X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fxo-callbacks.c;h=8dad7c9fdd6b053286ea136be8fa6a6766e38ce8;hb=HEAD;hp=8c6f098a1cdc88566305da6b6181386ad3960a0d;hpb=bc1db27c7eef7de6d5097a5e708d2de540d35b88;p=xournal.git diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c index 8c6f098..8dad7c9 100644 --- a/src/xo-callbacks.c +++ b/src/xo-callbacks.c @@ -33,6 +33,7 @@ #include "xo-misc.h" #include "xo-file.h" #include "xo-paint.h" +#include "xo-selection.h" #include "xo-print.h" #include "xo-shapes.h" @@ -1807,7 +1808,25 @@ void on_toolsSelectRegion_activate (GtkMenuItem *menuitem, gpointer user_data) { - + if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_RADIO_MENU_ITEM) { + if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) + return; + } else { + if (!gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem))) + return; + } + + if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated + if (ui.toolno[ui.cur_mapping] == TOOL_SELECTREGION) return; + + ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon) + end_text(); + ui.toolno[ui.cur_mapping] = TOOL_SELECTREGION; + update_mapping_linkings(-1); + update_tool_buttons(); + update_tool_menu(); + update_color_menu(); + update_cursor(); } @@ -2438,6 +2457,7 @@ on_canvas_button_press_event (GtkWidget *widget, ui.cur_path.num_points == 1) { // Xorg 7.3+ sent core event before XInput event: fix initial point ui.is_corestroke = FALSE; + ui.stroke_device = event->device; get_pointer_coords((GdkEvent *)event, ui.cur_path.coords); } if (ui.cur_item_type != ITEM_NONE) return FALSE; // we're already doing something @@ -2520,6 +2540,9 @@ on_canvas_button_press_event (GtkWidget *widget, do_eraser((GdkEvent *)event, ui.cur_brush->thickness/2, ui.cur_brush->tool_options == TOOLOPT_ERASER_STROKES); } + else if (ui.toolno[mapping] == TOOL_SELECTREGION) { + start_selectregion((GdkEvent *)event); + } else if (ui.toolno[mapping] == TOOL_SELECTRECT) { start_selectrect((GdkEvent *)event); } @@ -2551,6 +2574,7 @@ on_canvas_button_release_event (GtkWidget *widget, 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 (ui.ignore_other_devices && ui.stroke_device!=event->device) return FALSE; if (!is_core) fix_xinput_coords((GdkEvent *)event); if (event->button != ui.which_mouse_button && @@ -2564,6 +2588,9 @@ on_canvas_button_release_event (GtkWidget *widget, else if (ui.cur_item_type == ITEM_ERASURE) { finalize_erasure(); } + else if (ui.cur_item_type == ITEM_SELECTREGION) { + finalize_selectregion(); + } else if (ui.cur_item_type == ITEM_SELECTRECT) { finalize_selectrect(); } @@ -2735,11 +2762,15 @@ on_canvas_motion_notify_event (GtkWidget *widget, } if (ui.use_xinput && is_core && !ui.is_corestroke) return FALSE; - if (!is_core) ui.is_corestroke = FALSE; + if (!is_core && ui.is_corestroke) { + ui.is_corestroke = FALSE; + ui.stroke_device = event->device; + } + if (ui.ignore_other_devices && ui.stroke_device!=event->device) return FALSE; #ifdef INPUT_DEBUG printf("DEBUG: MotionNotify (%s) (x,y)=(%.2f,%.2f), modifier %x\n", - is_core?"core":"xinput", event->x, event->y, event->state); + event->device->name, event->x, event->y, event->state); #endif looks_wrong = !(event->state & (1<<(7+ui.which_mouse_button))); @@ -2756,6 +2787,9 @@ on_canvas_motion_notify_event (GtkWidget *widget, else if (ui.cur_item_type == ITEM_ERASURE) { finalize_erasure(); } + else if (ui.cur_item_type == ITEM_SELECTREGION) { + finalize_selectregion(); + } else if (ui.cur_item_type == ITEM_SELECTRECT) { finalize_selectrect(); } @@ -2779,6 +2813,9 @@ on_canvas_motion_notify_event (GtkWidget *widget, do_eraser((GdkEvent *)event, ui.cur_brush->thickness/2, ui.cur_brush->tool_options == TOOLOPT_ERASER_STROKES); } + else if (ui.cur_item_type == ITEM_SELECTREGION) { + continue_selectregion((GdkEvent *)event); + } else if (ui.cur_item_type == ITEM_SELECTRECT) { get_pointer_coords((GdkEvent *)event, pt); ui.selection->bbox.right = pt[0];