summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/Makefile.am1
-rw-r--r--gtk/gtkaccelmap.c2
-rw-r--r--gtk/gtkmain.c31
-rw-r--r--gtk/gtkplug-x11.c1
-rw-r--r--gtk/gtkplug.c2
-rw-r--r--gtk/gtksocket-x11.c2
-rw-r--r--gtk/gtksocket.c2
-rw-r--r--gtk/gtkwidget.c2
-rw-r--r--gtk/gtkwindow.c84
-rw-r--r--gtk/gtkwindow.h63
-rw-r--r--gtk/gtkwindowprivate.h90
11 files changed, 156 insertions, 124 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index cbf8b3d89e..62be9e1bfe 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -433,6 +433,7 @@ gtk_private_h_sources = \
gtktreedatalist.h \
gtktreeprivate.h \
gtkwidgetprivate.h \
+ gtkwindowprivate.h \
$(gtk_clipboard_dnd_h_sources) \
$(gtk_appchooser_impl_h_sources)
diff --git a/gtk/gtkaccelmap.c b/gtk/gtkaccelmap.c
index de3745e2ce..2b0fc3d519 100644
--- a/gtk/gtkaccelmap.c
+++ b/gtk/gtkaccelmap.c
@@ -22,7 +22,7 @@
#include "gtkaccelmap.h"
#include "gtkmarshalers.h"
-#include "gtkwindow.h" /* in lack of GtkAcceleratable */
+#include "gtkwindowprivate.h"
#include "gtkintl.h"
#include <glib/gstdio.h>
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index dc303e7f8a..861ab0f44a 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -60,7 +60,7 @@
#include "gtkselection.h"
#include "gtksettings.h"
#include "gtkwidgetprivate.h"
-#include "gtkwindow.h"
+#include "gtkwindowprivate.h"
#include "gtktooltip.h"
#include "gtkdebug.h"
#include "gtkmenu.h"
@@ -1585,8 +1585,8 @@ gtk_main_do_event (GdkEvent *event)
if (device)
grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
- if (!grab_widget && window_group->grabs)
- grab_widget = window_group->grabs->data;
+ if (!grab_widget)
+ grab_widget = gtk_window_group_get_current_grab (window_group);
/* If the grab widget is an ancestor of the event widget
* then we send the event to the original event widget.
@@ -1629,7 +1629,7 @@ gtk_main_do_event (GdkEvent *event)
case GDK_DELETE:
g_object_ref (event_widget);
- if ((!window_group->grabs || gtk_widget_get_toplevel (window_group->grabs->data) == event_widget) &&
+ if ((!gtk_window_group_get_current_grab (window_group) || gtk_widget_get_toplevel (gtk_window_group_get_current_grab (window_group)) == event_widget) &&
!gtk_widget_event (event_widget, event))
gtk_widget_destroy (event_widget);
g_object_unref (event_widget);
@@ -1988,16 +1988,13 @@ gtk_grab_add (GtkWidget *widget)
if (!gtk_widget_has_grab (widget) && gtk_widget_is_sensitive (widget))
{
_gtk_widget_set_has_grab (widget, TRUE);
-
+
group = gtk_main_get_window_group (widget);
- if (group->grabs)
- old_grab_widget = (GtkWidget *)group->grabs->data;
- else
- old_grab_widget = NULL;
+ old_grab_widget = gtk_window_group_get_current_grab (group);
g_object_ref (widget);
- group->grabs = g_slist_prepend (group->grabs, widget);
+ _gtk_window_group_add_grab (group, widget);
gtk_grab_notify (group, NULL, old_grab_widget, widget, TRUE);
}
@@ -2018,9 +2015,7 @@ gtk_grab_get_current (void)
group = gtk_main_get_window_group (NULL);
- if (group->grabs)
- return GTK_WIDGET (group->grabs->data);
- return NULL;
+ return gtk_window_group_get_current_grab (group);
}
void
@@ -2036,15 +2031,11 @@ gtk_grab_remove (GtkWidget *widget)
_gtk_widget_set_has_grab (widget, FALSE);
group = gtk_main_get_window_group (widget);
- group->grabs = g_slist_remove (group->grabs, widget);
-
- if (group->grabs)
- new_grab_widget = (GtkWidget *)group->grabs->data;
- else
- new_grab_widget = NULL;
+ _gtk_window_group_remove_grab (group, widget);
+ new_grab_widget = gtk_window_group_get_current_grab (group);
gtk_grab_notify (group, NULL, widget, new_grab_widget, FALSE);
-
+
g_object_unref (widget);
}
}
diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c
index df98e93e29..827474b50e 100644
--- a/gtk/gtkplug-x11.c
+++ b/gtk/gtkplug-x11.c
@@ -45,6 +45,7 @@
#include "gtkplug.h"
#include "gtkprivate.h"
#include "gtkplugprivate.h"
+#include "gtkwindowprivate.h"
#include "gtkdebug.h"
#include "x11/gdkx.h"
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index d3aacabcec..fc63c8ca52 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -34,7 +34,7 @@
#include "gtkprivate.h"
#include "gtkplugprivate.h"
#include "gtkwidgetprivate.h"
-#include "gtkwindow.h"
+#include "gtkwindowprivate.h"
/**
* SECTION:gtkplug
diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c
index 963d832b85..83cdc5c28b 100644
--- a/gtk/gtksocket-x11.c
+++ b/gtk/gtksocket-x11.c
@@ -31,7 +31,7 @@
#include "gdk/gdkkeysyms.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
-#include "gtkwindow.h"
+#include "gtkwindowprivate.h"
#include "gtkplug.h"
#include "gtkprivate.h"
#include "gtksocket.h"
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index b50d1c8384..86d72a1689 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -35,7 +35,7 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtksizerequest.h"
-#include "gtkwindow.h"
+#include "gtkwindowprivate.h"
#include "gtkplug.h"
#include "gtkprivate.h"
#include "gtksocketprivate.h"
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b27cd38b8e..214a1cf913 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -41,7 +41,7 @@
#include "gtksizegroup-private.h"
#include "gtkwidget.h"
#include "gtkwidgetprivate.h"
-#include "gtkwindow.h"
+#include "gtkwindowprivate.h"
#include "gtkbindings.h"
#include "gtkprivate.h"
#include "gdk/gdk.h"
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b42f68dc87..0bdda2bc2f 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -25,6 +25,9 @@
*/
#include "config.h"
+
+#include "gtkintl.h"
+
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@@ -32,11 +35,10 @@
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
-#include "gtkintl.h"
-
#include "gtkprivate.h"
#include "gtkrc.h"
#include "gtkwindow.h"
+#include "gtkwindowprivate.h"
#include "gtkbindings.h"
#include "gtkkeyhash.h"
#include "gtkmain.h"
@@ -95,7 +97,6 @@
*/
typedef struct _GtkDeviceGrabInfo GtkDeviceGrabInfo;
-typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate;
struct _GtkWindowPrivate
{
@@ -297,7 +298,6 @@ struct _GtkWindowGeometryInfo
GtkWindowLastGeometryInfo last;
};
-#define GTK_WINDOW_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_WINDOW_GROUP, GtkWindowGroupPrivate))
struct _GtkDeviceGrabInfo
{
@@ -308,6 +308,7 @@ struct _GtkDeviceGrabInfo
struct _GtkWindowGroupPrivate
{
+ GSList *grabs;
GSList *device_grabs;
};
@@ -8461,37 +8462,20 @@ gtk_window_has_toplevel_focus (GtkWindow *window)
return window->priv->has_toplevel_focus;
}
+G_DEFINE_TYPE (GtkWindowGroup, gtk_window_group, G_TYPE_OBJECT)
+
static void
-gtk_window_group_class_init (GtkWindowGroupClass *klass)
+gtk_window_group_init (GtkWindowGroup *group)
{
- g_type_class_add_private (klass, sizeof (GtkWindowGroupPrivate));
+ group->priv = G_TYPE_INSTANCE_GET_PRIVATE (group,
+ GTK_TYPE_WINDOW_GROUP,
+ GtkWindowGroupPrivate);
}
-GType
-gtk_window_group_get_type (void)
+static void
+gtk_window_group_class_init (GtkWindowGroupClass *klass)
{
- static GType window_group_type = 0;
-
- if (!window_group_type)
- {
- const GTypeInfo window_group_info =
- {
- sizeof (GtkWindowGroupClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtk_window_group_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkWindowGroup),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
- };
-
- window_group_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkWindowGroup"),
- &window_group_info, 0);
- }
-
- return window_group_type;
+ g_type_class_add_private (klass, sizeof (GtkWindowGroupPrivate));
}
/**
@@ -8510,14 +8494,16 @@ gtk_window_group_new (void)
static void
window_group_cleanup_grabs (GtkWindowGroup *group,
- GtkWindow *window)
+ GtkWindow *window)
{
GtkWindowGroupPrivate *priv;
GtkDeviceGrabInfo *info;
GSList *tmp_list;
GSList *to_remove = NULL;
- tmp_list = group->grabs;
+ priv = group->priv;
+
+ tmp_list = priv->grabs;
while (tmp_list)
{
if (gtk_widget_get_toplevel (tmp_list->data) == (GtkWidget*) window)
@@ -8532,7 +8518,6 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
to_remove = g_slist_delete_link (to_remove, to_remove);
}
- priv = GTK_WINDOW_GROUP_GET_PRIVATE (group);
tmp_list = priv->device_grabs;
while (tmp_list)
@@ -8709,12 +8694,33 @@ gtk_window_group_get_current_grab (GtkWindowGroup *window_group)
{
g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL);
- if (window_group->grabs)
- return GTK_WIDGET (window_group->grabs->data);
+ if (window_group->priv->grabs)
+ return GTK_WIDGET (window_group->priv->grabs->data);
return NULL;
}
void
+_gtk_window_group_add_grab (GtkWindowGroup *window_group,
+ GtkWidget *widget)
+{
+ GtkWindowGroupPrivate *priv;
+
+ priv = window_group->priv;
+ priv->grabs = g_slist_prepend (priv->grabs, widget);
+}
+
+void
+_gtk_window_group_remove_grab (GtkWindowGroup *window_group,
+ GtkWidget *widget)
+{
+ GtkWindowGroupPrivate *priv;
+
+ priv = window_group->priv;
+ priv->grabs = g_slist_remove (priv->grabs, widget);
+}
+
+
+void
_gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device,
@@ -8723,7 +8729,7 @@ _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWindowGroupPrivate *priv;
GtkDeviceGrabInfo *info;
- priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
+ priv = window_group->priv;
info = g_slice_new0 (GtkDeviceGrabInfo);
info->widget = widget;
@@ -8743,7 +8749,7 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
GSList *list, *node = NULL;
GdkDevice *other_device;
- priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
+ priv = window_group->priv;
other_device = gdk_device_get_associated_device (device);
list = priv->device_grabs;
@@ -8794,7 +8800,7 @@ gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL);
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
- priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
+ priv = window_group->priv;
list = priv->device_grabs;
other_device = gdk_device_get_associated_device (device);
@@ -8821,7 +8827,7 @@ _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
GdkDevice *other_device;
GSList *list;
- priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
+ priv = window_group->priv;
other_device = gdk_device_get_associated_device (device);
list = priv->device_grabs;
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 57d1f81476..81a979a6da 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -53,6 +53,7 @@ typedef struct _GtkWindowClass GtkWindowClass;
typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo;
typedef struct _GtkWindowGroup GtkWindowGroup;
typedef struct _GtkWindowGroupClass GtkWindowGroupClass;
+typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate;
struct _GtkWindow
{
@@ -95,7 +96,7 @@ struct _GtkWindowGroup
{
GObject parent_instance;
- GSList *GSEAL (grabs);
+ GtkWindowGroupPrivate *priv;
};
struct _GtkWindowGroupClass
@@ -336,6 +337,7 @@ void gtk_window_group_remove_window (GtkWindowGroup *window_grou
GtkWindow *window);
GList * gtk_window_group_list_windows (GtkWindowGroup *window_group);
+GtkWidget * gtk_window_group_get_current_grab (GtkWindowGroup *window_group);
GtkWidget * gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
GdkDevice *device);
@@ -353,65 +355,6 @@ gboolean gtk_window_resize_grip_is_visible (GtkWindow *window);
gboolean gtk_window_get_resize_grip_area (GtkWindow *window,
GdkRectangle *rect);
-
-/* --- internal functions --- */
-void _gtk_window_internal_set_focus (GtkWindow *window,
- GtkWidget *focus);
-void gtk_window_remove_embedded_xid (GtkWindow *window,
- GdkNativeWindow xid);
-void gtk_window_add_embedded_xid (GtkWindow *window,
- GdkNativeWindow xid);
-void _gtk_window_reposition (GtkWindow *window,
- gint x,
- gint y);
-void _gtk_window_constrain_size (GtkWindow *window,
- gint width,
- gint height,
- gint *new_width,
- gint *new_height);
-GtkWidget *gtk_window_group_get_current_grab (GtkWindowGroup *window_group);
-void _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
- GtkWidget *widget,
- GdkDevice *device,
- gboolean block_others);
-void _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
- GtkWidget *widget,
- GdkDevice *device);
-
-gboolean _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
- GtkWidget *widget,
- GdkDevice *device);
-
-void _gtk_window_set_has_toplevel_focus (GtkWindow *window,
- gboolean has_toplevel_focus);
-void _gtk_window_unset_focus_and_default (GtkWindow *window,
- GtkWidget *widget);
-
-void _gtk_window_set_is_active (GtkWindow *window,
- gboolean is_active);
-
-void _gtk_window_set_is_toplevel (GtkWindow *window,
- gboolean is_toplevel);
-
-void _gtk_window_get_wmclass (GtkWindow *window,
- gchar **wmclass_name,
- gchar **wmclass_class);
-
-typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
- guint keyval,
- GdkModifierType modifiers,
- gboolean is_mnemonic,
- gpointer data);
-
-void _gtk_window_keys_foreach (GtkWindow *window,
- GtkWindowKeysForeachFunc func,
- gpointer func_data);
-
-/* --- internal (GtkAcceleratable) --- */
-gboolean _gtk_window_query_nonaccels (GtkWindow *window,
- guint accel_key,
- GdkModifierType accel_mods);
-
G_END_DECLS
#endif /* __GTK_WINDOW_H__ */
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
new file mode 100644
index 0000000000..18562e9a38
--- /dev/null
+++ b/gtk/gtkwindowprivate.h
@@ -0,0 +1,90 @@
+
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_WINDOW_PRIVATE_H__
+#define __GTK_WINDOW_PRIVATE_H__
+
+#include "gtkwindow.h"
+
+G_BEGIN_DECLS
+
+void _gtk_window_internal_set_focus (GtkWindow *window,
+ GtkWidget *focus);
+void gtk_window_remove_embedded_xid (GtkWindow *window,
+ GdkNativeWindow xid);
+void gtk_window_add_embedded_xid (GtkWindow *window,
+ GdkNativeWindow xid);
+void _gtk_window_reposition (GtkWindow *window,
+ gint x,
+ gint y);
+void _gtk_window_constrain_size (GtkWindow *window,
+ gint width,
+ gint height,
+ gint *new_width,
+ gint *new_height);
+void _gtk_window_group_add_grab (GtkWindowGroup *window_group,
+ GtkWidget *widget);
+void _gtk_window_group_remove_grab (GtkWindowGroup *window_group,
+ GtkWidget *widget);
+void _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
+ GtkWidget *widget,
+ GdkDevice *device,
+ gboolean block_others);
+void _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
+ GtkWidget *widget,
+ GdkDevice *device);
+
+gboolean _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
+ GtkWidget *widget,
+ GdkDevice *device);
+
+void _gtk_window_set_has_toplevel_focus (GtkWindow *window,
+ gboolean has_toplevel_focus);
+void _gtk_window_unset_focus_and_default (GtkWindow *window,
+ GtkWidget *widget);
+
+void _gtk_window_set_is_active (GtkWindow *window,
+ gboolean is_active);
+
+void _gtk_window_set_is_toplevel (GtkWindow *window,
+ gboolean is_toplevel);
+
+void _gtk_window_get_wmclass (GtkWindow *window,
+ gchar **wmclass_name,
+ gchar **wmclass_class);
+
+typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
+ guint keyval,
+ GdkModifierType modifiers,
+ gboolean is_mnemonic,
+ gpointer data);
+
+void _gtk_window_keys_foreach (GtkWindow *window,
+ GtkWindowKeysForeachFunc func,
+ gpointer func_data);
+
+/* --- internal (GtkAcceleratable) --- */
+gboolean _gtk_window_query_nonaccels (GtkWindow *window,
+ guint accel_key,
+ GdkModifierType accel_mods);
+
+G_END_DECLS
+
+#endif /* __GTK_WINDOW_PRIVATE_H__ */