Code

New file. use for building with gtk28
[inkscape.git] / src / event-context.cpp
index 8bda4b6c4255e335bd06feac01a38ce484188f23..e63df0d2f5eedff819df23361987fe696f2d5c99 100644 (file)
@@ -172,17 +172,22 @@ sp_event_context_update_cursor(SPEventContext *ec)
 {
     GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(ec->desktop));
     if (w->window) {
-         GdkDisplay *display=gdk_display_get_default();
-         if (ec->cursor) 
-             gdk_cursor_unref(ec->cursor);
-         ec->cursor=sp_cursor_new(
-                 display,
-                 ec->cursor_pixbuf,
-                 ec->cursor_shape,
-                 ec->hot_x,
-                 ec->hot_y);
+        /* fixme: */
+        if (ec->cursor_shape) {
+            GdkBitmap *bitmap = NULL;
+            GdkBitmap *mask = NULL;
+            sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape);
+            if ((bitmap != NULL) && (mask != NULL)) {
+                if (ec->cursor)
+                    gdk_cursor_unref (ec->cursor);
+                ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask,
+                                                        &w->style->black,
+                                                        &w->style->white,
+                                                        ec->hot_x, ec->hot_y);
+                g_object_unref (bitmap);
+                g_object_unref (mask);
+            }
+        }
         gdk_window_set_cursor(w->window, ec->cursor);
     }
 }
@@ -447,6 +452,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
         case GDK_BUTTON_RELEASE:
             if (within_tolerance && (panning || zoom_rb)) {
                 dontgrab ++;
+                zoom_rb = 0;
                 NR::Point const event_w(event->button.x, event->button.y);
                 NR::Point const event_dt(desktop->w2d(event_w));
                 double const zoom_power = ( (event->button.state & GDK_SHIFT_MASK)
@@ -474,9 +480,13 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
             break;
         case GDK_KEY_PRESS:
             switch (get_group0_keyval(&event->key)) {
+                // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
+                // in the editing window). So we resteal them back and run our regular shortcut
+                // invoker on them.
                 unsigned int shortcut;
+                case GDK_Tab: 
+                case GDK_ISO_Left_Tab: 
                 case GDK_F1:
-                    /* Grab it away from Gtk */
                     shortcut = get_group0_keyval(&event->key);
                     if (event->key.state & GDK_SHIFT_MASK)
                         shortcut |= SP_SHORTCUT_SHIFT_MASK;
@@ -487,22 +497,6 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                     ret = sp_shortcut_invoke(shortcut, desktop);
                     break;
 
-                case GDK_Tab: // disable tab/shift-tab which cycle widget focus
-                case GDK_ISO_Left_Tab: // they will get different functions
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        ret = TRUE;
-                    } else {
-                        /* Grab it away from Gtk */
-                        shortcut = get_group0_keyval(&event->key);
-                        if (event->key.state & GDK_SHIFT_MASK)
-                            shortcut |= SP_SHORTCUT_SHIFT_MASK;
-                        if (event->key.state & GDK_CONTROL_MASK)
-                            shortcut |= SP_SHORTCUT_CONTROL_MASK;
-                        if (event->key.state & GDK_MOD1_MASK)
-                            shortcut |= SP_SHORTCUT_ALT_MASK;
-                        ret = sp_shortcut_invoke(shortcut, desktop);
-                    }
-                    break;
                 case GDK_W:
                 case GDK_w:
                 case GDK_F4:
@@ -801,8 +795,8 @@ sp_event_context_deactivate(SPEventContext *ec)
     g_return_if_fail(ec != NULL);
     g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
 
-    if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate)
-        ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate(ec);
+    if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate)
+        ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate(ec);
 }
 
 /**