(go through Patches tracker and take the good stuff... now at 2009-05-09)
-** option to have buttons *toggle* the tool rather than act as tool
- (ie button 2 causes button 1 to map to tool 2) [Dylan Thurston]
+DONE?? option to have buttons *toggle* the tool rather than act as tool
+ (ie button 2 causes button 1 to map to tool 2) [Dylan Thurston]
+
+** commit patches from Bob McElrath
- paper color chooser (see tracker 2083103)
- prerelease: update help file (remove references to pdftoppm/libgnomeprint
& update to poppler/gtkprint)
+- REMOVE BINARY INSTALLER (poppler breaks ABI all the time)
- document config options into manual file?
- PDF bg memory usage throttling / delete oldest pdf backgrounds
- replace ttsubset by something more modern? (eg. from cairo ?)
to load pixmaps from pixmaps/$THEME/ (see Jan 9, 2009 emails)
** autosave patch (Edward Yang) (fix: optional only, w/ menu + cfgfile
entries; fix: should clean up autosave.xoj.bg* files too; config interval)
+- horizontal mode instead of dual-view / multicolumn ?
- patch (ikim@physics.wisc.edu): multicolumn mode + LASSO SELECTION
- patch: ortho/snap (revised Apr 13 2009)
** FIXME: get_pressure_multiplier() should access correct members
PDF file, default paper
- bug in truetype subset generation w/ Adobe 9, see if gtk-print any better?
+- drag-and-drop, copy-paste text & images directly into xournal
+- proximity detection: eraser proximity switches mapping?
+ proximity out removes cursor until next motionnotify?
+
- render page to bitmap: for export, preview, and copy-paste
(render using libart, see how gnomecanvas does it?)
NO: render using Cairo !!! then can switch to GtkPrint as well.
int mapping;
gboolean is_core;
struct Item *item;
+ GdkEvent scroll_event;
+#ifdef INPUT_DEBUG
+ printf("DEBUG: ButtonPress (%s) (x,y)=(%.2f,%.2f), button %d, modifier %x\n",
+ event->device->name, event->x, event->y, event->button, event->state);
+#endif
+
+ if (ui.cur_item_type != ITEM_TEXT) // remove focus from other elements
+ gtk_widget_grab_focus(GTK_WIDGET(canvas));
+
is_core = (event->device == gdk_device_get_core_pointer());
if (!ui.use_xinput && !is_core) return FALSE;
if (ui.use_xinput && is_core && ui.discard_corepointer) return FALSE;
- if (event->button > 3) return FALSE; // no painting with the mouse wheel!
if (event->type != GDK_BUTTON_PRESS) return FALSE;
// double-clicks may have broken axes member (free'd) due to a bug in GDK
+
+ if (event->button > 3) { // scroll wheel events! don't paint...
+ if (ui.use_xinput && !gtk_check_version(2, 17, 0) && event->button <= 7) {
+ /* with GTK+ 2.17 and later, the entire widget hierarchy is xinput-aware,
+ so the core button event gets discarded and the scroll event never
+ gets processed by the main window. This is arguably a GTK+ bug.
+ We work around it. */
+ scroll_event.scroll.type = GDK_SCROLL;
+ scroll_event.scroll.window = event->window;
+ scroll_event.scroll.send_event = event->send_event;
+ scroll_event.scroll.time = event->time;
+ scroll_event.scroll.x = event->x;
+ scroll_event.scroll.y = event->y;
+ scroll_event.scroll.state = event->state;
+ scroll_event.scroll.device = event->device;
+ scroll_event.scroll.x_root = event->x_root;
+ scroll_event.scroll.y_root = event->y_root;
+ if (event->button == 4) scroll_event.scroll.direction = GDK_SCROLL_UP;
+ else if (event->button == 5) scroll_event.scroll.direction = GDK_SCROLL_DOWN;
+ else if (event->button == 6) scroll_event.scroll.direction = GDK_SCROLL_LEFT;
+ else scroll_event.scroll.direction = GDK_SCROLL_RIGHT;
+ printf("sending...\n");
+ gtk_widget_event(GET_COMPONENT("scrolledwindowMain"), &scroll_event);
+ }
+ return FALSE;
+ }
if ((event->state & (GDK_CONTROL_MASK|GDK_MOD1_MASK)) != 0) return FALSE;
// no control-clicking or alt-clicking
if (!is_core)
fix_xinput_coords((GdkEvent *)event);
-#ifdef INPUT_DEBUG
- printf("DEBUG: ButtonDown (%s) (x,y)=(%.2f,%.2f)\n",
- is_core?"core":"xinput", event->x, event->y);
-#endif
if (!finite(event->x) || !finite(event->y)) return FALSE; // Xorg 7.3 bug
if (ui.cur_item_type == ITEM_TEXT) {
// if button_switch_mapping enabled, button 2 or 3 clicks only switch mapping
if (ui.button_switch_mapping && event->button > 1) {
- if (is_core == ui.use_xinput) return FALSE; // duplicate event
- if (ui.cur_mapping == event->button-1) switch_mapping(0);
- else switch_mapping(event->button-1);
+ ui.which_unswitch_button = event->button;
+ switch_mapping(event->button-1);
return FALSE;
}
ui.is_corestroke = is_core;
+ ui.stroke_device = event->device;
if (ui.use_erasertip && event->device->source == GDK_SOURCE_ERASER)
- mapping = NUM_BUTTONS;
- else if (ui.button_switch_mapping) mapping = ui.cur_mapping;
+ mapping = NUM_BUTTONS;
+ else if (ui.button_switch_mapping) {
+ mapping = ui.cur_mapping;
+ if (!mapping && (event->state & GDK_BUTTON2_MASK)) mapping = 1;
+ if (!mapping && (event->state & GDK_BUTTON3_MASK)) mapping = 2;
+ }
else mapping = event->button-1;
// check whether we're in a page
{
gboolean is_core;
- if (ui.cur_item_type == ITEM_NONE) return FALSE; // not doing anything
-
- if (event->button != ui.which_mouse_button) return FALSE; // ignore
+#ifdef INPUT_DEBUG
+ printf("DEBUG: ButtonRelease (%s) (x,y)=(%.2f,%.2f), button %d, modifier %x\n",
+ event->device->name, event->x, event->y, event->button, event->state);
+#endif
is_core = (event->device == gdk_device_get_core_pointer());
if (!ui.use_xinput && !is_core) return FALSE;
if (ui.use_xinput && is_core && !ui.is_corestroke) return FALSE;
if (!is_core) fix_xinput_coords((GdkEvent *)event);
+ if (event->button != ui.which_mouse_button &&
+ event->button != ui.which_unswitch_button)
+ return FALSE;
+
if (ui.cur_item_type == ITEM_STROKE) {
finalize_stroke();
if (ui.cur_brush->recognizer) recognize_patterns();
else if (ui.cur_item_type == ITEM_HAND) {
ui.cur_item_type = ITEM_NONE;
}
+
+ if (!ui.which_unswitch_button || event->button == ui.which_unswitch_button)
+ switch_mapping(0); // will reset ui.which_unswitch_button
- if (!ui.button_switch_mapping || ui.cur_mapping == NUM_BUTTONS)
- switch_mapping(0);
return FALSE;
}
{
gboolean looks_wrong, is_core;
double pt[2];
+ GdkModifierType mask;
/* we don't care about this event unless some operation is in progress;
or if there's a selection (then we might want to change the mouse
if (!is_core) ui.is_corestroke = FALSE;
#ifdef INPUT_DEBUG
- printf("DEBUG: MotionNotify (%s) (x,y)=(%.2f,%.2f)\n",
- is_core?"core":"xinput", event->x, event->y);
+ printf("DEBUG: MotionNotify (%s) (x,y)=(%.2f,%.2f), modifier %x\n",
+ is_core?"core":"xinput", event->x, event->y, event->state);
#endif
looks_wrong = !(event->state & (1<<(7+ui.which_mouse_button)));
+ if (looks_wrong) {
+ gdk_device_get_state(ui.stroke_device, event->window, NULL, &mask);
+ looks_wrong = !(mask & (1<<(7+ui.which_mouse_button)));
+ }
if (looks_wrong) { /* mouse button shouldn't be up... give up */
if (ui.cur_item_type == ITEM_STROKE) {
/* HOW THINGS USED TO BE:
- We'd like ONLY the canvas window itself to receive
- XInput events, while its child window in the GDK hierarchy (also
- associated to the canvas widget) receives the core events.
- This way on_canvas_... will get both types of events -- otherwise,
- the proximity detection code in GDK is broken and we'll lose core
- events.
+ We'd like on_canvas_... to get BOTH core and xinput events. Up to
+ GTK+ 2.16 this is achieved by making only the canvas's parent
+ GdkWindow xinput-aware, rather than the entire hierarchy.
+ Otherwise, the proximity detection code in GDK is broken and
+ we'll lose core events.
Up to GTK+ 2.10, gtk_widget_set_extension_events() only sets
extension events for the widget's main window itself; in GTK+ 2.11
non-responsive).
*/
- // this causes core events to be discarded... unwanted!
-/*
- gtk_widget_set_extension_events(GTK_WIDGET (canvas),
+ if (!gtk_check_version(2, 17, 0)) {
+ /* GTK+ 2.17 and later: everybody shares a single native window,
+ so we'll never get any core events, and we might as well set
+ extension events the way we're supposed to. Doing so helps solve
+ crasher bugs in 2.17, and prevents us from losing two-button
+ events in 2.18 */
+ gtk_widget_set_extension_events(GTK_WIDGET (canvas),
+ ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
+ } else {
+ /* GTK+ 2.16 and earlier: we only activate extension events on the
+ canvas's parent GdkWindow. This allows us to keep receiving core
+ events. */
+ gdk_input_set_extension_events(GTK_WIDGET(canvas)->window,
+ GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
-*/
-
- // this version only activates extension events on the canvas's parent GdkWindow
- gdk_input_set_extension_events(GTK_WIDGET(canvas)->window,
- GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
- ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
-
+ }
+
update_mappings_menu();
}
void realloc_cur_path(int n)
{
if (n <= ui.cur_path_storage_alloc) return;
- ui.cur_path_storage_alloc = n+10;
- ui.cur_path.coords = g_realloc(ui.cur_path.coords, 2*(n+10)*sizeof(double));
+ ui.cur_path_storage_alloc = n+100;
+ ui.cur_path.coords = g_realloc(ui.cur_path.coords, 2*(n+100)*sizeof(double));
}
void realloc_cur_widths(int n)
{
if (n <= ui.cur_widths_storage_alloc) return;
- ui.cur_widths_storage_alloc = n+10;
- ui.cur_widths = g_realloc(ui.cur_widths, (n+10)*sizeof(double));
+ ui.cur_widths_storage_alloc = n+100;
+ ui.cur_widths = g_realloc(ui.cur_widths, (n+100)*sizeof(double));
}
// undo utility functions
*py = iy + sy;
}
else {
- *px += sx;
- *py += sy;
+ /* with GTK+ 2.16 or earlier, the event comes from the parent gdkwindow
+ and so needs to be adjusted for scrolling */
+ if (gtk_major_version == 2 && gtk_minor_version <= 16) {
+ *px += sx;
+ *py += sy;
+ }
/* with GTK+ 2.17, events come improperly translated, and the event's
GdkWindow isn't even the same for ButtonDown as for MotionNotify... */
- if (!gtk_check_version(2,17,0)) { // GTK+ 2.17 issues !!
+ if (gtk_major_version == 2 && gtk_minor_version == 17) { // GTK+ 2.17 issues !!
gdk_window_get_position(GTK_WIDGET(canvas)->window, &wx, &wy);
- *px -= wx;
- *py -= wy;
+ *px += sx - wx;
+ *py += sy - wy;
}
}
#endif
/* NOTE ABOUT BUTTON MAPPINGS: ui.cur_mapping is 0 except while a canvas
click event is being processed ... or if ui.button_switch_mapping is
- enabled and mappings are switched! */
+ enabled and mappings are switched (but even then, canvas should have
+ a pointer grab from the initial click that switched the mapping) */
void switch_mapping(int m)
{
ui.cur_brush = &(ui.brushes[m][ui.toolno[m]]);
if (ui.toolno[m] == TOOL_TEXT)
ui.cur_brush = &(ui.brushes[m][TOOL_PEN]);
+ if (m==0) ui.which_unswitch_button = 0;
+
update_tool_buttons();
update_color_menu();
update_cursor();
gboolean is_shown;
g_object_get(G_OBJECT(widget), "popup-shown", &is_shown, NULL);
- gdk_input_set_extension_events(GTK_WIDGET(canvas)->window,
- GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
- (ui.use_xinput && !is_shown)?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
+ gtk_widget_set_extension_events(GTK_WIDGET (canvas),
+ (ui.use_xinput && !is_shown)?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
}
-
-