2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2005-07-21 13:26:27 +00:00
|
|
|
* 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, write to the Free
|
|
|
|
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2005-07-21 13:26:27 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gdk/gdkkeysyms.h"
|
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtkmarshalers.h"
|
|
|
|
#include "gtkwindow.h"
|
|
|
|
#include "gtkplug.h"
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtksocket.h"
|
|
|
|
#include "gtksocketprivate.h"
|
|
|
|
#include "gtkdnd.h"
|
2010-09-18 23:57:32 +00:00
|
|
|
#include "gtkdebug.h"
|
2005-07-21 13:26:27 +00:00
|
|
|
|
|
|
|
#include "x11/gdkx.h"
|
|
|
|
|
2005-08-29 17:18:12 +00:00
|
|
|
#ifdef HAVE_XFIXES
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#endif
|
|
|
|
|
2005-07-21 13:26:27 +00:00
|
|
|
#include "gtkxembed.h"
|
|
|
|
|
|
|
|
static gboolean xembed_get_info (GdkWindow *gdk_window,
|
|
|
|
unsigned long *version,
|
|
|
|
unsigned long *flags);
|
|
|
|
|
|
|
|
/* From Tk */
|
|
|
|
#define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20
|
|
|
|
|
|
|
|
GdkNativeWindow
|
|
|
|
_gtk_socket_windowing_get_id (GtkSocket *socket)
|
|
|
|
{
|
2010-08-15 15:36:02 +00:00
|
|
|
return GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (socket)));
|
2005-07-21 13:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_realize_window (GtkSocket *socket)
|
|
|
|
{
|
2010-08-15 15:36:02 +00:00
|
|
|
GdkWindow *window;
|
2005-07-21 13:26:27 +00:00
|
|
|
XWindowAttributes xattrs;
|
|
|
|
|
2010-08-15 15:36:02 +00:00
|
|
|
window = gtk_widget_get_window (GTK_WIDGET (socket));
|
|
|
|
|
2005-07-21 13:26:27 +00:00
|
|
|
XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
GDK_WINDOW_XWINDOW (window),
|
|
|
|
&xattrs);
|
|
|
|
|
2009-07-04 18:13:43 +00:00
|
|
|
/* Sooooo, it turns out that mozilla, as per the gtk2xt code selects
|
|
|
|
for input on the socket with a mask of 0x0fffff (for god knows why)
|
|
|
|
which includes ButtonPressMask causing a BadAccess if someone else
|
|
|
|
also selects for this. As per the client-side windows merge we always
|
|
|
|
normally selects for button press so we can emulate it on client
|
|
|
|
side children that selects for button press. However, we don't need
|
|
|
|
this for GtkSocket, so we unselect it here, fixing the crashes in
|
|
|
|
firefox. */
|
2005-07-21 13:26:27 +00:00
|
|
|
XSelectInput (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
GDK_WINDOW_XWINDOW (window),
|
2009-07-04 18:13:43 +00:00
|
|
|
(xattrs.your_event_mask & ~ButtonPressMask) |
|
2005-07-21 13:26:27 +00:00
|
|
|
SubstructureNotifyMask | SubstructureRedirectMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_end_embedding_toplevel (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
gtk_window_remove_embedded_xid (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket))),
|
|
|
|
GDK_WINDOW_XWINDOW (socket->plug_window));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_size_request (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
XSizeHints hints;
|
|
|
|
long supplied;
|
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
|
|
|
|
socket->request_width = 1;
|
|
|
|
socket->request_height = 1;
|
|
|
|
|
|
|
|
if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (socket->plug_window),
|
|
|
|
GDK_WINDOW_XWINDOW (socket->plug_window),
|
|
|
|
&hints, &supplied))
|
|
|
|
{
|
|
|
|
if (hints.flags & PMinSize)
|
|
|
|
{
|
2005-09-30 14:57:02 +00:00
|
|
|
socket->request_width = MAX (hints.min_width, 1);
|
|
|
|
socket->request_height = MAX (hints.min_height, 1);
|
2005-07-21 13:26:27 +00:00
|
|
|
}
|
|
|
|
else if (hints.flags & PBaseSize)
|
|
|
|
{
|
2005-09-30 14:57:02 +00:00
|
|
|
socket->request_width = MAX (hints.base_width, 1);
|
|
|
|
socket->request_height = MAX (hints.base_height, 1);
|
2005-07-21 13:26:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
socket->have_size = TRUE;
|
|
|
|
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-07-21 13:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_send_key_event (GtkSocket *socket,
|
|
|
|
GdkEvent *gdk_event,
|
|
|
|
gboolean mask_key_presses)
|
|
|
|
{
|
2007-01-04 01:28:07 +00:00
|
|
|
XKeyEvent xkey;
|
2010-08-28 23:18:43 +00:00
|
|
|
GdkScreen *screen = gdk_window_get_screen (socket->plug_window);
|
2005-07-21 13:26:27 +00:00
|
|
|
|
2007-01-04 01:28:07 +00:00
|
|
|
memset (&xkey, 0, sizeof (xkey));
|
|
|
|
xkey.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease;
|
|
|
|
xkey.window = GDK_WINDOW_XWINDOW (socket->plug_window);
|
|
|
|
xkey.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));
|
|
|
|
xkey.subwindow = None;
|
|
|
|
xkey.time = gdk_event->key.time;
|
|
|
|
xkey.x = 0;
|
|
|
|
xkey.y = 0;
|
|
|
|
xkey.x_root = 0;
|
|
|
|
xkey.y_root = 0;
|
|
|
|
xkey.state = gdk_event->key.state;
|
|
|
|
xkey.keycode = gdk_event->key.hardware_keycode;
|
|
|
|
xkey.same_screen = True;/* FIXME ? */
|
2005-07-21 13:26:27 +00:00
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window),
|
|
|
|
GDK_WINDOW_XWINDOW (socket->plug_window),
|
|
|
|
False,
|
|
|
|
(mask_key_presses ? KeyPressMask : NoEventMask),
|
2007-01-04 01:28:07 +00:00
|
|
|
(XEvent *)&xkey);
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-07-21 13:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_focus_change (GtkSocket *socket,
|
|
|
|
gboolean focus_in)
|
|
|
|
{
|
|
|
|
if (focus_in)
|
|
|
|
_gtk_xembed_send_focus_message (socket->plug_window,
|
|
|
|
XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
|
|
|
|
else
|
|
|
|
_gtk_xembed_send_message (socket->plug_window,
|
|
|
|
XEMBED_FOCUS_OUT, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_update_active (GtkSocket *socket,
|
|
|
|
gboolean active)
|
|
|
|
{
|
|
|
|
_gtk_xembed_send_message (socket->plug_window,
|
|
|
|
active ? XEMBED_WINDOW_ACTIVATE : XEMBED_WINDOW_DEACTIVATE,
|
|
|
|
0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_update_modality (GtkSocket *socket,
|
|
|
|
gboolean modality)
|
|
|
|
{
|
|
|
|
_gtk_xembed_send_message (socket->plug_window,
|
|
|
|
modality ? XEMBED_MODALITY_ON : XEMBED_MODALITY_OFF,
|
|
|
|
0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_focus (GtkSocket *socket,
|
|
|
|
GtkDirectionType direction)
|
|
|
|
{
|
|
|
|
gint detail = -1;
|
|
|
|
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case GTK_DIR_UP:
|
|
|
|
case GTK_DIR_LEFT:
|
|
|
|
case GTK_DIR_TAB_BACKWARD:
|
|
|
|
detail = XEMBED_FOCUS_LAST;
|
|
|
|
break;
|
|
|
|
case GTK_DIR_DOWN:
|
|
|
|
case GTK_DIR_RIGHT:
|
|
|
|
case GTK_DIR_TAB_FORWARD:
|
|
|
|
detail = XEMBED_FOCUS_FIRST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gtk_xembed_send_focus_message (socket->plug_window, XEMBED_FOCUS_IN, detail);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_send_configure_event (GtkSocket *socket)
|
|
|
|
{
|
2010-08-15 15:36:02 +00:00
|
|
|
GtkAllocation allocation;
|
2007-01-04 01:28:07 +00:00
|
|
|
XConfigureEvent xconfigure;
|
2005-07-21 13:26:27 +00:00
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
g_return_if_fail (socket->plug_window != NULL);
|
|
|
|
|
2007-01-04 01:28:07 +00:00
|
|
|
memset (&xconfigure, 0, sizeof (xconfigure));
|
|
|
|
xconfigure.type = ConfigureNotify;
|
2005-07-21 13:26:27 +00:00
|
|
|
|
2007-01-04 01:28:07 +00:00
|
|
|
xconfigure.event = GDK_WINDOW_XWINDOW (socket->plug_window);
|
|
|
|
xconfigure.window = GDK_WINDOW_XWINDOW (socket->plug_window);
|
2005-07-21 13:26:27 +00:00
|
|
|
|
|
|
|
/* The ICCCM says that synthetic events should have root relative
|
|
|
|
* coordinates. We still aren't really ICCCM compliant, since
|
|
|
|
* we don't send events when the real toplevel is moved.
|
|
|
|
*/
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
gdk_window_get_origin (socket->plug_window, &x, &y);
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2010-08-15 15:36:02 +00:00
|
|
|
|
|
|
|
gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation);
|
2007-01-04 01:28:07 +00:00
|
|
|
xconfigure.x = x;
|
|
|
|
xconfigure.y = y;
|
2010-08-15 15:36:02 +00:00
|
|
|
xconfigure.width = allocation.width;
|
|
|
|
xconfigure.height = allocation.height;
|
2005-07-21 13:26:27 +00:00
|
|
|
|
2007-01-04 01:28:07 +00:00
|
|
|
xconfigure.border_width = 0;
|
|
|
|
xconfigure.above = None;
|
|
|
|
xconfigure.override_redirect = False;
|
2005-07-21 13:26:27 +00:00
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window),
|
|
|
|
GDK_WINDOW_XWINDOW (socket->plug_window),
|
2007-01-04 01:28:07 +00:00
|
|
|
False, NoEventMask, (XEvent *)&xconfigure);
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-07-21 13:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_select_plug_window_input (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
XSelectInput (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))),
|
|
|
|
GDK_WINDOW_XWINDOW (socket->plug_window),
|
|
|
|
StructureNotifyMask | PropertyChangeMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_embed_get_info (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
unsigned long version;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
socket->xembed_version = -1;
|
|
|
|
if (xembed_get_info (socket->plug_window, &version, &flags))
|
|
|
|
{
|
|
|
|
socket->xembed_version = MIN (GTK_XEMBED_PROTOCOL_VERSION, version);
|
|
|
|
socket->is_mapped = (flags & XEMBED_MAPPED) != 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME, we should probably actually check the state before we started */
|
|
|
|
socket->is_mapped = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_embed_notify (GtkSocket *socket)
|
|
|
|
{
|
2005-08-29 17:18:12 +00:00
|
|
|
#ifdef HAVE_XFIXES
|
2005-08-29 23:48:49 +00:00
|
|
|
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (socket));
|
2005-08-29 17:18:12 +00:00
|
|
|
|
2010-10-27 16:40:59 +00:00
|
|
|
gdk_error_trap_push ();
|
2005-08-29 23:48:49 +00:00
|
|
|
XFixesChangeSaveSet (GDK_DISPLAY_XDISPLAY (display),
|
2005-08-29 17:18:12 +00:00
|
|
|
GDK_WINDOW_XWINDOW (socket->plug_window),
|
|
|
|
SetModeInsert, SaveSetRoot, SaveSetUnmap);
|
2010-10-27 17:00:58 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-08-29 17:18:12 +00:00
|
|
|
#endif
|
2005-07-21 13:26:27 +00:00
|
|
|
_gtk_xembed_send_message (socket->plug_window,
|
|
|
|
XEMBED_EMBEDDED_NOTIFY, 0,
|
2010-08-15 15:36:02 +00:00
|
|
|
GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (socket))),
|
2005-07-21 13:26:27 +00:00
|
|
|
socket->xembed_version);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
xembed_get_info (GdkWindow *window,
|
|
|
|
unsigned long *version,
|
|
|
|
unsigned long *flags)
|
|
|
|
{
|
2010-08-29 00:08:24 +00:00
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
2005-07-21 13:26:27 +00:00
|
|
|
Atom xembed_info_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO");
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
unsigned char *data;
|
|
|
|
unsigned long *data_long;
|
|
|
|
int status;
|
|
|
|
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_push ();
|
2005-07-21 13:26:27 +00:00
|
|
|
status = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
|
|
|
|
GDK_WINDOW_XWINDOW (window),
|
|
|
|
xembed_info_atom,
|
|
|
|
0, 2, False,
|
|
|
|
xembed_info_atom, &type, &format,
|
|
|
|
&nitems, &bytes_after, &data);
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-07-21 13:26:27 +00:00
|
|
|
|
|
|
|
if (status != Success)
|
|
|
|
return FALSE; /* Window vanished? */
|
|
|
|
|
|
|
|
if (type == None) /* No info property */
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (type != xembed_info_atom)
|
|
|
|
{
|
|
|
|
g_warning ("_XEMBED_INFO property has wrong type\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nitems < 2)
|
|
|
|
{
|
|
|
|
g_warning ("_XEMBED_INFO too short\n");
|
|
|
|
XFree (data);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_long = (unsigned long *)data;
|
|
|
|
if (version)
|
|
|
|
*version = data_long[0];
|
|
|
|
if (flags)
|
|
|
|
*flags = data_long[1] & XEMBED_MAPPED;
|
|
|
|
|
|
|
|
XFree (data);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gtk_socket_windowing_embed_get_focus_wrapped (void)
|
|
|
|
{
|
|
|
|
return _gtk_xembed_get_focus_wrapped ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_socket_windowing_embed_set_focus_wrapped (void)
|
|
|
|
{
|
|
|
|
_gtk_xembed_set_focus_wrapped ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_xembed_message (GtkSocket *socket,
|
|
|
|
XEmbedMessageType message,
|
|
|
|
glong detail,
|
|
|
|
glong data1,
|
|
|
|
glong data2,
|
|
|
|
guint32 time)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket: %s received", _gtk_xembed_message_name (message)));
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case XEMBED_EMBEDDED_NOTIFY:
|
|
|
|
case XEMBED_WINDOW_ACTIVATE:
|
|
|
|
case XEMBED_WINDOW_DEACTIVATE:
|
|
|
|
case XEMBED_MODALITY_ON:
|
|
|
|
case XEMBED_MODALITY_OFF:
|
|
|
|
case XEMBED_FOCUS_IN:
|
|
|
|
case XEMBED_FOCUS_OUT:
|
|
|
|
g_warning ("GtkSocket: Invalid _XEMBED message %s received", _gtk_xembed_message_name (message));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_REQUEST_FOCUS:
|
|
|
|
_gtk_socket_claim_focus (socket, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_FOCUS_NEXT:
|
|
|
|
case XEMBED_FOCUS_PREV:
|
|
|
|
_gtk_socket_advance_toplevel_focus (socket,
|
|
|
|
(message == XEMBED_FOCUS_NEXT ?
|
|
|
|
GTK_DIR_TAB_FORWARD : GTK_DIR_TAB_BACKWARD));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_GTK_GRAB_KEY:
|
|
|
|
_gtk_socket_add_grabbed_key (socket, data1, data2);
|
|
|
|
break;
|
|
|
|
case XEMBED_GTK_UNGRAB_KEY:
|
|
|
|
_gtk_socket_remove_grabbed_key (socket, data1, data2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_GRAB_KEY:
|
|
|
|
case XEMBED_UNGRAB_KEY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket: Ignoring unknown _XEMBED message of type %d", message));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkFilterReturn
|
|
|
|
_gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkSocket *socket;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GdkDisplay *display;
|
|
|
|
XEvent *xevent;
|
|
|
|
|
|
|
|
GdkFilterReturn return_val;
|
|
|
|
|
|
|
|
socket = GTK_SOCKET (data);
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_CONTINUE;
|
|
|
|
|
|
|
|
if (socket->plug_widget)
|
|
|
|
return return_val;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (socket);
|
|
|
|
xevent = (XEvent *)gdk_xevent;
|
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
|
|
|
switch (xevent->type)
|
|
|
|
{
|
|
|
|
case ClientMessage:
|
|
|
|
if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"))
|
|
|
|
{
|
|
|
|
_gtk_xembed_push_message (xevent);
|
|
|
|
handle_xembed_message (socket,
|
|
|
|
xevent->xclient.data.l[1],
|
|
|
|
xevent->xclient.data.l[2],
|
|
|
|
xevent->xclient.data.l[3],
|
|
|
|
xevent->xclient.data.l[4],
|
|
|
|
xevent->xclient.data.l[0]);
|
|
|
|
_gtk_xembed_pop_message ();
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CreateNotify:
|
|
|
|
{
|
|
|
|
XCreateWindowEvent *xcwe = &xevent->xcreatewindow;
|
|
|
|
|
|
|
|
if (!socket->plug_window)
|
|
|
|
{
|
|
|
|
_gtk_socket_add_window (socket, xcwe->window, FALSE);
|
|
|
|
|
|
|
|
if (socket->plug_window)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window created"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ConfigureRequest:
|
|
|
|
{
|
|
|
|
XConfigureRequestEvent *xcre = &xevent->xconfigurerequest;
|
|
|
|
|
|
|
|
if (!socket->plug_window)
|
|
|
|
_gtk_socket_add_window (socket, xcre->window, FALSE);
|
|
|
|
|
|
|
|
if (socket->plug_window)
|
|
|
|
{
|
|
|
|
GtkSocketPrivate *private = _gtk_socket_get_private (socket);
|
|
|
|
|
|
|
|
if (xcre->value_mask & (CWWidth | CWHeight))
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket - configure request: %d %d",
|
|
|
|
socket->request_width,
|
|
|
|
socket->request_height));
|
|
|
|
|
|
|
|
private->resize_count++;
|
|
|
|
gtk_widget_queue_resize (widget);
|
|
|
|
}
|
|
|
|
else if (xcre->value_mask & (CWX | CWY))
|
|
|
|
{
|
|
|
|
_gtk_socket_windowing_send_configure_event (socket);
|
|
|
|
}
|
|
|
|
/* Ignore stacking requests. */
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DestroyNotify:
|
|
|
|
{
|
|
|
|
XDestroyWindowEvent *xdwe = &xevent->xdestroywindow;
|
|
|
|
|
|
|
|
/* Note that we get destroy notifies both from SubstructureNotify on
|
|
|
|
* our window and StructureNotify on socket->plug_window
|
|
|
|
*/
|
|
|
|
if (socket->plug_window && (xdwe->window == GDK_WINDOW_XWINDOW (socket->plug_window)))
|
|
|
|
{
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - destroy notify"));
|
|
|
|
|
|
|
|
gdk_window_destroy_notify (socket->plug_window);
|
|
|
|
_gtk_socket_end_embedding (socket);
|
|
|
|
|
|
|
|
g_object_ref (widget);
|
2008-08-11 13:36:15 +00:00
|
|
|
g_signal_emit_by_name (widget, "plug-removed", &result);
|
2005-07-21 13:26:27 +00:00
|
|
|
if (!result)
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
g_object_unref (widget);
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FocusIn:
|
|
|
|
if (xevent->xfocus.mode == EMBEDDED_APP_WANTS_FOCUS)
|
|
|
|
{
|
|
|
|
_gtk_socket_claim_focus (socket, TRUE);
|
|
|
|
}
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
break;
|
|
|
|
case FocusOut:
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
break;
|
|
|
|
case MapRequest:
|
|
|
|
if (!socket->plug_window)
|
|
|
|
{
|
|
|
|
_gtk_socket_add_window (socket, xevent->xmaprequest.window, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (socket->plug_window)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Map Request"));
|
|
|
|
|
|
|
|
_gtk_socket_handle_map_request (socket);
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
if (socket->plug_window &&
|
|
|
|
xevent->xproperty.window == GDK_WINDOW_XWINDOW (socket->plug_window))
|
|
|
|
{
|
|
|
|
GdkDragProtocol protocol;
|
|
|
|
|
|
|
|
if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_NORMAL_HINTS"))
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - received PropertyNotify for plug's WM_NORMAL_HINTS"));
|
|
|
|
socket->have_size = FALSE;
|
|
|
|
gtk_widget_queue_resize (widget);
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
else if ((xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "XdndAware")) ||
|
|
|
|
(xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO")))
|
|
|
|
{
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
if (gdk_drag_get_protocol_for_display (display,
|
|
|
|
xevent->xproperty.window,
|
|
|
|
&protocol))
|
|
|
|
gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
|
|
|
|
socket->plug_window,
|
|
|
|
protocol, TRUE);
|
|
|
|
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-07-21 13:26:27 +00:00
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
else if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO"))
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (xembed_get_info (socket->plug_window, NULL, &flags))
|
|
|
|
{
|
|
|
|
gboolean was_mapped = socket->is_mapped;
|
|
|
|
gboolean is_mapped = (flags & XEMBED_MAPPED) != 0;
|
|
|
|
|
|
|
|
if (was_mapped != is_mapped)
|
|
|
|
{
|
|
|
|
if (is_mapped)
|
|
|
|
_gtk_socket_handle_map_request (socket);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
gdk_window_show (socket->plug_window);
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
2005-07-21 13:26:27 +00:00
|
|
|
|
|
|
|
_gtk_socket_unmap_notify (socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ReparentNotify:
|
|
|
|
{
|
2010-08-15 15:36:02 +00:00
|
|
|
GdkWindow *window;
|
2005-07-21 13:26:27 +00:00
|
|
|
XReparentEvent *xre = &xevent->xreparent;
|
|
|
|
|
2010-08-15 15:36:02 +00:00
|
|
|
window = gtk_widget_get_window (widget);
|
|
|
|
|
2008-09-19 22:52:33 +00:00
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - ReparentNotify received"));
|
2010-08-15 15:36:02 +00:00
|
|
|
if (!socket->plug_window &&
|
|
|
|
xre->parent == GDK_WINDOW_XWINDOW (window))
|
2005-07-21 13:26:27 +00:00
|
|
|
{
|
|
|
|
_gtk_socket_add_window (socket, xre->window, FALSE);
|
|
|
|
|
|
|
|
if (socket->plug_window)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window reparented"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
2009-11-28 04:44:01 +00:00
|
|
|
else
|
|
|
|
{
|
2010-08-15 15:36:02 +00:00
|
|
|
if (socket->plug_window &&
|
|
|
|
xre->window == GDK_WINDOW_XWINDOW (socket->plug_window) &&
|
|
|
|
xre->parent != GDK_WINDOW_XWINDOW (window))
|
2009-11-28 04:44:01 +00:00
|
|
|
{
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
_gtk_socket_end_embedding (socket);
|
|
|
|
|
|
|
|
g_object_ref (widget);
|
|
|
|
g_signal_emit_by_name (widget, "plug-removed", &result);
|
|
|
|
if (!result)
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
g_object_unref (widget);
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-21 13:26:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UnmapNotify:
|
|
|
|
if (socket->plug_window &&
|
|
|
|
xevent->xunmap.window == GDK_WINDOW_XWINDOW (socket->plug_window))
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Unmap notify"));
|
|
|
|
|
|
|
|
_gtk_socket_unmap_notify (socket);
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_val;
|
|
|
|
}
|