Split toplevel-specific pieces of GdkWindowImplX11 into a separate

Fri Jul  4 22:26:27 2003  Owen Taylor  <otaylor@redhat.com>

        * gdk/x11/gdkwindow-x11.[ch] gdkevents-x11.c: Split
        toplevel-specific pieces of GdkWindowImplX11 into
        a separate GdkToplevelX11 structure.
This commit is contained in:
Owen Taylor 2003-07-05 02:34:52 +00:00 committed by Owen Taylor
parent bce0622bd6
commit 8625065817
8 changed files with 229 additions and 162 deletions

View File

@ -1,3 +1,9 @@
Fri Jul 4 22:26:27 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.[ch] gdkevents-x11.c: Split
toplevel-specific pieces of GdkWindowImplX11 into
a separate GdkToplevelX11 structure.
Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix * gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix

View File

@ -1,3 +1,9 @@
Fri Jul 4 22:26:27 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.[ch] gdkevents-x11.c: Split
toplevel-specific pieces of GdkWindowImplX11 into
a separate GdkToplevelX11 structure.
Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix * gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix

View File

@ -1,3 +1,9 @@
Fri Jul 4 22:26:27 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.[ch] gdkevents-x11.c: Split
toplevel-specific pieces of GdkWindowImplX11 into
a separate GdkToplevelX11 structure.
Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix * gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix

View File

@ -1,3 +1,9 @@
Fri Jul 4 22:26:27 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.[ch] gdkevents-x11.c: Split
toplevel-specific pieces of GdkWindowImplX11 into
a separate GdkToplevelX11 structure.
Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix * gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix

View File

@ -1,3 +1,9 @@
Fri Jul 4 22:26:27 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.[ch] gdkevents-x11.c: Split
toplevel-specific pieces of GdkWindowImplX11 into
a separate GdkToplevelX11 structure.
Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 22:05:09 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix * gdk/x11/gdkasync.c (struct _SetInputFocusState): Fix

View File

@ -359,9 +359,8 @@ gdk_add_client_message_filter (GdkAtom message_type,
static void static void
do_net_wm_state_changes (GdkWindow *window) do_net_wm_state_changes (GdkWindow *window)
{ {
GdkWindowObject *window_private = (GdkWindowObject *)window; GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
GdkWindowImplX11 *window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
GdkWindowState old_state; GdkWindowState old_state;
if (GDK_WINDOW_DESTROYED (window) || if (GDK_WINDOW_DESTROYED (window) ||
@ -375,14 +374,14 @@ do_net_wm_state_changes (GdkWindow *window)
*/ */
if (old_state & GDK_WINDOW_STATE_STICKY) if (old_state & GDK_WINDOW_STATE_STICKY)
{ {
if (!(window_impl->have_sticky && window_impl->on_all_desktops)) if (!(toplevel->have_sticky && toplevel->on_all_desktops))
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_STICKY, GDK_WINDOW_STATE_STICKY,
0); 0);
} }
else else
{ {
if (window_impl->have_sticky && window_impl->on_all_desktops) if (toplevel->have_sticky && toplevel->on_all_desktops)
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
0, 0,
GDK_WINDOW_STATE_STICKY); GDK_WINDOW_STATE_STICKY);
@ -390,14 +389,14 @@ do_net_wm_state_changes (GdkWindow *window)
if (old_state & GDK_WINDOW_STATE_FULLSCREEN) if (old_state & GDK_WINDOW_STATE_FULLSCREEN)
{ {
if (!window_impl->have_fullscreen) if (!toplevel->have_fullscreen)
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_FULLSCREEN, GDK_WINDOW_STATE_FULLSCREEN,
0); 0);
} }
else else
{ {
if (window_impl->have_fullscreen) if (toplevel->have_fullscreen)
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
0, 0,
GDK_WINDOW_STATE_FULLSCREEN); GDK_WINDOW_STATE_FULLSCREEN);
@ -408,14 +407,14 @@ do_net_wm_state_changes (GdkWindow *window)
*/ */
if (old_state & GDK_WINDOW_STATE_MAXIMIZED) if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
{ {
if (!(window_impl->have_maxvert && window_impl->have_maxhorz)) if (!(toplevel->have_maxvert && toplevel->have_maxhorz))
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_MAXIMIZED, GDK_WINDOW_STATE_MAXIMIZED,
0); 0);
} }
else else
{ {
if (window_impl->have_maxvert && window_impl->have_maxhorz) if (toplevel->have_maxvert && toplevel->have_maxhorz)
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
0, 0,
GDK_WINDOW_STATE_MAXIMIZED); GDK_WINDOW_STATE_MAXIMIZED);
@ -425,8 +424,7 @@ do_net_wm_state_changes (GdkWindow *window)
static void static void
gdk_check_wm_desktop_changed (GdkWindow *window) gdk_check_wm_desktop_changed (GdkWindow *window)
{ {
GdkWindowObject *window_private = (GdkWindowObject *)window; GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
GdkWindowImplX11 *window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
Atom type; Atom type;
@ -434,7 +432,7 @@ gdk_check_wm_desktop_changed (GdkWindow *window)
gulong nitems; gulong nitems;
gulong bytes_after; gulong bytes_after;
if (window_impl->have_sticky) if (toplevel->have_sticky)
{ {
gulong *desktop; gulong *desktop;
@ -447,11 +445,11 @@ gdk_check_wm_desktop_changed (GdkWindow *window)
if (type != None) if (type != None)
{ {
window_impl->on_all_desktops = (*desktop == 0xFFFFFFFF); toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
XFree (desktop); XFree (desktop);
} }
else else
window_impl->on_all_desktops = FALSE; toplevel->on_all_desktops = FALSE;
do_net_wm_state_changes (window); do_net_wm_state_changes (window);
} }
@ -460,8 +458,7 @@ gdk_check_wm_desktop_changed (GdkWindow *window)
static void static void
gdk_check_wm_state_changed (GdkWindow *window) gdk_check_wm_state_changed (GdkWindow *window)
{ {
GdkWindowObject *window_private = (GdkWindowObject *)window; GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
GdkWindowImplX11 *window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
Atom type; Atom type;
@ -471,7 +468,7 @@ gdk_check_wm_state_changed (GdkWindow *window)
Atom *atoms = NULL; Atom *atoms = NULL;
gulong i; gulong i;
gboolean had_sticky = window_impl->have_sticky; gboolean had_sticky = toplevel->have_sticky;
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"), gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
@ -489,13 +486,13 @@ gdk_check_wm_state_changed (GdkWindow *window)
while (i < nitems) while (i < nitems)
{ {
if (atoms[i] == sticky_atom) if (atoms[i] == sticky_atom)
window_impl->have_sticky = TRUE; toplevel->have_sticky = TRUE;
else if (atoms[i] == maxvert_atom) else if (atoms[i] == maxvert_atom)
window_impl->have_maxvert = TRUE; toplevel->have_maxvert = TRUE;
else if (atoms[i] == maxhorz_atom) else if (atoms[i] == maxhorz_atom)
window_impl->have_maxhorz = TRUE; toplevel->have_maxhorz = TRUE;
else if (atoms[i] == fullscreen_atom) else if (atoms[i] == fullscreen_atom)
window_impl->have_fullscreen = TRUE; toplevel->have_fullscreen = TRUE;
++i; ++i;
} }
@ -506,14 +503,14 @@ gdk_check_wm_state_changed (GdkWindow *window)
/* When have_sticky is turned on, we have to check the DESKTOP property /* When have_sticky is turned on, we have to check the DESKTOP property
* as well. * as well.
*/ */
if (window_impl->have_sticky && !had_sticky) if (toplevel->have_sticky && !had_sticky)
gdk_check_wm_desktop_changed (window); gdk_check_wm_desktop_changed (window);
else else
do_net_wm_state_changes (window); do_net_wm_state_changes (window);
} }
#define HAS_FOCUS(window_impl) \ #define HAS_FOCUS(toplevel) \
((window_impl)->has_focus || (window_impl)->has_pointer_focus) ((toplevel)->has_focus || (toplevel)->has_pointer_focus)
static void static void
generate_focus_event (GdkWindow *window, generate_focus_event (GdkWindow *window,
@ -724,6 +721,7 @@ gdk_event_translate (GdkDisplay *display,
gint xoffset, yoffset; gint xoffset, yoffset;
GdkScreen *screen = NULL; GdkScreen *screen = NULL;
GdkScreenX11 *screen_x11 = NULL; GdkScreenX11 *screen_x11 = NULL;
GdkToplevelX11 *toplevel = NULL;
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display); GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
Window xwindow; Window xwindow;
@ -769,6 +767,7 @@ gdk_event_translate (GdkDisplay *display,
{ {
screen = GDK_WINDOW_SCREEN (window); screen = GDK_WINDOW_SCREEN (window);
screen_x11 = GDK_SCREEN_X11 (screen); screen_x11 = GDK_SCREEN_X11 (screen);
toplevel = _gdk_x11_window_get_toplevel (window);
} }
if (window != NULL) if (window != NULL)
@ -785,7 +784,7 @@ gdk_event_translate (GdkDisplay *display,
/* Move key events on focus window to the real toplevel, and /* Move key events on focus window to the real toplevel, and
* filter out all other events on focus window * filter out all other events on focus window
*/ */
if (xwindow == window_impl->focus_window) if (toplevel && xwindow == toplevel->focus_window)
{ {
switch (xevent->type) switch (xevent->type)
{ {
@ -1083,16 +1082,15 @@ gdk_event_translate (GdkDisplay *display,
} }
/* Handle focusing (in the case where no window manager is running */ /* Handle focusing (in the case where no window manager is running */
if (window && if (toplevel &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
xevent->xcrossing.detail != NotifyInferior && xevent->xcrossing.detail != NotifyInferior &&
xevent->xcrossing.focus && !window_impl->has_focus_window) xevent->xcrossing.focus && !toplevel->has_focus_window)
{ {
gboolean had_focus = HAS_FOCUS (window_impl); gboolean had_focus = HAS_FOCUS (toplevel);
window_impl->has_pointer_focus = TRUE; toplevel->has_pointer_focus = TRUE;
if (HAS_FOCUS (window_impl) != had_focus) if (HAS_FOCUS (toplevel) != had_focus)
generate_focus_event (window, TRUE); generate_focus_event (window, TRUE);
} }
@ -1178,16 +1176,15 @@ gdk_event_translate (GdkDisplay *display,
} }
/* Handle focusing (in the case where no window manager is running */ /* Handle focusing (in the case where no window manager is running */
if (window && if (toplevel &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
xevent->xcrossing.detail != NotifyInferior && xevent->xcrossing.detail != NotifyInferior &&
xevent->xcrossing.focus && !window_impl->has_focus_window) xevent->xcrossing.focus && !toplevel->has_focus_window)
{ {
gboolean had_focus = HAS_FOCUS (window_impl); gboolean had_focus = HAS_FOCUS (toplevel);
window_impl->has_pointer_focus = FALSE; toplevel->has_pointer_focus = FALSE;
if (HAS_FOCUS (window_impl) != had_focus) if (HAS_FOCUS (toplevel) != had_focus)
generate_focus_event (window, FALSE); generate_focus_event (window, FALSE);
} }
@ -1264,9 +1261,9 @@ gdk_event_translate (GdkDisplay *display,
notify_details[xevent->xfocus.detail], notify_details[xevent->xfocus.detail],
notify_modes[xevent->xfocus.mode])); notify_modes[xevent->xfocus.mode]));
if (window && GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD) if (toplevel)
{ {
gboolean had_focus = HAS_FOCUS (window_impl); gboolean had_focus = HAS_FOCUS (toplevel);
switch (xevent->xfocus.detail) switch (xevent->xfocus.detail)
{ {
@ -1274,13 +1271,13 @@ gdk_event_translate (GdkDisplay *display,
case NotifyNonlinear: case NotifyNonlinear:
case NotifyVirtual: case NotifyVirtual:
case NotifyNonlinearVirtual: case NotifyNonlinearVirtual:
window_impl->has_focus_window = TRUE; toplevel->has_focus_window = TRUE;
/* We pretend that the focus moves to the grab /* We pretend that the focus moves to the grab
* window, so we pay attention to NotifyGrab * window, so we pay attention to NotifyGrab
* NotifyUngrab, and ignore NotifyWhileGrabbed * NotifyUngrab, and ignore NotifyWhileGrabbed
*/ */
if (xevent->xfocus.mode != NotifyWhileGrabbed) if (xevent->xfocus.mode != NotifyWhileGrabbed)
window_impl->has_focus = TRUE; toplevel->has_focus = TRUE;
break; break;
case NotifyPointer: case NotifyPointer:
/* The X server sends NotifyPointer/NotifyGrab, /* The X server sends NotifyPointer/NotifyGrab,
@ -1288,7 +1285,7 @@ gdk_event_translate (GdkDisplay *display,
* grab is in effect * grab is in effect
*/ */
if (xevent->xfocus.mode != NotifyGrab) if (xevent->xfocus.mode != NotifyGrab)
window_impl->has_pointer_focus = TRUE; toplevel->has_pointer_focus = TRUE;
break; break;
case NotifyInferior: case NotifyInferior:
case NotifyPointerRoot: case NotifyPointerRoot:
@ -1296,7 +1293,7 @@ gdk_event_translate (GdkDisplay *display,
break; break;
} }
if (HAS_FOCUS (window_impl) != had_focus) if (HAS_FOCUS (toplevel) != had_focus)
generate_focus_event (window, TRUE); generate_focus_event (window, TRUE);
} }
break; break;
@ -1307,9 +1304,9 @@ gdk_event_translate (GdkDisplay *display,
notify_details[xevent->xfocus.detail], notify_details[xevent->xfocus.detail],
notify_modes[xevent->xfocus.mode])); notify_modes[xevent->xfocus.mode]));
if (window && GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD) if (toplevel)
{ {
gboolean had_focus = HAS_FOCUS (window_impl); gboolean had_focus = HAS_FOCUS (toplevel);
switch (xevent->xfocus.detail) switch (xevent->xfocus.detail)
{ {
@ -1317,13 +1314,13 @@ gdk_event_translate (GdkDisplay *display,
case NotifyNonlinear: case NotifyNonlinear:
case NotifyVirtual: case NotifyVirtual:
case NotifyNonlinearVirtual: case NotifyNonlinearVirtual:
window_impl->has_focus_window = FALSE; toplevel->has_focus_window = FALSE;
if (xevent->xfocus.mode != NotifyWhileGrabbed) if (xevent->xfocus.mode != NotifyWhileGrabbed)
window_impl->has_focus = FALSE; toplevel->has_focus = FALSE;
break; break;
case NotifyPointer: case NotifyPointer:
if (xevent->xfocus.mode != NotifyUngrab) if (xevent->xfocus.mode != NotifyUngrab)
window_impl->has_pointer_focus = FALSE; toplevel->has_pointer_focus = FALSE;
break; break;
case NotifyInferior: case NotifyInferior:
case NotifyPointerRoot: case NotifyPointerRoot:
@ -1331,7 +1328,7 @@ gdk_event_translate (GdkDisplay *display,
break; break;
} }
if (HAS_FOCUS (window_impl) != had_focus) if (HAS_FOCUS (toplevel) != had_focus)
generate_focus_event (window, FALSE); generate_focus_event (window, FALSE);
} }
break; break;
@ -1647,8 +1644,8 @@ gdk_event_translate (GdkDisplay *display,
} }
window_private->x = event->configure.x; window_private->x = event->configure.x;
window_private->y = event->configure.y; window_private->y = event->configure.y;
GDK_WINDOW_IMPL_X11 (window_private->impl)->width = xevent->xconfigure.width; window_impl->width = xevent->xconfigure.width;
GDK_WINDOW_IMPL_X11 (window_private->impl)->height = xevent->xconfigure.height; window_impl->height = xevent->xconfigure.height;
if (window_private->resize_count >= 1) if (window_private->resize_count >= 1)
{ {
window_private->resize_count -= 1; window_private->resize_count -= 1;
@ -1677,7 +1674,8 @@ gdk_event_translate (GdkDisplay *display,
/* We compare with the serial of the last time we mapped the /* We compare with the serial of the last time we mapped the
* window to avoid refetching properties that we set ourselves * window to avoid refetching properties that we set ourselves
*/ */
if (xevent->xproperty.serial >= GDK_WINDOW_IMPL_X11 (window_private->impl)->map_serial) if (toplevel &&
xevent->xproperty.serial >= toplevel->map_serial)
{ {
if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE")) if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
gdk_check_wm_state_changed (window); gdk_check_wm_state_changed (window);
@ -1906,15 +1904,15 @@ gdk_wm_protocols_filter (GdkXEvent *xev,
} }
else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS")) else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
{ {
GdkWindow *win = event->any.window; GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *)win)->impl);
/* There is no way of knowing reliably whether we are viewable; /* There is no way of knowing reliably whether we are viewable;
* _gdk_x11_set_input_focus_safe() traps errors asynchronously. * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
*/ */
_gdk_x11_set_input_focus_safe (display, impl->focus_window, if (toplevel)
RevertToParent, _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
xevent->xclient.data.l[1]); RevertToParent,
xevent->xclient.data.l[1]);
} }
else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING") && else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING") &&
!_gdk_x11_display_is_root_window (display, !_gdk_x11_display_is_root_window (display,

View File

@ -142,6 +142,26 @@ gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
impl->height = 1; impl->height = 1;
} }
GdkToplevelX11 *
_gdk_x11_window_get_toplevel (GdkWindow *window)
{
GdkWindowObject *private;
GdkWindowImplX11 *impl;
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
return NULL;
private = (GdkWindowObject *)window;
impl = GDK_WINDOW_IMPL_X11 (private->impl);
if (!impl->toplevel)
impl->toplevel = g_new0 (GdkToplevelX11, 1);
return impl->toplevel;
}
static void static void
gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
{ {
@ -180,10 +200,13 @@ gdk_window_impl_x11_finalize (GObject *object)
if (!GDK_WINDOW_DESTROYED (wrapper)) if (!GDK_WINDOW_DESTROYED (wrapper))
{ {
_gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), draw_impl->xid); _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), draw_impl->xid);
if (window_impl->focus_window) if (window_impl->toplevel && window_impl->toplevel->focus_window)
_gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), window_impl->focus_window); _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), window_impl->toplevel->focus_window);
} }
if (window_impl->toplevel)
g_free (window_impl->toplevel);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -379,6 +402,7 @@ gdk_window_new (GdkWindow *parent,
GdkWindowObject *private; GdkWindowObject *private;
GdkWindowImplX11 *impl; GdkWindowImplX11 *impl;
GdkDrawableImplX11 *draw_impl; GdkDrawableImplX11 *draw_impl;
GdkToplevelX11 *toplevel;
GdkScreenX11 *screen_x11; GdkScreenX11 *screen_x11;
GdkScreen *screen; GdkScreen *screen;
@ -625,22 +649,24 @@ gdk_window_new (GdkWindow *parent,
return window; return window;
} }
toplevel = _gdk_x11_window_get_toplevel (window);
if (class != InputOnly) if (class != InputOnly)
{ {
/* The focus window is off the visible area, and serves to receive key /* The focus window is off the visible area, and serves to receive key
* press events so they don't get sent to child windows. * press events so they don't get sent to child windows.
*/ */
impl->focus_window = XCreateSimpleWindow (xdisplay, xid, toplevel->focus_window = XCreateSimpleWindow (xdisplay, xid,
-1, -1, 1, 1, 0, -1, -1, 1, 1, 0,
xattributes.background_pixel, xattributes.background_pixel,
xattributes.background_pixel); xattributes.background_pixel);
/* FIXME: probably better to actually track the requested event mask for the toplevel /* FIXME: probably better to actually track the requested event mask for the toplevel
*/ */
XSelectInput (xdisplay, impl->focus_window, XSelectInput (xdisplay, toplevel->focus_window,
KeyPressMask | KeyReleaseMask | FocusChangeMask); KeyPressMask | KeyReleaseMask | FocusChangeMask);
XMapWindow (xdisplay, impl->focus_window); XMapWindow (xdisplay, toplevel->focus_window);
_gdk_xid_table_insert (screen_x11->display, &impl->focus_window, window); _gdk_xid_table_insert (screen_x11->display, &toplevel->focus_window, window);
} }
size_hints.flags = PSize; size_hints.flags = PSize;
@ -832,43 +858,49 @@ gdk_window_lookup (GdkNativeWindow anid)
return (GdkWindow*) gdk_xid_table_lookup (anid); return (GdkWindow*) gdk_xid_table_lookup (anid);
} }
static void
gdk_toplevel_x11_free_contents (GdkToplevelX11 *toplevel)
{
if (toplevel->icon_window)
{
g_object_unref (toplevel->icon_window);
toplevel->icon_window = NULL;
}
if (toplevel->icon_pixmap)
{
g_object_unref (toplevel->icon_pixmap);
toplevel->icon_pixmap = NULL;
}
if (toplevel->icon_mask)
{
g_object_unref (toplevel->icon_mask);
toplevel->icon_mask = NULL;
}
if (toplevel->group_leader)
{
g_object_unref (toplevel->group_leader);
toplevel->group_leader = NULL;
}
}
void void
_gdk_windowing_window_destroy (GdkWindow *window, _gdk_windowing_window_destroy (GdkWindow *window,
gboolean recursing, gboolean recursing,
gboolean foreign_destroy) gboolean foreign_destroy)
{ {
GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *private = (GdkWindowObject *)window;
GdkWindowImplX11 *window_impl; GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
window_impl = GDK_WINDOW_IMPL_X11 (private->impl);
_gdk_selection_window_destroyed (window); _gdk_selection_window_destroyed (window);
if (private->extension_events != 0) if (private->extension_events != 0)
_gdk_input_window_destroy (window); _gdk_input_window_destroy (window);
if (window_impl->icon_window) toplevel = _gdk_x11_window_get_toplevel (window);
{ if (toplevel)
g_object_unref (window_impl->icon_window); gdk_toplevel_x11_free_contents (toplevel);
window_impl->icon_window = NULL;
}
if (window_impl->icon_pixmap)
{
g_object_unref (window_impl->icon_pixmap);
window_impl->icon_pixmap = NULL;
}
if (window_impl->icon_mask)
{
g_object_unref (window_impl->icon_mask);
window_impl->icon_mask = NULL;
}
if (window_impl->group_leader)
{
g_object_unref (window_impl->group_leader);
window_impl->group_leader = NULL;
}
#ifdef HAVE_XFT #ifdef HAVE_XFT
{ {
@ -943,8 +975,8 @@ gdk_window_destroy_notify (GdkWindow *window)
} }
_gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window)); _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window));
if (window_impl->focus_window) if (window_impl->toplevel && window_impl->toplevel->focus_window)
_gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), window_impl->focus_window); _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), window_impl->toplevel->focus_window);
_gdk_xgrab_check_destroy (window); _gdk_xgrab_check_destroy (window);
@ -955,8 +987,8 @@ static void
update_wm_hints (GdkWindow *window, update_wm_hints (GdkWindow *window,
gboolean force) gboolean force)
{ {
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *private = (GdkWindowObject *)window;
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
GdkDisplay *display = GDK_WINDOW_DISPLAY (window); GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
XWMHints wm_hints; XWMHints wm_hints;
@ -974,29 +1006,29 @@ update_wm_hints (GdkWindow *window,
wm_hints.initial_state = IconicState; wm_hints.initial_state = IconicState;
} }
if (impl->icon_window && !GDK_WINDOW_DESTROYED (impl->icon_window)) if (toplevel->icon_window && !GDK_WINDOW_DESTROYED (toplevel->icon_window))
{ {
wm_hints.flags |= IconWindowHint; wm_hints.flags |= IconWindowHint;
wm_hints.icon_window = GDK_WINDOW_XID (impl->icon_window); wm_hints.icon_window = GDK_WINDOW_XID (toplevel->icon_window);
} }
if (impl->icon_pixmap) if (toplevel->icon_pixmap)
{ {
wm_hints.flags |= IconPixmapHint; wm_hints.flags |= IconPixmapHint;
wm_hints.icon_pixmap = GDK_PIXMAP_XID (impl->icon_pixmap); wm_hints.icon_pixmap = GDK_PIXMAP_XID (toplevel->icon_pixmap);
} }
if (impl->icon_mask) if (toplevel->icon_mask)
{ {
wm_hints.flags |= IconMaskHint; wm_hints.flags |= IconMaskHint;
wm_hints.icon_mask = GDK_PIXMAP_XID (impl->icon_mask); wm_hints.icon_mask = GDK_PIXMAP_XID (toplevel->icon_mask);
} }
wm_hints.flags |= WindowGroupHint; wm_hints.flags |= WindowGroupHint;
if (impl->group_leader && !GDK_WINDOW_DESTROYED (impl->group_leader)) if (toplevel->group_leader && !GDK_WINDOW_DESTROYED (toplevel->group_leader))
{ {
wm_hints.flags |= WindowGroupHint; wm_hints.flags |= WindowGroupHint;
wm_hints.window_group = GDK_WINDOW_XID (impl->group_leader); wm_hints.window_group = GDK_WINDOW_XID (toplevel->group_leader);
} }
else else
wm_hints.window_group = GDK_DISPLAY_X11 (display)->leader_window; wm_hints.window_group = GDK_DISPLAY_X11 (display)->leader_window;
@ -1013,12 +1045,15 @@ set_initial_hints (GdkWindow *window)
Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
Window xwindow = GDK_WINDOW_XID (window); Window xwindow = GDK_WINDOW_XID (window);
GdkWindowObject *private; GdkWindowObject *private;
GdkWindowImplX11 *impl; GdkToplevelX11 *toplevel;
Atom atoms[7]; Atom atoms[7];
gint i; gint i;
private = (GdkWindowObject*) window; private = (GdkWindowObject*) window;
impl = GDK_WINDOW_IMPL_X11 (private->impl); toplevel = _gdk_x11_window_get_toplevel (window);
if (!toplevel)
return;
update_wm_hints (window, TRUE); update_wm_hints (window, TRUE);
@ -1060,14 +1095,14 @@ set_initial_hints (GdkWindow *window)
++i; ++i;
} }
if (impl->skip_taskbar_hint) if (toplevel->skip_taskbar_hint)
{ {
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
"_NET_WM_STATE_SKIP_TASKBAR"); "_NET_WM_STATE_SKIP_TASKBAR");
++i; ++i;
} }
if (impl->skip_pager_hint) if (toplevel->skip_pager_hint)
{ {
atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
"_NET_WM_STATE_SKIP_PAGER"); "_NET_WM_STATE_SKIP_PAGER");
@ -1104,6 +1139,8 @@ set_initial_hints (GdkWindow *window)
xwindow, xwindow,
gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP")); gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"));
} }
toplevel->map_serial = NextRequest (xdisplay);
} }
static void static void
@ -1117,7 +1154,7 @@ show_window_internal (GdkWindow *window,
private = (GdkWindowObject*) window; private = (GdkWindowObject*) window;
if (!private->destroyed) if (!private->destroyed)
{ {
GdkWindowImplX11 *impl =GDK_WINDOW_IMPL_X11 (private->impl); GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
Display *xdisplay = GDK_WINDOW_XDISPLAY (window); Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
Window xwindow = GDK_WINDOW_XID (window); Window xwindow = GDK_WINDOW_XID (window);
@ -1131,8 +1168,6 @@ show_window_internal (GdkWindow *window,
gdk_synthesize_window_state (window, gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_WITHDRAWN, GDK_WINDOW_STATE_WITHDRAWN,
0); 0);
impl->map_serial = NextRequest (xdisplay);
} }
g_assert (GDK_WINDOW_IS_MAPPED (window)); g_assert (GDK_WINDOW_IS_MAPPED (window));
@ -1488,12 +1523,20 @@ gdk_window_reparent (GdkWindow *window,
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
{ {
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
/* If we were being sophisticated, we'd save the old window type /* If we were being sophisticated, we'd save the old window type
* here, and restore it if we were reparented back to the * here, and restore it if we were reparented back to the
* toplevel. However, the difference between different types * toplevel. However, the difference between different types
* of toplevels only really matters on creation anyways. * of toplevels only really matters on creation anyways.
*/ */
GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD; GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
if (impl->toplevel)
{
gdk_toplevel_x11_free_contents (impl->toplevel);
g_free (impl->toplevel);
impl->toplevel = NULL;
}
} }
} }
@ -1863,19 +1906,17 @@ void
gdk_window_set_skip_taskbar_hint (GdkWindow *window, gdk_window_set_skip_taskbar_hint (GdkWindow *window,
gboolean skips_taskbar) gboolean skips_taskbar)
{ {
GdkWindowObject *private; GdkToplevelX11 *toplevel;
GdkWindowImplX11 *impl;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
private = (GdkWindowObject*) window; toplevel = _gdk_x11_window_get_toplevel (window);
impl = GDK_WINDOW_IMPL_X11 (private->impl); toplevel->skip_taskbar_hint = skips_taskbar;
impl->skip_taskbar_hint = skips_taskbar;
if (GDK_WINDOW_IS_MAPPED (window)) if (GDK_WINDOW_IS_MAPPED (window))
gdk_wmspec_change_state (skips_taskbar, window, gdk_wmspec_change_state (skips_taskbar, window,
@ -1902,19 +1943,17 @@ void
gdk_window_set_skip_pager_hint (GdkWindow *window, gdk_window_set_skip_pager_hint (GdkWindow *window,
gboolean skips_pager) gboolean skips_pager)
{ {
GdkWindowObject *private; GdkToplevelX11 *toplevel;
GdkWindowImplX11 *impl;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
private = (GdkWindowObject*) window; toplevel = _gdk_x11_window_get_toplevel (window);
impl = GDK_WINDOW_IMPL_X11 (private->impl); toplevel->skip_pager_hint = skips_pager;
impl->skip_pager_hint = skips_pager;
if (GDK_WINDOW_IS_MAPPED (window)) if (GDK_WINDOW_IS_MAPPED (window))
gdk_wmspec_change_state (skips_pager, window, gdk_wmspec_change_state (skips_pager, window,
@ -3330,37 +3369,36 @@ gdk_window_set_icon (GdkWindow *window,
GdkPixmap *pixmap, GdkPixmap *pixmap,
GdkBitmap *mask) GdkBitmap *mask)
{ {
GdkWindowObject *private; GdkToplevelX11 *toplevel;
GdkWindowImplX11 *impl;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
private = (GdkWindowObject *)window; toplevel = _gdk_x11_window_get_toplevel (window);
impl = GDK_WINDOW_IMPL_X11 (private->impl);
if (impl->icon_window != icon_window) if (toplevel->icon_window != icon_window)
{ {
if (impl->icon_window) if (toplevel->icon_window)
g_object_unref (impl->icon_window); g_object_unref (toplevel->icon_window);
impl->icon_window = g_object_ref (icon_window); toplevel->icon_window = g_object_ref (icon_window);
} }
if (impl->icon_pixmap != pixmap) if (toplevel->icon_pixmap != pixmap)
{ {
if (impl->icon_pixmap) if (toplevel->icon_pixmap)
g_object_unref (impl->icon_pixmap); g_object_unref (toplevel->icon_pixmap);
impl->icon_pixmap = g_object_ref (pixmap); toplevel->icon_pixmap = g_object_ref (pixmap);
} }
if (impl->icon_mask != mask) if (toplevel->icon_mask != mask)
{ {
if (impl->icon_mask) if (toplevel->icon_mask)
g_object_unref (impl->icon_mask); g_object_unref (toplevel->icon_mask);
impl->icon_mask = g_object_ref (mask); toplevel->icon_mask = g_object_ref (mask);
} }
update_wm_hints (window, FALSE); update_wm_hints (window, FALSE);
@ -3791,25 +3829,24 @@ void
gdk_window_set_group (GdkWindow *window, gdk_window_set_group (GdkWindow *window,
GdkWindow *leader) GdkWindow *leader)
{ {
GdkWindowObject *private; GdkToplevelX11 *toplevel;
GdkWindowImplX11 *impl;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
g_return_if_fail (leader != NULL); g_return_if_fail (leader != NULL);
g_return_if_fail (GDK_IS_WINDOW (leader)); g_return_if_fail (GDK_IS_WINDOW (leader));
toplevel = _gdk_x11_window_get_toplevel (window);
if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader)) if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
return; return;
private = (GdkWindowObject *)window; if (toplevel->group_leader != leader)
impl = GDK_WINDOW_IMPL_X11 (private->impl);
if (impl->group_leader != leader)
{ {
if (impl->group_leader) if (toplevel->group_leader)
g_object_unref (impl->group_leader); g_object_unref (toplevel->group_leader);
impl->group_leader = g_object_ref (impl->group_leader); toplevel->group_leader = g_object_ref (toplevel->group_leader);
} }
update_wm_hints (window, FALSE); update_wm_hints (window, FALSE);

View File

@ -29,11 +29,12 @@
#include <gdk/x11/gdkdrawable-x11.h> #include <gdk/x11/gdkdrawable-x11.h>
#ifdef __cplusplus G_BEGIN_DECLS
extern "C" {
#endif /* __cplusplus */
typedef struct _GdkXPositionInfo GdkXPositionInfo; typedef struct _GdkToplevelX11 GdkToplevelX11;
typedef struct _GdkWindowImplX11 GdkWindowImplX11;
typedef struct _GdkWindowImplX11Class GdkWindowImplX11Class;
typedef struct _GdkXPositionInfo GdkXPositionInfo;
struct _GdkXPositionInfo struct _GdkXPositionInfo
{ {
@ -54,9 +55,6 @@ struct _GdkXPositionInfo
/* Window implementation for X11 /* Window implementation for X11
*/ */
typedef struct _GdkWindowImplX11 GdkWindowImplX11;
typedef struct _GdkWindowImplX11Class GdkWindowImplX11Class;
#define GDK_TYPE_WINDOW_IMPL_X11 (gdk_window_impl_x11_get_type ()) #define GDK_TYPE_WINDOW_IMPL_X11 (gdk_window_impl_x11_get_type ())
#define GDK_WINDOW_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11)) #define GDK_WINDOW_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11))
#define GDK_WINDOW_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11Class)) #define GDK_WINDOW_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_X11, GdkWindowImplX11Class))
@ -72,6 +70,16 @@ struct _GdkWindowImplX11
gint height; gint height;
GdkXPositionInfo position_info; GdkXPositionInfo position_info;
GdkToplevelX11 *toplevel; /* Toplevel-specific information */
};
struct _GdkWindowImplX11Class
{
GdkDrawableImplX11Class parent_class;
};
struct _GdkToplevelX11
{
/* Set if the window, or any descendent of it, is the server's focus window /* Set if the window, or any descendent of it, is the server's focus window
*/ */
@ -111,17 +119,11 @@ struct _GdkWindowImplX11
*/ */
Window focus_window; Window focus_window;
}; };
struct _GdkWindowImplX11Class
{
GdkDrawableImplX11Class parent_class;
};
GType gdk_window_impl_x11_get_type (void); GType gdk_window_impl_x11_get_type (void);
#ifdef __cplusplus GdkToplevelX11 *_gdk_x11_window_get_toplevel (GdkWindow *window);
}
#endif /* __cplusplus */ G_END_DECLS
#endif /* __GDK_WINDOW_X11_H__ */ #endif /* __GDK_WINDOW_X11_H__ */