summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-12-14 02:41:30 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-12-14 02:41:30 +0000
commit30b328e79aada4b0d029879e11b58cf6ca2b0073 (patch)
tree6c67157a1cf5d6e3bf7955de42994ccfe084196b /gtk
parent59f712ad5f622d40ebd854dfa8d0882730adf106 (diff)
downloadgtk+-30b328e79aada4b0d029879e11b58cf6ca2b0073.tar.gz
Handle the case where the pointer is moved between screens during a handle
Fri Dec 13 21:35:12 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_motion): Handle the case where the pointer is moved between screens during a handle box drag by resetting the original location. (#94562) * gtk/gtkinputdialog.c (gtk_input_dialog_get_private): Fix a leftover variable name from cut-and-paste.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkhandlebox.c50
-rw-r--r--gtk/gtkinputdialog.c6
2 files changed, 50 insertions, 6 deletions
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index 9611d12de6..c34d90f9e1 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -32,6 +32,14 @@
#include "gtkwindow.h"
#include "gtkintl.h"
+typedef struct _GtkHandleBoxPrivate GtkHandleBoxPrivate;
+
+struct _GtkHandleBoxPrivate
+{
+ gint orig_x;
+ gint orig_y;
+};
+
enum {
PROP_0,
PROP_SHADOW,
@@ -264,6 +272,27 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
GTK_TYPE_WIDGET);
}
+GtkHandleBoxPrivate *
+gtk_handle_box_get_private (GtkHandleBox *hb)
+{
+ GtkHandleBoxPrivate *private;
+ static GQuark private_quark = 0;
+
+ if (!private_quark)
+ private_quark = g_quark_from_static_string ("gtk-handle-box-private");
+
+ private = g_object_get_qdata (G_OBJECT (hb), private_quark);
+
+ if (!private)
+ {
+ private = g_new0 (GtkHandleBoxPrivate, 1);
+ g_object_set_qdata_full (G_OBJECT (hb), private_quark,
+ private, g_free);
+ }
+
+ return private;
+}
+
static void
gtk_handle_box_init (GtkHandleBox *handle_box)
{
@@ -1022,13 +1051,17 @@ gtk_handle_box_button_changed (GtkWidget *widget,
{
if (event->type == GDK_BUTTON_PRESS) /* Start a drag */
{
+ GtkHandleBoxPrivate *private = gtk_handle_box_get_private (hb);
gint desk_x, desk_y;
gint root_x, root_y;
gint width, height;
-
+
gdk_window_get_deskrelative_origin (hb->bin_window, &desk_x, &desk_y);
gdk_window_get_origin (hb->bin_window, &root_x, &root_y);
gdk_drawable_get_size (hb->bin_window, &width, &height);
+
+ private->orig_x = event->x_root;
+ private->orig_y = event->y_root;
hb->float_allocation.x = root_x - event->x_root;
hb->float_allocation.y = root_y - event->y_root;
@@ -1095,6 +1128,7 @@ gtk_handle_box_motion (GtkWidget *widget,
gboolean is_snapped = FALSE;
gint handle_position;
GdkGeometry geometry;
+ GdkScreen *screen, *pointer_screen;
hb = GTK_HANDLE_BOX (widget);
if (!hb->in_drag)
@@ -1110,8 +1144,18 @@ gtk_handle_box_motion (GtkWidget *widget,
*/
new_x = 0;
new_y = 0;
- gdk_window_get_pointer (gtk_widget_get_root_window (widget),
- &new_x, &new_y, NULL);
+ screen = gtk_widget_get_screen (widget);
+ gdk_display_get_pointer (gdk_screen_get_display (screen),
+ &pointer_screen,
+ &new_x, &new_y, NULL);
+ if (pointer_screen != screen)
+ {
+ GtkHandleBoxPrivate *private = gtk_handle_box_get_private (hb);
+
+ new_x = private->orig_x;
+ new_y = private->orig_y;
+ }
+
new_x += hb->float_allocation.x;
new_y += hb->float_allocation.y;
diff --git a/gtk/gtkinputdialog.c b/gtk/gtkinputdialog.c
index 0efe51a34a..ffb35e807f 100644
--- a/gtk/gtkinputdialog.c
+++ b/gtk/gtkinputdialog.c
@@ -146,7 +146,7 @@ gtk_input_dialog_get_type (void)
}
GtkInputDialogPrivate *
-gtk_input_dialog_get_private (GtkInputDialog *menu)
+gtk_input_dialog_get_private (GtkInputDialog *input_dialog)
{
GtkInputDialogPrivate *private;
static GQuark private_quark = 0;
@@ -154,12 +154,12 @@ gtk_input_dialog_get_private (GtkInputDialog *menu)
if (!private_quark)
private_quark = g_quark_from_static_string ("gtk-input-dialog-private");
- private = g_object_get_qdata (G_OBJECT (menu), private_quark);
+ private = g_object_get_qdata (G_OBJECT (input_dialog), private_quark);
if (!private)
{
private = g_new0 (GtkInputDialogPrivate, 1);
- g_object_set_qdata_full (G_OBJECT (menu), private_quark,
+ g_object_set_qdata_full (G_OBJECT (input_dialog), private_quark,
private, g_free);
}