]> git.donarmstrong.com Git - xournal.git/commitdiff
ignore events from non-drawing devices by default (ignore_other_devices)
authorauroux <auroux>
Sat, 11 Aug 2012 21:32:22 +0000 (21:32 +0000)
committerauroux <auroux>
Sat, 11 Aug 2012 21:32:22 +0000 (21:32 +0000)
ChangeLog
src/xo-callbacks.c
src/xo-clipboard.c
src/xo-file.c
src/xo-misc.c
src/xournal.h

index 5b464b916622c58902d36f7af4b9e485c229242d..0d7dc7431b6be48528e05bf45660e6df8bd35ae4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ This version:
   - work around Win32 bug: refuse paste if mismatched format
   - Chinese (simplified) translation (by Mutse)
   - updated German translation (Stefan Holtzhauer)
+  - ignore events from non-drawing devices by default (ignore_other_devices)
 
 Version 0.4.7 (July 4, 2012):
   - insert image tool (based on patches by Victor Saase and Simon Guest)
index 50672f6b14737a2edbf462266894798a12ffbd1d..8dad7c9fdd6b053286ea136be8fa6a6766e38ce8 100644 (file)
@@ -2457,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
@@ -2573,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 && 
@@ -2760,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)));
index 3d6cb41aaa28df66046760f65da586e23ea8538f..7beef32b7c51711a757072ff1584940dbc8bf5d2 100644 (file)
@@ -71,7 +71,7 @@ void callback_clipboard_clear(GtkClipboard *clipboard, gpointer user_data)
   
   if (sel->xo_data!=NULL) g_free(sel->xo_data);
   if (sel->text_data!=NULL) g_free(sel->text_data);
-  if (sel->image_data!=NULL) gdk_pixbuf_unref(sel->image_data);
+  if (sel->image_data!=NULL) g_object_unref(sel->image_data);
   g_free(sel);
 }
 
index 082d399f36c3d4d26ae9bc7970d9a685ae091cb6..ac8753c73c118099785f777117bbf1c3538792d5 100644 (file)
@@ -456,7 +456,7 @@ void xoj_parser_start_element(GMarkupParseContext *context,
             { *error = xoj_invalid(); return; }
           tmpPage->bg->filename = refstring_ref(tmpbg->filename);
           tmpPage->bg->pixbuf = tmpbg->pixbuf;
-          if (tmpbg->pixbuf!=NULL) gdk_pixbuf_ref(tmpbg->pixbuf);
+          if (tmpbg->pixbuf!=NULL) g_object_ref(tmpbg->pixbuf);
           tmpPage->bg->file_domain = tmpbg->file_domain;
         }
         else {
@@ -1033,7 +1033,7 @@ GList *attempt_load_gv_bg(char *filename)
     if (remnlen == 0) { // make a new bg
       pix = gdk_pixbuf_loader_get_pixbuf(loader);
       if (pix == NULL) break;
-      gdk_pixbuf_ref(pix);
+      g_object_ref(pix);
       gdk_pixbuf_loader_close(loader, NULL);
       g_object_unref(loader);
       loader = NULL;
@@ -1177,7 +1177,7 @@ gboolean bgpdf_scheduler_callback(gpointer data)
       bgpdf.npages++;
     }
     bgpg = g_list_nth_data(bgpdf.pages, req->pageno-1);
-    if (bgpg->pixbuf!=NULL) gdk_pixbuf_unref(bgpg->pixbuf);
+    if (bgpg->pixbuf!=NULL) g_object_unref(bgpg->pixbuf);
     bgpg->pixbuf = pixbuf;
     bgpg->dpi = req->dpi;
     bgpg->pixel_height = scaled_height;
@@ -1240,7 +1240,7 @@ void shutdown_bgpdf(void)
   refstring_unref(bgpdf.filename);
   for (list = bgpdf.pages; list != NULL; list = list->next) {
     pdfpg = (struct BgPdfPage *)list->data;
-    if (pdfpg->pixbuf!=NULL) gdk_pixbuf_unref(pdfpg->pixbuf);
+    if (pdfpg->pixbuf!=NULL) g_object_unref(pdfpg->pixbuf);
     g_free(pdfpg);
   }
   g_list_free(bgpdf.pages);
@@ -1358,8 +1358,8 @@ void bgpdf_update_bg(int pageno, struct BgPdfPage *bgpg)
   for (list = journal.pages; list!= NULL; list = list->next) {
     pg = (struct Page *)list->data;
     if (pg->bg->type == BG_PDF && pg->bg->file_page_seq == pageno) {
-      if (pg->bg->pixbuf!=NULL) gdk_pixbuf_unref(pg->bg->pixbuf);
-      pg->bg->pixbuf = gdk_pixbuf_ref(bgpg->pixbuf);
+      if (pg->bg->pixbuf!=NULL) g_object_unref(pg->bg->pixbuf);
+      pg->bg->pixbuf = g_object_ref(bgpg->pixbuf);
       pg->bg->pixel_width = bgpg->pixel_width;
       pg->bg->pixel_height = bgpg->pixel_height;
       update_canvas_bg(pg);
@@ -1477,6 +1477,7 @@ void init_config_default(void)
   ui.view_continuous = TRUE;
   ui.allow_xinput = TRUE;
   ui.discard_corepointer = FALSE;
+  ui.ignore_other_devices = TRUE;
   ui.left_handed = FALSE;
   ui.shorten_menus = FALSE;
   ui.shorten_menu_items = g_strdup(DEFAULT_SHORTEN_MENUS);
@@ -1629,6 +1630,9 @@ void save_config_to_file(void)
   update_keyval("general", "discard_corepointer",
     _(" discard Core Pointer events in XInput mode (true/false)"),
     g_strdup(ui.discard_corepointer?"true":"false"));
+  update_keyval("general", "ignore_other_devices",
+    _(" ignore events from other devices while drawing (true/false)"),
+    g_strdup(ui.ignore_other_devices?"true":"false"));
   update_keyval("general", "use_erasertip",
     _(" always map eraser tip to eraser (true/false)"),
     g_strdup(ui.use_erasertip?"true":"false"));
@@ -2022,6 +2026,7 @@ void load_config_from_file(void)
   parse_keyval_boolean("general", "view_continuous", &ui.view_continuous);
   parse_keyval_boolean("general", "use_xinput", &ui.allow_xinput);
   parse_keyval_boolean("general", "discard_corepointer", &ui.discard_corepointer);
+  parse_keyval_boolean("general", "ignore_other_devices", &ui.ignore_other_devices);
   parse_keyval_boolean("general", "use_erasertip", &ui.use_erasertip);
   parse_keyval_boolean("general", "buttons_switch_mappings", &ui.button_switch_mapping);
   parse_keyval_boolean("general", "autoload_pdf_xoj", &ui.autoload_pdf_xoj);
index 3d866cf37da202002da89588a5711ceeb5d1f6e3..43279f24e8ee333f6d5244f5944e2d51e0a2db4c 100644 (file)
@@ -65,7 +65,7 @@ struct Page *new_page(struct Page *template)
   pg->bg = (struct Background *)g_memdup(template->bg, sizeof(struct Background));
   pg->bg->canvas_item = NULL;
   if (pg->bg->type == BG_PIXMAP || pg->bg->type == BG_PDF) {
-    gdk_pixbuf_ref(pg->bg->pixbuf);
+    g_object_ref(pg->bg->pixbuf);
     refstring_ref(pg->bg->filename);
   }
   pg->group = (GnomeCanvasGroup *) gnome_canvas_item_new(
@@ -204,7 +204,7 @@ void clear_redo_stack(void)
     else if (redo->type == ITEM_NEW_BG_ONE || redo->type == ITEM_NEW_BG_RESIZE
           || redo->type == ITEM_NEW_DEFAULT_BG) {
       if (redo->bg->type == BG_PIXMAP || redo->bg->type == BG_PDF) {
-        if (redo->bg->pixbuf!=NULL) gdk_pixbuf_unref(redo->bg->pixbuf);
+        if (redo->bg->pixbuf!=NULL) g_object_unref(redo->bg->pixbuf);
         refstring_unref(redo->bg->filename);
       }
       g_free(redo->bg);
@@ -276,7 +276,7 @@ void clear_undo_stack(void)
     else if (undo->type == ITEM_NEW_BG_ONE || undo->type == ITEM_NEW_BG_RESIZE
           || undo->type == ITEM_NEW_DEFAULT_BG) {
       if (undo->bg->type == BG_PIXMAP || undo->bg->type == BG_PDF) {
-        if (undo->bg->pixbuf!=NULL) gdk_pixbuf_unref(undo->bg->pixbuf);
+        if (undo->bg->pixbuf!=NULL) g_object_unref(undo->bg->pixbuf);
         refstring_unref(undo->bg->filename);
       }
       g_free(undo->bg);
@@ -333,7 +333,7 @@ void delete_page(struct Page *pg)
   if (pg->group!=NULL) gtk_object_destroy(GTK_OBJECT(pg->group));
               // this also destroys the background's canvas items
   if (pg->bg->type == BG_PIXMAP || pg->bg->type == BG_PDF) {
-    if (pg->bg->pixbuf != NULL) gdk_pixbuf_unref(pg->bg->pixbuf);
+    if (pg->bg->pixbuf != NULL) g_object_unref(pg->bg->pixbuf);
     if (pg->bg->filename != NULL) refstring_unref(pg->bg->filename);
   }
   g_free(pg->bg);
index 3ef9b27b873593c54b16a17444710ae376dd6e97..62625ab3285edbb5bc9640180ccdd81528aa9109 100644 (file)
@@ -276,6 +276,7 @@ typedef struct UIData {
   gboolean is_corestroke; // this stroke is painted with core pointer
   gboolean saved_is_corestroke;
   GdkDevice *stroke_device; // who's painting this stroke
+  gboolean ignore_other_devices;
   int screen_width, screen_height; // initial screen size, for XInput events
   double hand_refpt[2];
   int hand_scrollto_cx, hand_scrollto_cy;