API: Remove GtkPlug, GtkSocket and GtkWin32EmbedWidget

This commit is contained in:
Benjamin Otte 2016-10-03 18:30:40 +02:00
parent 89f2e17f91
commit 021fe010b6
33 changed files with 12 additions and 5267 deletions

View File

@ -157,7 +157,6 @@ IGNORE_HFILES = \
gtksidebarrowprivate.h \
gtksizegroup-private.h \
gtksizerequestcacheprivate.h \
gtksocketprivate.h \
gtkstyleanimationprivate.h \
gtkstylecascadeprivate.h \
gtkstylecontextprivate.h \
@ -233,7 +232,6 @@ IGNORE_HFILES = \
gtksearchenginesimple.h \
gtksearchenginequartz.h \
gtksequence.h \
gtksocketprivate.h \
gtktextbtree.h \
gtktextbufferserialize.h \
gtktextdisplay.h \
@ -248,9 +246,6 @@ IGNORE_HFILES = \
gtktreedatalist.h \
gtktreemenu.h \
gtktypebuiltins.h \
gtkxembed.h \
gtkwin32embed.h \
gtkwin32embedwidget.h \
gtkwindow-decorate.h \
xdgmime \
xembed.h

View File

@ -274,12 +274,6 @@
<xi:include href="xml/gtknativedialog.xml" />
</chapter>
<chapter id="PlugSocket">
<title>Cross-process Embedding</title>
<xi:include href="xml/gtkplug.xml" />
<xi:include href="xml/gtksocket.xml" />
</chapter>
<chapter id="RecentDocuments">
<title>Recently Used Documents</title>
<xi:include href="xml/gtkrecentmanager.xml" />

View File

@ -2677,29 +2677,6 @@ GTK_PLACES_SIDEBAR_GET_CLASS
gtk_places_sidebar_get_type
</SECTION>
<SECTION>
<FILE>gtkplug</FILE>
<TITLE>GtkPlug</TITLE>
GtkPlug
gtk_plug_construct
gtk_plug_construct_for_display
gtk_plug_new
gtk_plug_new_for_display
gtk_plug_get_id
gtk_plug_get_embedded
gtk_plug_get_socket_window
<SUBSECTION Standard>
GTK_PLUG
GTK_IS_PLUG
GTK_TYPE_PLUG
GTK_PLUG_CLASS
GTK_IS_PLUG_CLASS
GTK_PLUG_GET_CLASS
<SUBSECTION Private>
GtkPlugPrivate
gtk_plug_get_type
</SECTION>
<SECTION>
<FILE>gtkprogressbar</FILE>
<TITLE>GtkProgressBar</TITLE>
@ -3345,26 +3322,6 @@ GtkSizeGroupPrivate
gtk_size_group_get_type
</SECTION>
<SECTION>
<FILE>gtksocket</FILE>
<TITLE>GtkSocket</TITLE>
GtkSocket
gtk_socket_new
gtk_socket_add_id
gtk_socket_get_id
gtk_socket_get_plug_window
<SUBSECTION Standard>
GTK_SOCKET
GTK_IS_SOCKET
GTK_TYPE_SOCKET
GTK_SOCKET_CLASS
GTK_IS_SOCKET_CLASS
GTK_SOCKET_GET_CLASS
<SUBSECTION Private>
GtkSocketPrivate
gtk_socket_get_type
</SECTION>
<SECTION>
<FILE>gtkspinbutton</FILE>
<TITLE>GtkSpinButton</TITLE>

View File

@ -1,4 +1,3 @@
#include <gtk/gtkx.h>
#include <gtk/gtkunixprint.h>
gtk_about_dialog_get_type
@ -138,7 +137,6 @@ gtk_page_setup_get_type
gtk_paned_get_type
gtk_paper_size_get_type
gtk_places_sidebar_get_type
@ENABLE_ON_X11@gtk_plug_get_type
gtk_popover_get_type
gtk_popover_menu_get_type
@DISABLE_ON_W32@gtk_printer_get_type
@ -179,7 +177,6 @@ gtk_shortcuts_section_get_type
gtk_shortcuts_group_get_type
gtk_shortcuts_shortcut_get_type
gtk_size_group_get_type
@ENABLE_ON_X11@gtk_socket_get_type
gtk_spin_button_get_type
gtk_spinner_get_type
gtk_stack_get_type

View File

@ -31,13 +31,6 @@ see <link linkend="gdk-X-Window-System-Interaction">GDK X Window
System interaction</link> in the GDK manual.
</para>
<para>
GTK+ includes an cross-process embedding facility in the form of
the #GtkSocket and #GtkPlug widgets. These are X11-specific, and
you have to include the <filename>gtk/gtkx.h</filename> header
to use them.
</para>
<refsect2 id="x11-cmdline">
<title>X11-specific commandline options</title>

View File

@ -122,8 +122,6 @@ include $(srcdir)/inspector/Makefile.inc
gtk_public_h_sources = \
gtk.h \
gtk-autocleanups.h \
gtkx.h \
gtkx-autocleanups.h \
gtk-a11y.h \
gtkaboutdialog.h \
gtkaccelgroup.h \
@ -255,7 +253,6 @@ gtk_public_h_sources = \
gtkpaned.h \
gtkpapersize.h \
gtkplacessidebar.h \
gtkplug.h \
gtkpopover.h \
gtkpopovermenu.h \
gtkprintcontext.h \
@ -296,7 +293,6 @@ gtk_public_h_sources = \
gtkstacksidebar.h \
gtksizegroup.h \
gtksizerequest.h \
gtksocket.h \
gtkspinbutton.h \
gtkspinner.h \
gtkstack.h \
@ -555,7 +551,6 @@ gtk_private_h_sources = \
gtksidebarrowprivate.h \
gtksizegroup-private.h \
gtksizerequestcacheprivate.h \
gtksocketprivate.h \
gtkstyleanimationprivate.h \
gtkstylecascadeprivate.h \
gtkstylecontextprivate.h \
@ -1020,9 +1015,6 @@ gtk_c_sources += $(gtk_os_win32_c_sources)
endif
gtk_use_x11_c_sources = \
gtkplug.c \
gtksocket.c \
gtkxembed.c \
gtkapplication-x11.c \
gtkmountoperation-x11.c
@ -1033,8 +1025,6 @@ gtk_use_wayland_or_x11_c_sources = \
gtkapplication-dbus.c
gtk_use_win32_c_sources = \
gtkwin32embed.c \
gtkwin32embedwidget.c \
gtkmountoperation-stub.c
gtk_use_quartz_c_sources = \
gtksearchenginequartz.c \
@ -1044,12 +1034,8 @@ gtk_use_quartz_c_sources = \
gtkquartz.c
gtk_use_stub_c_sources = \
gtkmountoperation-stub.c
gtk_use_x11_private_h_sources = \
gtkxembed.h \
xembed.h
if USE_X11
gtk_c_sources += $(gtk_use_x11_c_sources)
gtk_private_h_sources += $(gtk_use_x11_private_h_sources)
endif
if USE_WAYLAND
@ -1066,12 +1052,8 @@ else
endif
endif
gtk_use_win32_private_h_sources = \
gtkwin32embed.h \
gtkwin32embedwidget.h
if USE_WIN32
gtk_c_sources += $(gtk_use_win32_c_sources)
gtk_private_h_sources += $(gtk_use_win32_private_h_sources)
endif
gtk_use_quartz_private_h_sources = \
@ -1087,8 +1069,6 @@ gtk_all_private_h_sources = \
$(a11y_private_h_sources) \
$(deprecated_private_h_sources) \
$(gtk_private_h_sources) \
$(gtk_use_x11_private_h_sources) \
$(gtk_use_win32_private_h_sources) \
$(gtk_use_quartz_private_h_sources)
if !USE_X11
@ -1380,12 +1360,12 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins.
gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_srcdir)/gtk/*.h $(top_srcdir)/gtk/a11y/*.h $(top_srcdir)/gtk/deprecated/*.h $(top_srcdir)/gdk/*.h Makefile
$(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include <gtk/gtkx.h>') > xgen-gtfsrc.c && \
$(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include <gtk/gtk.h>') > xgen-gtfsrc.c && \
echo 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS' > xgen-gtf && \
${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \
$(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \
sort | uniq | \
$(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \
$(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \
&& cp xgen-gtf $@ && rm -f xgen-gtf
gtktestutils.c: gtktypefuncs.c
@ -1527,7 +1507,7 @@ distclean-local:
fi
if HAVE_INTROSPECTION
introspected_pub_headers = $(filter-out %private.h gtktextdisplay.h gtktextlayout.h gtkx.h, $(gtkinclude_HEADERS) $(a11yinclude_HEADERS) $(deprecatedinclude_HEADERS))
introspected_pub_headers = $(filter-out %private.h gtktextdisplay.h gtktextlayout.h, $(gtkinclude_HEADERS) $(a11yinclude_HEADERS) $(deprecatedinclude_HEADERS))
introspection_files = \
$(introspected_pub_headers) \
@ -1536,12 +1516,6 @@ introspection_files = \
gtktypebuiltins.h \
gtktypebuiltins.c
if USE_X11
introspection_files += \
gtksocket.c \
gtkplug.c
endif
include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_SCANNER_ENV = CC="$(CC)"
INTROSPECTION_COMPILER_ARGS = \
@ -1686,9 +1660,6 @@ EXTRA_DIST += \
libgtk3.manifest.in \
gtk-win32.rc.body.in \
gtk-win32.rc.body \
gtkwin32embed.h \
gtkwin32embedwidget.h \
gtkwin32embedwidget.c \
gtkprint-win32.h \
gtkprint-win32.c \
gtksearchenginequartz.h \

View File

@ -33,7 +33,6 @@
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenubar.h>
#include <gtk/gtksocket.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkaccessible.h>
@ -254,17 +253,6 @@ gail_focus_watcher (GSignalInvocationHint *ihint,
}
}
#ifdef GDK_WINDOWING_X11
/*
* If the focus widget is a GtkSocket without a plug
* then ignore the focus notification as the embedded
* plug will report a focus notification.
*/
if (GTK_IS_SOCKET (widget) &&
gtk_socket_get_plug_window (GTK_SOCKET (widget)) != NULL)
return TRUE;
#endif
/*
* The widget may not yet be visible on the screen so we wait until it is.
*/

View File

@ -26,7 +26,6 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkplug.h>
#include <gtk/gtkwindow.h>
#include "gtktoplevelaccessible.h"
@ -208,9 +207,6 @@ show_event_watcher (GSignalInvocationHint *ihint,
widget = GTK_WIDGET (object);
if (gtk_widget_get_parent (widget) ||
is_attached_menu_window (widget) ||
#ifdef GDK_WINDOWING_X11
GTK_IS_PLUG (widget) ||
#endif
is_combo_window (widget))
return TRUE;
@ -270,9 +266,6 @@ gtk_toplevel_accessible_init (GtkToplevelAccessible *toplevel)
if (!window ||
!gtk_widget_get_visible (widget) ||
is_attached_menu_window (widget) ||
#ifdef GDK_WINDOWING_X11
GTK_IS_PLUG (window) ||
#endif
gtk_widget_get_parent (GTK_WIDGET (window)))
{
GList *temp_l = l->next;

View File

@ -54,7 +54,6 @@
#include "gtkimageprivate.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkplug.h"
#include "gtktooltipprivate.h"
#include "gtkwindow.h"
#include "gtkrender.h"
@ -1067,18 +1066,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
window = gtk_widget_get_window (toplevel);
#ifdef GDK_WINDOWING_X11
/* Hackaround for: http://bugzilla.gnome.org/show_bug.cgi?id=136112
*
* Currently gdk_window_get_position doesn't provide reliable
* information for embedded windows, so we call the much more
* expensive gdk_window_get_origin().
*/
if (GTK_IS_PLUG (toplevel))
gdk_window_get_origin (window, &tx, &ty);
else
#endif /* GDK_WINDOWING_X11 */
gdk_window_get_position (window, &tx, &ty);
gdk_window_get_position (window, &tx, &ty);
found = gtk_drag_find_widget (toplevel,
context,

File diff suppressed because it is too large Load Diff

View File

@ -1,103 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_PLUG_H__
#define __GTK_PLUG_H__
#if !defined (__GTKX_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtkx.h> can be included directly."
#endif
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <gtk/gtksocket.h>
#include <gtk/gtkwindow.h>
G_BEGIN_DECLS
#define GTK_TYPE_PLUG (gtk_plug_get_type ())
#define GTK_PLUG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PLUG, GtkPlug))
#define GTK_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PLUG, GtkPlugClass))
#define GTK_IS_PLUG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PLUG))
#define GTK_IS_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PLUG))
#define GTK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PLUG, GtkPlugClass))
typedef struct _GtkPlug GtkPlug;
typedef struct _GtkPlugPrivate GtkPlugPrivate;
typedef struct _GtkPlugClass GtkPlugClass;
struct _GtkPlug
{
GtkWindow window;
GtkPlugPrivate *priv;
};
struct _GtkPlugClass
{
GtkWindowClass parent_class;
void (*embedded) (GtkPlug *plug);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GDK_AVAILABLE_IN_ALL
GType gtk_plug_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
void gtk_plug_construct (GtkPlug *plug,
Window socket_id);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_plug_new (Window socket_id);
GDK_AVAILABLE_IN_ALL
void gtk_plug_construct_for_display (GtkPlug *plug,
GdkDisplay *display,
Window socket_id);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_plug_new_for_display (GdkDisplay *display,
Window socket_id);
GDK_AVAILABLE_IN_ALL
Window gtk_plug_get_id (GtkPlug *plug);
GDK_AVAILABLE_IN_ALL
gboolean gtk_plug_get_embedded (GtkPlug *plug);
GDK_AVAILABLE_IN_ALL
GdkWindow *gtk_plug_get_socket_window (GtkPlug *plug);
G_END_DECLS
#endif /* GDK_WINDOWING_X11 */
#endif /* __GTK_PLUG_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_SOCKET_H__
#define __GTK_SOCKET_H__
#if !defined (__GTKX_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtkx.h> can be included directly."
#endif
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <gtk/gtkcontainer.h>
G_BEGIN_DECLS
#define GTK_TYPE_SOCKET (gtk_socket_get_type ())
#define GTK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SOCKET, GtkSocket))
#define GTK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SOCKET, GtkSocketClass))
#define GTK_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SOCKET))
#define GTK_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SOCKET))
#define GTK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOCKET, GtkSocketClass))
typedef struct _GtkSocket GtkSocket;
typedef struct _GtkSocketClass GtkSocketClass;
typedef struct _GtkSocketPrivate GtkSocketPrivate;
struct _GtkSocket
{
GtkContainer container;
GtkSocketPrivate *priv;
};
struct _GtkSocketClass
{
GtkContainerClass parent_class;
void (*plug_added) (GtkSocket *socket_);
gboolean (*plug_removed) (GtkSocket *socket_);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GDK_AVAILABLE_IN_ALL
GType gtk_socket_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_socket_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_socket_add_id (GtkSocket *socket_,
Window window);
GDK_AVAILABLE_IN_ALL
Window gtk_socket_get_id (GtkSocket *socket_);
GDK_AVAILABLE_IN_ALL
GdkWindow *gtk_socket_get_plug_window (GtkSocket *socket_);
G_END_DECLS
#endif /* GDK_WINDOWING_X11 */
#endif /* __GTK_SOCKET_H__ */

View File

@ -1,61 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_SOCKET_PRIVATE_H__
#define __GTK_SOCKET_PRIVATE_H__
#include "gtkplug.h"
#include "gtksocket.h"
struct _GtkSocketPrivate
{
gint resize_count;
guint16 request_width;
guint16 request_height;
guint16 current_width;
guint16 current_height;
GdkWindow *plug_window;
GtkWidget *plug_widget;
gshort xembed_version; /* -1 == not xembed */
guint same_app : 1;
guint focus_in : 1;
guint have_size : 1;
guint need_map : 1;
guint is_mapped : 1;
guint active : 1;
GtkAccelGroup *accel_group;
GtkWidget *toplevel;
};
/* from gtkplug.c */
void _gtk_plug_add_to_socket (GtkPlug *plug,
GtkSocket *socket_);
void _gtk_plug_remove_from_socket (GtkPlug *plug,
GtkSocket *socket_);
#endif /* __GTK_SOCKET_PRIVATE_H__ */

View File

@ -37,7 +37,7 @@
* So....
*/
#undef GTK_COMPILATION
#include <gtk/gtkx.h>
#include <gtk/gtk.h>
#define GTK_COMPILATION
/**

View File

@ -63,7 +63,6 @@
#include "gtkmodifierstyle.h"
#include "gtkversion.h"
#include "gtkdebug.h"
#include "gtkplug.h"
#include "gtktypebuiltins.h"
#include "a11y/gtkwidgetaccessible.h"
#include "gtkapplicationprivate.h"
@ -9120,9 +9119,8 @@ gtk_widget_get_has_window (GtkWidget *widget)
*
* Determines whether @widget is a toplevel widget.
*
* Currently only #GtkWindow and #GtkInvisible (and out-of-process
* #GtkPlugs) are toplevel widgets. Toplevel widgets have no parent
* widget.
* Currently only #GtkWindow and #GtkInvisible are toplevel widgets.
* Toplevel widgets have no parent widget.
*
* Returns: %TRUE if @widget is a toplevel, %FALSE otherwise
*
@ -10617,8 +10615,6 @@ gtk_widget_set_parent_window (GtkWidget *widget,
if (parent_window != old_parent_window)
{
gboolean is_plug;
g_object_set_qdata (G_OBJECT (widget), quark_parent_window,
parent_window);
if (old_parent_window)
@ -10630,12 +10626,7 @@ gtk_widget_set_parent_window (GtkWidget *widget,
* this is the primary entry point to allow toplevels to be
* embeddable.
*/
#ifdef GDK_WINDOWING_X11
is_plug = GTK_IS_PLUG (widget);
#else
is_plug = FALSE;
#endif
if (GTK_IS_WINDOW (widget) && !is_plug)
if (GTK_IS_WINDOW (widget))
_gtk_window_set_is_toplevel (GTK_WINDOW (widget), parent_window == NULL);
}
}
@ -11462,9 +11453,7 @@ gtk_widget_add_device_events (GtkWidget *widget,
* would return
* %NULL if @widget wasnt inside a toplevel window, and if the
* window was inside a #GtkWindow-derived widget which was in turn
* inside the toplevel #GtkWindow. While the second case may
* seem unlikely, it actually happens when a #GtkPlug is embedded
* inside a #GtkSocket within the same application.
* inside the toplevel #GtkWindow.
*
* To reliably find the toplevel #GtkWindow, use
* gtk_widget_get_toplevel() and call gtk_widget_is_toplevel()

View File

@ -1,131 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkwin32embed.c: Utilities for Win32 embedding
* Copyright (C) 2005, Novell, 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, see <http://www.gnu.org/licenses/>.
*/
/* By Tor Lillqvist <tml@novell.com> 2005 */
#include "config.h"
#include "win32/gdkwin32.h"
#include "gtkwin32embed.h"
static guint message_type[GTK_WIN32_EMBED_LAST];
static GSList *current_messages;
guint
_gtk_win32_embed_message_type (GtkWin32EmbedMessageType type)
{
if (type < 0 || type >= GTK_WIN32_EMBED_LAST)
return 0;
if (message_type[type] == 0)
{
char name[100];
sprintf (name, "gtk-win32-embed:%d", type);
message_type[type] = RegisterWindowMessage (name);
}
return message_type[type];
}
void
_gtk_win32_embed_push_message (MSG *msg)
{
MSG *message = g_new (MSG, 1);
*message = *msg;
current_messages = g_slist_prepend (current_messages, message);
}
void
_gtk_win32_embed_pop_message (void)
{
MSG *message = current_messages->data;
current_messages = g_slist_delete_link (current_messages, current_messages);
g_free (message);
}
void
_gtk_win32_embed_send (GdkWindow *recipient,
GtkWin32EmbedMessageType message,
WPARAM wparam,
LPARAM lparam)
{
PostMessage (GDK_WINDOW_HWND (recipient),
_gtk_win32_embed_message_type (message),
wparam, lparam);
}
void
_gtk_win32_embed_send_focus_message (GdkWindow *recipient,
GtkWin32EmbedMessageType message,
WPARAM wparam)
{
int lparam = 0;
if (!recipient)
return;
g_return_if_fail (GDK_IS_WINDOW (recipient));
g_return_if_fail (message == GTK_WIN32_EMBED_FOCUS_IN ||
message == GTK_WIN32_EMBED_FOCUS_NEXT ||
message == GTK_WIN32_EMBED_FOCUS_PREV);
if (current_messages)
{
MSG *msg = current_messages->data;
if (msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_IN) ||
msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_NEXT) ||
msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_PREV))
lparam = (msg->lParam & GTK_WIN32_EMBED_FOCUS_WRAPAROUND);
}
_gtk_win32_embed_send (recipient, message, wparam, lparam);
}
void
_gtk_win32_embed_set_focus_wrapped (void)
{
MSG *msg;
g_return_if_fail (current_messages != NULL);
msg = current_messages->data;
g_return_if_fail (msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_PREV) ||
msg->message == _gtk_win32_embed_message_type (GTK_WIN32_EMBED_FOCUS_NEXT));
msg->lParam |= GTK_WIN32_EMBED_FOCUS_WRAPAROUND;
}
gboolean
_gtk_win32_embed_get_focus_wrapped (void)
{
MSG *msg;
g_return_val_if_fail (current_messages != NULL, FALSE);
msg = current_messages->data;
return (msg->lParam & GTK_WIN32_EMBED_FOCUS_WRAPAROUND) != 0;
}

View File

@ -1,93 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkwin32embed.h: Utilities for Win32 embedding
* Copyright (C) 2005, Novell, 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, see <http://www.gnu.org/licenses/>.
*/
/* By Tor Lillqvist <tml@novell.com> 2005 */
#ifndef __GTK_WIN32_EMBED_H__
#define __GTK_WIN32_EMBED_H__
G_BEGIN_DECLS
#define GTK_WIN32_EMBED_PROTOCOL_VERSION 1
/*
* When the plug and socket are in separate processes they use a
* simple protocol, more or less based on XEMBED. The protocol uses
* registered window messages. The name passed to
* RegisterWindowMessage() is gtk-win32-embed:%d, with %d being the
* numeric value of an GtkWin32EmbedMessageType enum. Each message
* carries the message type enum value and two integers, the wparam
* and lparam, like all window messages.
*
* So far all the window messages are posted to the other
* process. Maybe some later enhancement will add also messages that
* are sent, i.e. where the sending process waits for the receiving
* processs window procedure to handle the message.
*/
typedef enum { /* send or post? */
/* First those sent from the socket
* to the plug
*/
GTK_WIN32_EMBED_WINDOW_ACTIVATE, /* post */
GTK_WIN32_EMBED_WINDOW_DEACTIVATE, /* post */
GTK_WIN32_EMBED_FOCUS_IN, /* post */
GTK_WIN32_EMBED_FOCUS_OUT, /* post */
GTK_WIN32_EMBED_MODALITY_ON, /* post */
GTK_WIN32_EMBED_MODALITY_OFF, /* post */
/* Then the ones sent from the plug
* to the socket.
*/
GTK_WIN32_EMBED_PARENT_NOTIFY, /* post */
GTK_WIN32_EMBED_EVENT_PLUG_MAPPED, /* post */
GTK_WIN32_EMBED_PLUG_RESIZED, /* post */
GTK_WIN32_EMBED_REQUEST_FOCUS, /* post */
GTK_WIN32_EMBED_FOCUS_NEXT, /* post */
GTK_WIN32_EMBED_FOCUS_PREV, /* post */
GTK_WIN32_EMBED_GRAB_KEY, /* post */
GTK_WIN32_EMBED_UNGRAB_KEY, /* post */
GTK_WIN32_EMBED_LAST
} GtkWin32EmbedMessageType;
/* wParam values for GTK_WIN32_EMBED_FOCUS_IN: */
#define GTK_WIN32_EMBED_FOCUS_CURRENT 0
#define GTK_WIN32_EMBED_FOCUS_FIRST 1
#define GTK_WIN32_EMBED_FOCUS_LAST 2
/* Flags for lParam in GTK_WIN32_EMBED_FOCUS_IN, GTK_WIN32_EMBED_FOCUS_NEXT,
* GTK_WIN32_EMBED_FOCUS_PREV
*/
#define GTK_WIN32_EMBED_FOCUS_WRAPAROUND (1 << 0)
guint _gtk_win32_embed_message_type (GtkWin32EmbedMessageType type);
void _gtk_win32_embed_push_message (MSG *msg);
void _gtk_win32_embed_pop_message (void);
void _gtk_win32_embed_send (GdkWindow *recipient,
GtkWin32EmbedMessageType message,
WPARAM wparam,
LPARAM lparam);
void _gtk_win32_embed_send_focus_message (GdkWindow *recipient,
GtkWin32EmbedMessageType message,
WPARAM wparam);
void _gtk_win32_embed_set_focus_wrapped (void);
gboolean _gtk_win32_embed_get_focus_wrapped (void);
G_END_DECLS
#endif /* __GTK_WIN32_EMBED_H__ */

View File

@ -1,385 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.Free
*/
/*
* Modified by the GTK+ Team and others 1997-2006. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtksizerequest.h"
#include "gtkwin32embedwidget.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkwindowprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcontainerprivate.h"
static void gtk_win32_embed_widget_realize (GtkWidget *widget);
static void gtk_win32_embed_widget_unrealize (GtkWidget *widget);
static void gtk_win32_embed_widget_show (GtkWidget *widget);
static void gtk_win32_embed_widget_hide (GtkWidget *widget);
static void gtk_win32_embed_widget_map (GtkWidget *widget);
static void gtk_win32_embed_widget_unmap (GtkWidget *widget);
static void gtk_win32_embed_widget_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_win32_embed_widget_set_focus (GtkWindow *window,
GtkWidget *focus);
static gboolean gtk_win32_embed_widget_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_win32_embed_widget_check_resize (GtkContainer *container);
static GtkBinClass *bin_class = NULL;
G_DEFINE_TYPE (GtkWin32EmbedWidget, gtk_win32_embed_widget, GTK_TYPE_WINDOW)
static void
gtk_win32_embed_widget_class_init (GtkWin32EmbedWidgetClass *class)
{
GtkWidgetClass *widget_class = (GtkWidgetClass *)class;
GtkWindowClass *window_class = (GtkWindowClass *)class;
GtkContainerClass *container_class = (GtkContainerClass *)class;
bin_class = g_type_class_peek (GTK_TYPE_BIN);
widget_class->realize = gtk_win32_embed_widget_realize;
widget_class->unrealize = gtk_win32_embed_widget_unrealize;
widget_class->show = gtk_win32_embed_widget_show;
widget_class->hide = gtk_win32_embed_widget_hide;
widget_class->map = gtk_win32_embed_widget_map;
widget_class->unmap = gtk_win32_embed_widget_unmap;
widget_class->size_allocate = gtk_win32_embed_widget_size_allocate;
widget_class->focus = gtk_win32_embed_widget_focus;
container_class->check_resize = gtk_win32_embed_widget_check_resize;
window_class->set_focus = gtk_win32_embed_widget_set_focus;
}
static void
gtk_win32_embed_widget_init (GtkWin32EmbedWidget *embed_widget)
{
_gtk_widget_set_is_toplevel (GTK_WIDGET (embed_widget), TRUE);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_container_set_resize_mode (GTK_CONTAINER (embed_widget), GTK_RESIZE_QUEUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
GtkWidget*
_gtk_win32_embed_widget_new (HWND parent)
{
GtkWin32EmbedWidget *embed_widget;
embed_widget = g_object_new (GTK_TYPE_WIN32_EMBED_WIDGET, NULL);
embed_widget->parent_window =
gdk_win32_window_lookup_for_display (gdk_display_get_default (),
parent);
if (!embed_widget->parent_window)
embed_widget->parent_window =
gdk_win32_window_foreign_new_for_display (gdk_display_get_default (),
parent);
return GTK_WIDGET (embed_widget);
}
BOOL
_gtk_win32_embed_widget_dialog_procedure (GtkWin32EmbedWidget *embed_widget,
HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
{
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (embed_widget);
if (message == WM_SIZE)
{
allocation.width = LOWORD(lparam);
allocation.height = HIWORD(lparam);
gtk_widget_set_allocation (widget, &allocation);
gtk_widget_queue_resize (widget);
}
return 0;
}
static void
gtk_win32_embed_widget_unrealize (GtkWidget *widget)
{
GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget);
embed_widget->old_window_procedure = NULL;
g_clear_object (&embed_widget->parent_window);
GTK_WIDGET_CLASS (gtk_win32_embed_widget_parent_class)->unrealize (widget);
}
static LRESULT CALLBACK
gtk_win32_embed_widget_window_process (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
GdkWindow *window;
GtkWin32EmbedWidget *embed_widget;
gpointer user_data;
window = gdk_win32_window_lookup_for_display (gdk_display_get_default (), hwnd);
if (window == NULL) {
g_warning ("No such window!");
return 0;
}
gdk_window_get_user_data (window, &user_data);
embed_widget = GTK_WIN32_EMBED_WIDGET (user_data);
if (msg == WM_GETDLGCODE) {
return DLGC_WANTALLKEYS;
}
if (embed_widget && embed_widget->old_window_procedure)
return CallWindowProc(embed_widget->old_window_procedure,
hwnd, msg, wparam, lparam);
else
return 0;
}
static void
gtk_win32_embed_widget_realize (GtkWidget *widget)
{
GtkWindow *window = GTK_WINDOW (widget);
GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget);
GtkAllocation allocation;
GdkWindow *gdk_window;
GdkWindowAttr attributes;
gint attributes_mask;
LONG_PTR styles;
gtk_widget_get_allocation (widget, &allocation);
/* ensure widget tree is properly size allocated */
if (allocation.x == -1 && allocation.y == -1 &&
allocation.width == 1 && allocation.height == 1)
{
GtkRequisition requisition;
GtkAllocation allocation = { 0, 0, 200, 200 };
gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (requisition.width || requisition.height)
{
/* non-empty window */
allocation.width = requisition.width;
allocation.height = requisition.height;
}
gtk_widget_size_allocate (widget, &allocation);
gtk_widget_queue_resize (widget);
g_return_if_fail (!gtk_widget_get_realized (widget));
}
gtk_widget_set_realized (widget, TRUE);
gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.title = (gchar *) gtk_window_get_title (window);
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
/* this isn't right - we should match our parent's visual/colormap.
* though that will require handling "foreign" colormaps */
attributes.visual = gtk_widget_get_visual (widget);
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_STRUCTURE_MASK |
GDK_FOCUS_CHANGE_MASK);
attributes_mask = GDK_WA_VISUAL;
attributes_mask |= (attributes.title ? GDK_WA_TITLE : 0);
gdk_window = gdk_window_new (embed_widget->parent_window,
&attributes, attributes_mask);
gtk_widget_set_window (widget, gdk_window);
gtk_widget_register_window (widget, gdk_window);
embed_widget->old_window_procedure = (gpointer)
SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window),
GWLP_WNDPROC,
(LONG_PTR)gtk_win32_embed_widget_window_process);
/* Enable tab to focus the widget */
styles = GetWindowLongPtr(GDK_WINDOW_HWND (gdk_window), GWL_STYLE);
SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window), GWL_STYLE, styles | WS_TABSTOP);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_set_background (gtk_widget_get_style_context (widget),
gdk_window);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static void
gtk_win32_embed_widget_show (GtkWidget *widget)
{
_gtk_widget_set_visible_flag (widget, TRUE);
gtk_widget_realize (widget);
gtk_container_check_resize (GTK_CONTAINER (widget));
gtk_widget_map (widget);
}
static void
gtk_win32_embed_widget_hide (GtkWidget *widget)
{
_gtk_widget_set_visible_flag (widget, FALSE);
gtk_widget_unmap (widget);
}
static void
gtk_win32_embed_widget_map (GtkWidget *widget)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
gtk_widget_set_mapped (widget, TRUE);
child = gtk_bin_get_child (bin);
if (child &&
gtk_widget_get_visible (child) &&
!gtk_widget_get_mapped (child))
gtk_widget_map (child);
gdk_window_show (gtk_widget_get_window (widget));
}
static void
gtk_win32_embed_widget_unmap (GtkWidget *widget)
{
gtk_widget_set_mapped (widget, FALSE);
gdk_window_hide (gtk_widget_get_window (widget));
}
static void
gtk_win32_embed_widget_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
GtkAllocation child_allocation;
child_allocation.x = gtk_container_get_border_width (GTK_CONTAINER (widget));
child_allocation.y = child_allocation.x;
child_allocation.width =
MAX (1, (gint)allocation->width - child_allocation.x * 2);
child_allocation.height =
MAX (1, (gint)allocation->height - child_allocation.y * 2);
gtk_widget_size_allocate (child, &child_allocation);
}
}
static void
gtk_win32_embed_widget_check_resize (GtkContainer *container)
{
GTK_CONTAINER_CLASS (bin_class)->check_resize (container);
}
static gboolean
gtk_win32_embed_widget_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkBin *bin = GTK_BIN (widget);
GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget);
GtkWindow *window = GTK_WINDOW (widget);
GtkContainer *container = GTK_CONTAINER (widget);
GtkWidget *old_focus_child = gtk_container_get_focus_child (container);
GtkWidget *parent;
GtkWidget *child;
/* We override GtkWindow's behavior, since we don't want wrapping here.
*/
if (old_focus_child)
{
if (gtk_widget_child_focus (old_focus_child, direction))
return TRUE;
if (gtk_window_get_focus (window))
{
/* Wrapped off the end, clear the focus setting for the toplevel */
parent = gtk_widget_get_parent (gtk_window_get_focus (window));
while (parent)
{
gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
parent = gtk_widget_get_parent (GTK_WIDGET (parent));
}
gtk_window_set_focus (GTK_WINDOW (container), NULL);
}
}
else
{
/* Try to focus the first widget in the window */
child = gtk_bin_get_child (bin);
if (child && gtk_widget_child_focus (child, direction))
return TRUE;
}
if (!gtk_container_get_focus_child (GTK_CONTAINER (window)))
{
int backwards = FALSE;
if (direction == GTK_DIR_TAB_BACKWARD ||
direction == GTK_DIR_LEFT)
backwards = TRUE;
PostMessage(GDK_WINDOW_HWND (embed_widget->parent_window),
WM_NEXTDLGCTL,
backwards, 0);
}
return FALSE;
}
static void
gtk_win32_embed_widget_set_focus (GtkWindow *window,
GtkWidget *focus)
{
GTK_WINDOW_CLASS (gtk_win32_embed_widget_parent_class)->set_focus (window, focus);
gdk_window_focus (gtk_widget_get_window (GTK_WIDGET(window)), 0);
}

View File

@ -1,75 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2006. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_WIN32_EMBED_WIDGET_H__
#define __GTK_WIN32_EMBED_WIDGET_H__
#include <gtk/gtkwindow.h>
#include "win32/gdkwin32.h"
G_BEGIN_DECLS
#define GTK_TYPE_WIN32_EMBED_WIDGET (gtk_win32_embed_widget_get_type ())
#define GTK_WIN32_EMBED_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WIN32_EMBED_WIDGET, GtkWin32EmbedWidget))
#define GTK_WIN32_EMBED_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIN32_EMBED_WIDGET, GtkWin32EmbedWidgetClass))
#define GTK_IS_WIN32_EMBED_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WIN32_EMBED_WIDGET))
#define GTK_IS_WIN32_EMBED_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIN32_EMBED_WIDGET))
#define GTK_WIN32_EMBED_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIN32_EMBED_WIDGET, GtkWin32EmbedWidgetClass))
typedef struct _GtkWin32EmbedWidget GtkWin32EmbedWidget;
typedef struct _GtkWin32EmbedWidgetClass GtkWin32EmbedWidgetClass;
struct _GtkWin32EmbedWidget
{
GtkWindow window;
GdkWindow *parent_window;
gpointer old_window_procedure;
};
struct _GtkWin32EmbedWidgetClass
{
GtkWindowClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_win32_embed_widget_get_type (void) G_GNUC_CONST;
GtkWidget* _gtk_win32_embed_widget_new (HWND parent);
BOOL _gtk_win32_embed_widget_dialog_procedure (GtkWin32EmbedWidget *embed_widget,
HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
G_END_DECLS
#endif /* __GTK_WIN32_EMBED_WIDGET_H__ */

View File

@ -46,7 +46,6 @@
#include "gtkmenushellprivate.h"
#include "gtkicontheme.h"
#include "gtkmarshalers.h"
#include "gtkplug.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkwidgetprivate.h"
@ -1712,17 +1711,10 @@ gtk_window_constructed (GObject *object)
{
GtkWindow *window = GTK_WINDOW (object);
GtkWindowPrivate *priv = window->priv;
gboolean is_plug;
G_OBJECT_CLASS (gtk_window_parent_class)->constructed (object);
#ifdef GDK_WINDOWING_X11
is_plug = GTK_IS_PLUG (window);
#else
is_plug = FALSE;
#endif
if (priv->type == GTK_WINDOW_TOPLEVEL && !is_plug)
if (priv->type == GTK_WINDOW_TOPLEVEL)
{
priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (object));
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), 0);
@ -5977,7 +5969,6 @@ gtk_window_show (GtkWidget *widget)
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
GtkContainer *container = GTK_CONTAINER (window);
gboolean is_plug;
if (!_gtk_widget_is_toplevel (GTK_WIDGET (widget)))
{
@ -5995,15 +5986,7 @@ gtk_window_show (GtkWidget *widget)
gtk_widget_map (widget);
/* Try to make sure that we have some focused widget
*/
#ifdef GDK_WINDOWING_X11
is_plug = GDK_IS_X11_WINDOW (_gtk_widget_get_window (widget)) &&
GTK_IS_PLUG (window);
#else
is_plug = FALSE;
#endif
if (!priv->focus_widget && !is_plug)
if (!priv->focus_widget)
{
if (priv->initial_focus)
gtk_window_set_focus (window, priv->initial_focus);
@ -10768,8 +10751,7 @@ _gtk_window_get_screen (GtkWindow *window)
*
* Returns whether the window is part of the current active toplevel.
* (That is, the toplevel window receiving keystrokes.)
* The return value is %TRUE if the window is active toplevel
* itself, but also if it is, say, a #GtkPlug embedded in the active toplevel.
* The return value is %TRUE if the window is active toplevel itself.
* You might use this function if you wanted to draw a widget
* differently in an active window from a widget in an inactive window.
* See gtk_window_has_toplevel_focus()

View File

@ -1,31 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#if !defined (__GTKX_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtkx.h> can be included directly."
#endif
#ifdef GDK_WINDOWING_X11
#ifndef __GI_SCANNER__
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSocket, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPlug, g_object_unref)
#endif
#endif

View File

@ -1,36 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_X_H__
#define __GTK_X_H__
#if defined (GTK_COMPILATION)
#error "<gtk/gtkx.h> must not be included by GTK+ headers."
#endif
#define __GTKX_H_INSIDE__
#include <gtk/gtk.h>
#include <gtk/gtksocket.h>
#include <gtk/gtkplug.h>
#include <gtk/gtkx-autocleanups.h>
#undef __GTKX_H_INSIDE__
#endif /* __GTK_X_H__ */

View File

@ -1,242 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkxembed.c: Utilities for the XEMBED protocol
* Copyright (C) 2001, 2003, 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkxembed.h"
#include "gtkdebug.h"
typedef struct _GtkXEmbedMessage GtkXEmbedMessage;
struct _GtkXEmbedMessage
{
glong message;
glong detail;
glong data1;
glong data2;
guint32 time;
};
static GSList *current_messages;
/**
* _gtk_xembed_push_message:
* @xevent: a XEvent
*
* Adds a client message to the stack of current XEMBED events.
**/
void
_gtk_xembed_push_message (XEvent *xevent)
{
GtkXEmbedMessage *message = g_slice_new (GtkXEmbedMessage);
message->time = xevent->xclient.data.l[0];
message->message = xevent->xclient.data.l[1];
message->detail = xevent->xclient.data.l[2];
message->data1 = xevent->xclient.data.l[3];
message->data2 = xevent->xclient.data.l[4];
current_messages = g_slist_prepend (current_messages, message);
}
/**
* _gtk_xembed_pop_message:
*
* Removes an event added with _gtk_xembed_push_message()
**/
void
_gtk_xembed_pop_message (void)
{
GtkXEmbedMessage *message = current_messages->data;
current_messages = g_slist_delete_link (current_messages, current_messages);
g_slice_free (GtkXEmbedMessage, message);
}
/**
* _gtk_xembed_set_focus_wrapped:
*
* Sets a flag indicating that the current focus sequence wrapped
* around to the beginning of the ultimate toplevel.
**/
void
_gtk_xembed_set_focus_wrapped (void)
{
GtkXEmbedMessage *message;
g_return_if_fail (current_messages != NULL);
message = current_messages->data;
g_return_if_fail (message->message == XEMBED_FOCUS_PREV || message->message == XEMBED_FOCUS_NEXT);
message->data1 |= XEMBED_FOCUS_WRAPAROUND;
}
/**
* _gtk_xembed_get_focus_wrapped:
*
* Gets whether the current focus sequence has wrapped around
* to the beginning of the ultimate toplevel.
*
* Returns: %TRUE if the focus sequence has wrapped around.
**/
gboolean
_gtk_xembed_get_focus_wrapped (void)
{
GtkXEmbedMessage *message;
g_return_val_if_fail (current_messages != NULL, FALSE);
message = current_messages->data;
return (message->data1 & XEMBED_FOCUS_WRAPAROUND) != 0;
}
static guint32
gtk_xembed_get_time (void)
{
if (current_messages)
{
GtkXEmbedMessage *message = current_messages->data;
return message->time;
}
else
return gtk_get_current_event_time ();
}
/**
* _gtk_xembed_send_message:
* @recipient: (allow-none): window to which to send the window, or %NULL
* in which case nothing will be sent
* @message: type of message
* @detail: detail field of message
* @data1: data1 field of message
* @data2: data2 field of message
*
* Sends a generic XEMBED message to a particular window.
**/
void
_gtk_xembed_send_message (GdkWindow *recipient,
XEmbedMessageType message,
glong detail,
glong data1,
glong data2)
{
GdkDisplay *display;
XClientMessageEvent xclient;
if (!recipient)
return;
g_return_if_fail (GDK_IS_WINDOW (recipient));
display = gdk_window_get_display (recipient);
GTK_NOTE (PLUGSOCKET,
g_message ("Sending %s", _gtk_xembed_message_name (message)));
memset (&xclient, 0, sizeof (xclient));
xclient.window = GDK_WINDOW_XID (recipient);
xclient.type = ClientMessage;
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED");
xclient.format = 32;
xclient.data.l[0] = gtk_xembed_get_time ();
xclient.data.l[1] = message;
xclient.data.l[2] = detail;
xclient.data.l[3] = data1;
xclient.data.l[4] = data2;
gdk_error_trap_push ();
XSendEvent (GDK_WINDOW_XDISPLAY(recipient),
GDK_WINDOW_XID (recipient),
False, NoEventMask, (XEvent *)&xclient);
gdk_error_trap_pop_ignored ();
}
/**
* _gtk_xembed_send_focus_message:
* @recipient: (allow-none): window to which to send the window, or %NULL
* in which case nothing will be sent
* @message_type: type of message
* @detail: detail field of message
*
* Sends a XEMBED message for moving the focus along the focus
* chain to a window. The flags field that these messages share
* will be correctly filled in.
**/
void
_gtk_xembed_send_focus_message (GdkWindow *recipient,
XEmbedMessageType message_type,
glong detail)
{
gulong flags = 0;
if (!recipient)
return;
g_return_if_fail (GDK_IS_WINDOW (recipient));
g_return_if_fail (message_type == XEMBED_FOCUS_IN ||
message_type == XEMBED_FOCUS_NEXT ||
message_type == XEMBED_FOCUS_PREV);
if (current_messages)
{
GtkXEmbedMessage *message = current_messages->data;
switch (message->message)
{
case XEMBED_FOCUS_IN:
case XEMBED_FOCUS_NEXT:
case XEMBED_FOCUS_PREV:
flags = message->data1 & XEMBED_FOCUS_WRAPAROUND;
break;
default:
break;
}
}
_gtk_xembed_send_message (recipient, message_type, detail, flags, 0);
}
const char *
_gtk_xembed_message_name (XEmbedMessageType message)
{
static char unk[24];
switch (message)
{
#define CASE(x) case XEMBED_##x: return "XEMBED_"#x
CASE (EMBEDDED_NOTIFY);
CASE (WINDOW_ACTIVATE);
CASE (WINDOW_DEACTIVATE);
CASE (REQUEST_FOCUS);
CASE (FOCUS_IN);
CASE (FOCUS_OUT);
CASE (FOCUS_NEXT);
CASE (FOCUS_PREV);
CASE (GRAB_KEY);
CASE (UNGRAB_KEY);
CASE (MODALITY_ON);
CASE (MODALITY_OFF);
CASE (GTK_GRAB_KEY);
CASE (GTK_UNGRAB_KEY);
#undef CASE
default:
snprintf (unk, 24, "UNKNOWN(%d)", message);
return unk;
}
}

View File

@ -1,47 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkxembed.c: Utilities for the XEMBED protocol
* Copyright (C) 2003, 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_XEMBED_H__
#define __GTK_XEMBED_H__
#include "xembed.h"
#include "x11/gdkx.h"
G_BEGIN_DECLS
/* Latest version we implement */
#define GTK_XEMBED_PROTOCOL_VERSION 1
void _gtk_xembed_send_message (GdkWindow *recipient,
XEmbedMessageType message,
glong detail,
glong data1,
glong data2);
void _gtk_xembed_send_focus_message (GdkWindow *recipient,
XEmbedMessageType message,
glong detail);
void _gtk_xembed_push_message (XEvent *xevent);
void _gtk_xembed_pop_message (void);
void _gtk_xembed_set_focus_wrapped (void);
gboolean _gtk_xembed_get_focus_wrapped (void);
const char *_gtk_xembed_message_name (XEmbedMessageType message);
G_END_DECLS
#endif /* __GTK_XEMBED_H__ */

View File

@ -445,7 +445,6 @@ gtk_public_h_sources = \
gtkpagesetup.h \
gtkpaned.h \
gtkpapersize.h \
gtkplug.h \
gtkprintcontext.h \
gtkprintoperation.h \
gtkprintoperationpreview.h \
@ -478,7 +477,6 @@ gtk_public_h_sources = \
gtkstacksidebar.h \
gtksizegroup.h \
gtksizerequest.h \
gtksocket.h \
gtkspinbutton.h \
gtkspinner.h \
gtkstatusbar.h \

View File

@ -216,7 +216,6 @@ gtk/gtkpathbar.c
gtk/gtkplacessidebar.c
gtk/gtkplacesview.c
gtk/gtkplacesviewrow.c
gtk/gtkplug.c
gtk/gtkpopover.c
gtk/gtkpopovermenu.c
gtk/gtkprintbackend.c
@ -259,7 +258,6 @@ gtk/gtkshortcutssection.c
gtk/gtkshortcutsshortcut.c
gtk/gtkshortcutswindow.c
gtk/gtksizegroup.c
gtk/gtksocket.c
gtk/gtkspinbutton.c
gtk/gtkspinner.c
gtk/gtkstack.c

View File

@ -217,7 +217,6 @@ gtk/gtkpathbar.c
gtk/gtkplacessidebar.c
gtk/gtkplacesview.c
gtk/gtkplacesviewrow.c
gtk/gtkplug.c
gtk/gtkpopover.c
gtk/gtkpopovermenu.c
gtk/gtkprintbackend.c
@ -261,7 +260,6 @@ gtk/gtkshortcutsshortcut.c
gtk/gtkshortcutswindow.c
gtk/gtksizegroup.c
gtk/gtksizerequest.c
gtk/gtksocket.c
gtk/gtkspinbutton.c
gtk/gtkspinner.c
gtk/gtkstack.c

View File

@ -22,10 +22,6 @@ LDADD = \
-lm
if USE_X11
testsocket_programs = testsocket testsocket_child
endif
if OS_LINUX
fontconfig_programs = testfontchooserdialog
endif
@ -113,7 +109,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testscale \
testselection \
testselectionmode \
$(testsocket_programs) \
testspinbutton \
teststockbuttonmenu \
testtoolbar \
@ -246,8 +241,6 @@ testrecentchoosermenu_DEPENDENCIES = $(TEST_DEPS)
testrichtext_DEPENDENCIES = $(TEST_DEPS)
testscale_DEPENDENCIES = $(TEST_DEPS)
testselection_DEPENDENCIES = $(TEST_DEPS)
testsocket_DEPENDENCIES = $(DEPS)
testsocket_child_DEPENDENCIES = $(DEPS)
testspinbutton_DEPENDENCIES = $(TEST_DEPS)
teststockbuttonmenu_DEPENDENCIES = $(TEST_DEPS)
testtreechanging_DEPENDENCIES = $(DEPS)
@ -391,14 +384,6 @@ testprint_SOURCES = \
testprintfileoperation.h \
testprintfileoperation.c
testsocket_SOURCES = \
testsocket.c \
testsocket_common.c
testsocket_child_SOURCES = \
testsocket_child.c \
testsocket_common.c
testspinbutton_SOURCES = \
testspinbutton.c

View File

@ -1,404 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
/* testsocket.c
* Copyright (C) 2001 Red Hat, Inc
* Author: Owen Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int n_children = 0;
GSList *sockets = NULL;
GtkWidget *window;
GtkWidget *box;
typedef struct
{
GtkWidget *box;
GtkWidget *frame;
GtkWidget *socket;
} Socket;
extern guint32 create_child_plug (guint32 xid,
gboolean local);
static void
quit_cb (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
{
GtkWidget *message_dialog = gtk_message_dialog_new (GTK_WINDOW (window), 0,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
"Really Quit?");
gtk_dialog_set_default_response (GTK_DIALOG (message_dialog), GTK_RESPONSE_NO);
if (gtk_dialog_run (GTK_DIALOG (message_dialog)) == GTK_RESPONSE_YES)
gtk_widget_destroy (window);
gtk_widget_destroy (message_dialog);
}
static void
socket_destroyed (GtkWidget *widget,
Socket *socket)
{
sockets = g_slist_remove (sockets, socket);
g_free (socket);
}
static void
plug_added (GtkWidget *widget,
Socket *socket)
{
g_print ("Plug added to socket\n");
gtk_widget_show (socket->socket);
gtk_widget_hide (socket->frame);
}
static gboolean
plug_removed (GtkWidget *widget,
Socket *socket)
{
g_print ("Plug removed from socket\n");
gtk_widget_hide (socket->socket);
gtk_widget_show (socket->frame);
return TRUE;
}
static Socket *
create_socket (void)
{
GtkWidget *label;
Socket *socket = g_new (Socket, 1);
socket->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
socket->socket = gtk_socket_new ();
gtk_box_pack_start (GTK_BOX (socket->box), socket->socket, TRUE, TRUE, 0);
socket->frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (socket->frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (socket->box), socket->frame, TRUE, TRUE, 0);
gtk_widget_show (socket->frame);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label), "<span color=\"red\">Empty</span>");
gtk_container_add (GTK_CONTAINER (socket->frame), label);
gtk_widget_show (label);
sockets = g_slist_prepend (sockets, socket);
g_signal_connect (socket->socket, "destroy",
G_CALLBACK (socket_destroyed), socket);
g_signal_connect (socket->socket, "plug_added",
G_CALLBACK (plug_added), socket);
g_signal_connect (socket->socket, "plug_removed",
G_CALLBACK (plug_removed), socket);
return socket;
}
void
remove_child (GtkWidget *window)
{
if (sockets)
{
Socket *socket = sockets->data;
gtk_widget_destroy (socket->box);
}
}
static gboolean
child_read_watch (GIOChannel *channel, GIOCondition cond, gpointer data)
{
GIOStatus status;
GError *error = NULL;
char *line;
gsize term;
int xid;
status = g_io_channel_read_line (channel, &line, NULL, &term, &error);
switch (status)
{
case G_IO_STATUS_NORMAL:
line[term] = '\0';
xid = strtol (line, NULL, 0);
if (xid == 0)
{
fprintf (stderr, "Invalid window id '%s'\n", line);
}
else
{
Socket *socket = create_socket ();
gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0);
gtk_widget_show (socket->box);
gtk_socket_add_id (GTK_SOCKET (socket->socket), xid);
}
g_free (line);
return TRUE;
case G_IO_STATUS_AGAIN:
return TRUE;
case G_IO_STATUS_EOF:
n_children--;
return FALSE;
case G_IO_STATUS_ERROR:
fprintf (stderr, "Error reading fd from child: %s\n", error->message);
exit (1);
return FALSE;
default:
g_assert_not_reached ();
return FALSE;
}
}
void
add_child (GtkWidget *window,
gboolean active)
{
Socket *socket;
char *argv[3] = { "./testsocket_child", NULL, NULL };
char buffer[20];
int out_fd;
GIOChannel *channel;
GError *error = NULL;
if (active)
{
socket = create_socket ();
gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0);
gtk_widget_show (socket->box);
sprintf(buffer, "%#lx", (gulong) gtk_socket_get_id (GTK_SOCKET (socket->socket)));
argv[1] = buffer;
}
if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &out_fd, NULL, &error))
{
fprintf (stderr, "Can't exec testsocket_child: %s\n", error->message);
exit (1);
}
n_children++;
channel = g_io_channel_unix_new (out_fd);
g_io_channel_set_close_on_unref (channel, TRUE);
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, &error);
if (error)
{
fprintf (stderr, "Error making channel non-blocking: %s\n", error->message);
exit (1);
}
g_io_add_watch (channel, G_IO_IN | G_IO_HUP, child_read_watch, NULL);
g_io_channel_unref (channel);
}
void
add_active_child (GtkWidget *window)
{
add_child (window, TRUE);
}
void
add_passive_child (GtkWidget *window)
{
add_child (window, FALSE);
}
void
add_local_active_child (GtkWidget *window)
{
Socket *socket;
socket = create_socket ();
gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0);
gtk_widget_show (socket->box);
create_child_plug (gtk_socket_get_id (GTK_SOCKET (socket->socket)), TRUE);
}
void
add_local_passive_child (GtkWidget *window)
{
Socket *socket;
Window xid;
socket = create_socket ();
gtk_box_pack_start (GTK_BOX (box), socket->box, TRUE, TRUE, 0);
gtk_widget_show (socket->box);
xid = create_child_plug (0, TRUE);
gtk_socket_add_id (GTK_SOCKET (socket->socket), xid);
}
static const char *
grab_string (int status)
{
switch (status) {
case GDK_GRAB_SUCCESS: return "GrabSuccess";
case GDK_GRAB_ALREADY_GRABBED: return "AlreadyGrabbed";
case GDK_GRAB_INVALID_TIME: return "GrabInvalidTime";
case GDK_GRAB_NOT_VIEWABLE: return "GrabNotViewable";
case GDK_GRAB_FROZEN: return "GrabFrozen";
default:
{
static char foo [255];
sprintf (foo, "unknown status: %d", status);
return foo;
}
}
}
static void
grab_window_toggled (GtkToggleButton *button,
GtkWidget *widget)
{
GdkDevice *device = gtk_get_current_event_device ();
GdkSeat *seat = gdk_device_get_seat (device);
if (gtk_toggle_button_get_active (button))
{
int status;
status = gdk_seat_grab (seat, gtk_widget_get_window (widget),
GDK_SEAT_CAPABILITY_KEYBOARD,
FALSE, NULL, NULL, NULL, NULL);
if (status != GDK_GRAB_SUCCESS)
g_warning ("Could not grab keyboard! (%s)", grab_string (status));
}
else
{
gdk_seat_ungrab (seat);
}
}
int
main (int argc, char *argv[])
{
GtkWidget *button;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *menubar;
GtkWidget *menuitem;
GtkWidget *menu;
GtkWidget *entry;
GtkWidget *checkbutton;
GtkAccelGroup *accel_group;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_title (GTK_WINDOW (window), "Socket Test");
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
menubar = gtk_menu_bar_new ();
menuitem = gtk_menu_item_new_with_mnemonic ("_File");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_mnemonic ("_Quit");
g_signal_connect (menuitem, "activate", G_CALLBACK (quit_cb), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Add Active Child");
gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (add_active_child), vbox);
button = gtk_button_new_with_label ("Add Passive Child");
gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (add_passive_child), vbox);
button = gtk_button_new_with_label ("Add Local Active Child");
gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (add_local_active_child), vbox);
button = gtk_button_new_with_label ("Add Local Passive Child");
gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (add_local_passive_child), vbox);
button = gtk_button_new_with_label ("Remove Last Child");
gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (remove_child), vbox);
checkbutton = gtk_check_button_new_with_label ("Grab keyboard");
gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0);
g_signal_connect (checkbutton, "toggled",
G_CALLBACK (grab_window_toggled),
window);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX(hbox), entry, FALSE, FALSE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
box = hbox;
gtk_widget_show_all (window);
gtk_main ();
if (n_children)
{
g_print ("Waiting for children to exit\n");
while (n_children)
g_main_context_iteration (NULL, TRUE);
}
return 0;
}

View File

@ -1,65 +0,0 @@
/* testsocket_child.c
* Copyright (C) 2001 Red Hat, Inc
* Author: Owen Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
extern guint32 create_child_plug (guint32 xid,
gboolean local);
int
main (int argc, char *argv[])
{
guint32 xid;
guint32 plug_xid;
gtk_init (&argc, &argv);
if (argc != 1 && argc != 2)
{
fprintf (stderr, "Usage: testsocket_child [WINDOW_ID]\n");
exit (1);
}
if (argc == 2)
{
xid = strtol (argv[1], NULL, 0);
if (xid == 0)
{
fprintf (stderr, "Invalid window id '%s'\n", argv[1]);
exit (1);
}
create_child_plug (xid, FALSE);
}
else
{
plug_xid = create_child_plug (0, FALSE);
printf ("%d\n", plug_xid);
fflush (stdout);
}
gtk_main ();
return 0;
}

View File

@ -1,286 +0,0 @@
/* testsocket_common.c
* Copyright (C) 2001 Red Hat, Inc
* Author: Owen Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#if defined (GDK_WINDOWING_X11)
#include <gtk/gtkx.h>
#elif defined (GDK_WINDOWING_WIN32)
#include "win32/gdkwin32.h"
#endif
enum
{
ACTION_FILE_NEW,
ACTION_FILE_OPEN,
ACTION_OK,
ACTION_HELP_ABOUT
};
static void
print_hello (GtkWidget *w,
guint action)
{
switch (action)
{
case ACTION_FILE_NEW:
g_message ("File New activated");
break;
case ACTION_FILE_OPEN:
g_message ("File Open activated");
break;
case ACTION_OK:
g_message ("OK activated");
break;
case ACTION_HELP_ABOUT:
g_message ("Help About activated ");
break;
default:
g_assert_not_reached ();
break;
}
}
static void
remove_buttons (GtkWidget *widget, GtkWidget *other_button)
{
gtk_widget_destroy (other_button);
gtk_widget_destroy (widget);
}
static gboolean
blink_cb (gpointer data)
{
GtkWidget *widget = data;
gtk_widget_show (widget);
g_object_set_data (G_OBJECT (widget), "blink", NULL);
return FALSE;
}
static void
blink (GtkWidget *widget,
GtkWidget *window)
{
guint blink_timeout = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (window), "blink"));
if (!blink_timeout)
{
blink_timeout = gdk_threads_add_timeout (1000, blink_cb, window);
gtk_widget_hide (window);
g_object_set_data (G_OBJECT (window), "blink", GUINT_TO_POINTER (blink_timeout));
}
}
static void
local_destroy (GtkWidget *window)
{
guint blink_timeout = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (window), "blink"));
if (blink_timeout)
g_source_remove (blink_timeout);
}
static void
remote_destroy (GtkWidget *window)
{
local_destroy (window);
gtk_main_quit ();
}
static void
add_buttons (GtkWidget *widget, GtkWidget *box)
{
GtkWidget *add_button;
GtkWidget *remove_button;
add_button = gtk_button_new_with_mnemonic ("_Add");
gtk_box_pack_start (GTK_BOX (box), add_button, TRUE, TRUE, 0);
gtk_widget_show (add_button);
g_signal_connect (add_button, "clicked",
G_CALLBACK (add_buttons),
box);
remove_button = gtk_button_new_with_mnemonic ("_Remove");
gtk_box_pack_start (GTK_BOX (box), remove_button, TRUE, TRUE, 0);
gtk_widget_show (remove_button);
g_signal_connect (remove_button, "clicked",
G_CALLBACK (remove_buttons),
add_button);
}
static GtkWidget *
create_combo (void)
{
GtkComboBoxText *combo;
GtkWidget *entry;
combo = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ());
gtk_combo_box_text_append_text (combo, "item0");
gtk_combo_box_text_append_text (combo, "item1 item1");
gtk_combo_box_text_append_text (combo, "item2 item2 item2");
gtk_combo_box_text_append_text (combo, "item3 item3 item3 item3");
gtk_combo_box_text_append_text (combo, "item4 item4 item4 item4 item4");
gtk_combo_box_text_append_text (combo, "item5 item5 item5 item5 item5 item5");
gtk_combo_box_text_append_text (combo, "item6 item6 item6 item6 item6");
gtk_combo_box_text_append_text (combo, "item7 item7 item7 item7");
gtk_combo_box_text_append_text (combo, "item8 item8 item8");
gtk_combo_box_text_append_text (combo, "item9 item9");
entry = gtk_bin_get_child (GTK_BIN (combo));
gtk_entry_set_text (GTK_ENTRY (entry), "hello world");
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
return GTK_WIDGET (combo);
}
static GtkWidget *
create_menubar (GtkWindow *window)
{
GtkAccelGroup *accel_group=NULL;
GtkWidget *menubar;
GtkWidget *menuitem;
GtkWidget *menu;
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (window, accel_group);
menubar = gtk_menu_bar_new ();
menuitem = gtk_menu_item_new_with_mnemonic ("_File");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_mnemonic ("_New");
g_signal_connect (menuitem, "activate", G_CALLBACK (print_hello), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("_Quit");
g_signal_connect (menuitem, "activate", G_CALLBACK (gtk_main_quit), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("O_K");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("_Help");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_mnemonic ("_About");
g_signal_connect (menuitem, "activate", G_CALLBACK (print_hello), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
return menubar;
}
static GtkWidget *
create_combo_box (void)
{
GtkComboBoxText *combo_box = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
gtk_combo_box_text_append_text (combo_box, "This");
gtk_combo_box_text_append_text (combo_box, "Is");
gtk_combo_box_text_append_text (combo_box, "A");
gtk_combo_box_text_append_text (combo_box, "ComboBox");
return GTK_WIDGET (combo_box);
}
static GtkWidget *
create_content (GtkWindow *window, gboolean local)
{
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *frame;
frame = gtk_frame_new (local? "Local" : "Remote");
gtk_container_set_border_width (GTK_CONTAINER (frame), 3);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
gtk_container_add (GTK_CONTAINER (frame), vbox);
/* Combo */
gtk_box_pack_start (GTK_BOX (vbox), create_combo(), TRUE, TRUE, 0);
/* Entry */
gtk_box_pack_start (GTK_BOX (vbox), gtk_entry_new(), TRUE, TRUE, 0);
/* Close Button */
button = gtk_button_new_with_mnemonic ("_Close");
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gtk_widget_destroy), window);
/* Blink Button */
button = gtk_button_new_with_mnemonic ("_Blink");
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (blink),
window);
/* Menubar */
gtk_box_pack_start (GTK_BOX (vbox), create_menubar (GTK_WINDOW (window)),
TRUE, TRUE, 0);
/* Combo Box */
gtk_box_pack_start (GTK_BOX (vbox), create_combo_box (), TRUE, TRUE, 0);
add_buttons (NULL, vbox);
return frame;
}
guint32
create_child_plug (guint32 xid,
gboolean local)
{
GtkWidget *window;
GtkWidget *content;
window = gtk_plug_new (xid);
g_signal_connect (window, "destroy",
local ? G_CALLBACK (local_destroy)
: G_CALLBACK (remote_destroy),
NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
content = create_content (GTK_WINDOW (window), local);
gtk_container_add (GTK_CONTAINER (window), content);
gtk_widget_show_all (window);
if (gtk_widget_get_realized (window))
#if defined (GDK_WINDOWING_X11)
return GDK_WINDOW_XID (gtk_widget_get_window (window));
#elif defined (GDK_WINDOWING_WIN32)
return (guint32) GDK_WINDOW_HWND (gtk_widget_get_window (window));
#elif defined (GDK_WINDOWING_BROADWAY)
return (guint32) 0; /* Child windows not supported */
#endif
else
return 0;
}

View File

@ -19,9 +19,6 @@
#include <string.h>
#include <gtk/gtk.h>
#include <gtk/gtkunixprint.h>
#ifdef GDK_WINDOWING_X11
#include <gtk/gtkx.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include "gdk/wayland/gdkwayland.h"
#endif
@ -416,14 +413,6 @@ test_type (gconstpointer data)
if (g_type_is_a (type, GTK_TYPE_MOUNT_OPERATION))
return;
/* Backend-specific */
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) ;
else if (g_type_is_a (type, GTK_TYPE_PLUG) ||
g_type_is_a (type, GTK_TYPE_SOCKET))
return;
#endif
klass = g_type_class_ref (type);
if (g_type_is_a (type, GTK_TYPE_SETTINGS))