]> Pileus Git - ~andy/gtk/commitdiff
Handle events in windows other than widget->event_window properly.
authorOwen Taylor <otaylor@redhat.com>
Sat, 24 Nov 2001 00:24:18 +0000 (00:24 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 24 Nov 2001 00:24:18 +0000 (00:24 +0000)
Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
* gtk/gtknotebook.c: Handle events in windows other
than widget->event_window properly. (#65079, reported
by Damon Chaplin)
* gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkevents.c
gtk/gtknotebook.c

index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index d8e178ba0f6dcfeb773325752bdc1033a53bf972..8f7e4d899d9855cc8ce72d5db906bc34f840ad6b 100644 (file)
@@ -1,7 +1,15 @@
+Fri Nov 23 19:22:50 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtknotebook.c: Handle events in windows other
+       than widget->event_window properly. (#65079, reported
+       by Damon Chaplin)
+
+       * gdk/gdkevents.c (gdk_event_get_coords): Fix x/y bug.
+
 Fri Nov 23 18:57:46 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmessagedialog.c (gtk_message_dialog_init): Align
-       the image at the top#65020, request from Seth Nickell)
+       the image at the top. (#65020, request from Seth Nickell)
 
 Fri Nov 23 18:49:53 2001  Owen Taylor  <otaylor@redhat.com>
 
index 4b9219553831cbe9fb0096b82d7687150158321a..fce4dbcbe3274be9cc2eb9a06f5fa64fbd11f3b4 100644 (file)
@@ -603,7 +603,7 @@ gdk_event_get_coords (GdkEvent *event,
   if (x_win)
     *x_win = x;
   if (y_win)
-    *y_win = x;
+    *y_win = y;
 
   return fetched;
 }
index f9f08c211320afb61ef19dd06a9d31f6f7bfc0e2..ae2ff72fc842f9fefa903776e9001f4cabee9a90 100644 (file)
@@ -1315,8 +1315,8 @@ gtk_notebook_get_arrow (GtkNotebook *notebook,
       gtk_notebook_get_event_window_position (notebook, &event_window_pos);
       gtk_notebook_get_arrow_rect (notebook, &arrow_rect);
       
-      x -= arrow_rect.x - event_window_pos.x;
-      y -= arrow_rect.y - event_window_pos.y;
+      x -= arrow_rect.x;
+      y -= arrow_rect.y;
       
       if (y >= 0 && y < arrow_rect.height)
        {
@@ -1380,6 +1380,40 @@ gtk_notebook_arrow_button_press (GtkNotebook    *notebook,
   return TRUE;
 }
 
+static gboolean
+get_widget_coordinates (GtkWidget *widget,
+                       GdkEvent  *event,
+                       gint      *x,
+                       gint      *y)
+{
+  GdkWindow *window = ((GdkEventAny *)event)->window;
+  gdouble tx, ty;
+
+  if (!gdk_event_get_coords (event, &tx, &ty))
+    return FALSE;
+
+  while (window && window != widget->window)
+    {
+      gint window_x, window_y;
+      
+      gdk_window_get_position (window, &window_x, &window_y);
+      tx += window_x;
+      ty += window_y;
+
+      window = gdk_window_get_parent (window);
+    }
+
+  if (window)
+    {
+      *x = tx;
+      *y = ty;
+
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
 static gboolean
 gtk_notebook_button_press (GtkWidget      *widget,
                           GdkEventButton *event)
@@ -1388,7 +1422,6 @@ gtk_notebook_button_press (GtkWidget      *widget,
   GtkNotebookPage *page;
   GList *children;
   GtkArrowType arrow;
-  GdkRectangle event_window_pos;
   gint num;
   gint x, y;
 
@@ -1396,7 +1429,10 @@ gtk_notebook_button_press (GtkWidget      *widget,
       notebook->button)
     return FALSE;
 
-  arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
+  if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
+    return FALSE;
+
+  arrow = gtk_notebook_get_arrow (notebook, x, y);
   if (arrow)
     return gtk_notebook_arrow_button_press (notebook, arrow, event);
 
@@ -1407,12 +1443,6 @@ gtk_notebook_button_press (GtkWidget      *widget,
       return TRUE;
     }
 
-  /* Translate coordinates from event_window to widget->window
-   */
-  gtk_notebook_get_event_window_position (notebook, &event_window_pos);
-  x = event->x + event_window_pos.x;
-  y = event->y + event_window_pos.y;
-      
   num = 0;
   children = notebook->children;
   while (children)
@@ -1496,13 +1526,17 @@ gtk_notebook_enter_notify (GtkWidget        *widget,
 {
   GtkNotebook *notebook;
   GtkArrowType arrow;
+  gint x, y;
 
   g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
 
   notebook = GTK_NOTEBOOK (widget);
 
-  arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
+  if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
+    return FALSE;
+
+  arrow = gtk_notebook_get_arrow (notebook, x, y);
 
   if (arrow != notebook->in_child)
     {
@@ -1521,8 +1555,12 @@ gtk_notebook_leave_notify (GtkWidget        *widget,
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkArrowType arrow;
+  gint x, y;
+
+  if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
+    return FALSE;
 
-  arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
+  arrow = gtk_notebook_get_arrow (notebook, x, y);
 
   if (notebook->in_child)
     {
@@ -1539,11 +1577,15 @@ gtk_notebook_motion_notify (GtkWidget      *widget,
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkArrowType arrow;
-
+  gint x, y;
+  
   if (notebook->button)
     return FALSE;
 
-  arrow = gtk_notebook_get_arrow (notebook, event->x, event->y);
+  if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
+    return FALSE;
+
+  arrow = gtk_notebook_get_arrow (notebook, x, y);
 
   if (arrow != notebook->in_child)
     {