[gtk+] Don't start a drag if we are not resizable



commit 5e1d8814ca005e2e28fdd579e060191d0db23cdc
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Oct 13 08:28:21 2010 -0400

    Don't start a drag if we are not resizable
    
    This was caused by get_drag_edge() returning -1 to mean 'no drag',
    but callers didn't really pay attention. Change get_drag_edge()
    to return a boolean instead.

 gtk/gtkwindow.c |   81 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 43 insertions(+), 38 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 1445752..cae6a80 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5015,15 +5015,15 @@ get_grip_edge (GtkWidget *widget)
          : GDK_WINDOW_EDGE_SOUTH_WEST;
 }
 
-static GdkWindowEdge
-get_drag_edge (GtkWidget *widget)
+static gboolean
+get_drag_edge (GtkWidget     *widget,
+               GdkWindowEdge *edge)
 {
   GdkGeometry geometry;
   guint flags;
   gboolean hresizable;
   gboolean vresizable;
   GtkTextDirection dir;
-  GdkWindowEdge edge;
 
   gtk_window_compute_hints (GTK_WINDOW (widget), &geometry, &flags);
 
@@ -5041,15 +5041,15 @@ get_drag_edge (GtkWidget *widget)
   dir = gtk_widget_get_direction (widget);
 
   if (hresizable && vresizable)
-    edge = dir == GTK_TEXT_DIR_LTR ? GDK_WINDOW_EDGE_SOUTH_EAST : GDK_WINDOW_EDGE_SOUTH_WEST;
+    *edge = dir == GTK_TEXT_DIR_LTR ? GDK_WINDOW_EDGE_SOUTH_EAST : GDK_WINDOW_EDGE_SOUTH_WEST;
   else if (hresizable)
-    edge = dir == GTK_TEXT_DIR_LTR ? GDK_WINDOW_EDGE_EAST : GDK_WINDOW_EDGE_WEST;
+    *edge = dir == GTK_TEXT_DIR_LTR ? GDK_WINDOW_EDGE_EAST : GDK_WINDOW_EDGE_WEST;
   else if (vresizable)
-    edge = GDK_WINDOW_EDGE_SOUTH;
+    *edge = GDK_WINDOW_EDGE_SOUTH;
   else
-    edge = (GdkWindowEdge)-1;
+    return FALSE;
 
-  return edge;
+  return TRUE;
 }
 
 static void
@@ -5057,37 +5057,40 @@ set_grip_cursor (GtkWindow *window)
 {
   GtkWidget *widget = GTK_WIDGET (window);
   GtkWindowPrivate *priv = window->priv;
-  GdkWindowEdge edge;
-  GdkDisplay *display;
-  GdkCursorType cursor_type;
-  GdkCursor *cursor;
 
   if (priv->grip_window == NULL)
     return;
 
   if (gtk_widget_is_sensitive (widget))
     {
-      edge = get_drag_edge (widget);
-      switch (edge)
+      GdkWindowEdge edge;
+      GdkDisplay *display;
+      GdkCursorType cursor_type;
+      GdkCursor *cursor;
+
+      cursor_type = GDK_LEFT_PTR;
+
+      if (get_drag_edge (widget, &edge))
         {
-        case GDK_WINDOW_EDGE_EAST:
-          cursor_type = GDK_RIGHT_SIDE;
-          break;
-        case GDK_WINDOW_EDGE_SOUTH_EAST:
-          cursor_type = GDK_BOTTOM_RIGHT_CORNER;
-          break;
-        case GDK_WINDOW_EDGE_SOUTH:
-          cursor_type = GDK_BOTTOM_SIDE;
-          break;
-        case GDK_WINDOW_EDGE_SOUTH_WEST:
-          cursor_type = GDK_BOTTOM_LEFT_CORNER;
-          break;
-        case GDK_WINDOW_EDGE_WEST:
-          cursor_type = GDK_LEFT_SIDE;
-          break;
-        default:
-          cursor_type = GDK_LEFT_PTR;
-          break;
+          switch (edge)
+            {
+            case GDK_WINDOW_EDGE_EAST:
+              cursor_type = GDK_RIGHT_SIDE;
+              break;
+            case GDK_WINDOW_EDGE_SOUTH_EAST:
+              cursor_type = GDK_BOTTOM_RIGHT_CORNER;
+              break;
+            case GDK_WINDOW_EDGE_SOUTH:
+              cursor_type = GDK_BOTTOM_SIDE;
+              break;
+            case GDK_WINDOW_EDGE_SOUTH_WEST:
+              cursor_type = GDK_BOTTOM_LEFT_CORNER;
+              break;
+            case GDK_WINDOW_EDGE_WEST:
+              cursor_type = GDK_LEFT_SIDE;
+              break;
+            default: ;
+            }
         }
 
       display = gtk_widget_get_display (widget);
@@ -5718,15 +5721,17 @@ gtk_window_button_press_event (GtkWidget *widget,
                                GdkEventButton *event)
 {
   GtkWindowPrivate *priv = GTK_WINDOW (widget)->priv;
+  GdkWindowEdge edge;
 
   if (event->window == priv->grip_window)
     {
-      gtk_window_begin_resize_drag (GTK_WINDOW (widget),
-                                    get_drag_edge (widget),
-                                    event->button,
-                                    event->x_root,
-                                    event->y_root,
-                                    event->time);
+      if (get_drag_edge (widget, &edge))
+        gtk_window_begin_resize_drag (GTK_WINDOW (widget),
+                                      edge,
+                                      event->button,
+                                      event->x_root,
+                                      event->y_root,
+                                      event->time);
 
       return TRUE;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]