[gtk+] x11: Reduce uses of the root window
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Reduce uses of the root window
- Date: Fri, 10 Nov 2017 03:53:11 +0000 (UTC)
commit bdb442be21471a91820219347b1345ed7b84d034
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Nov 9 18:40:16 2017 -0500
x11: Reduce uses of the root window
Avoid calling the get_root_window api that returns
a GdkWindow in some places, and instead use the X
root window directly.
gdk/x11/gdkcursor-x11.c | 7 +---
gdk/x11/gdkdevice-core-x11.c | 27 +++++++++++------
gdk/x11/gdkdevice-xi2.c | 43 +++++++++++++++------------
gdk/x11/gdkdevicemanager-xi2.c | 2 +-
gdk/x11/gdkdnd-x11.c | 61 +++++++++++++++++-----------------------
gdk/x11/gdkeventsource.c | 12 ++++++++
gdk/x11/gdkprivate-x11.h | 23 ++++++++++++--
gdk/x11/gdkproperty-x11.c | 29 +++++++++++--------
gdk/x11/gdkscreen-x11.c | 6 +--
gdk/x11/gdkwindow-x11.c | 26 ++++++++---------
10 files changed, 132 insertions(+), 104 deletions(-)
---
diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c
index c0fc7fd..9033d1f 100644
--- a/gdk/x11/gdkcursor-x11.c
+++ b/gdk/x11/gdkcursor-x11.c
@@ -78,7 +78,7 @@ get_blank_cursor (GdkDisplay *display)
cairo_surface_t *surface;
cairo_t *cr;
- surface = _gdk_x11_window_create_bitmap_surface (gdk_x11_display_get_root_window (display), 1, 1);
+ surface = _gdk_x11_display_create_bitmap_surface (display, 1, 1);
/* Clear surface */
cr = cairo_create (surface);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
@@ -305,13 +305,10 @@ _gdk_x11_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
- GdkWindow *window;
-
g_return_if_fail (GDK_IS_DISPLAY (display));
- window = gdk_x11_display_get_root_window (display);
XQueryBestCursor (GDK_DISPLAY_XDISPLAY (display),
- GDK_WINDOW_XID (window),
+ GDK_SCREEN_XROOTWIN (GDK_X11_DISPLAY (display)->screen),
128, 128, width, height);
}
diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c
index 91515dd..6176f6c 100644
--- a/gdk/x11/gdkdevice-core-x11.c
+++ b/gdk/x11/gdkdevice-core-x11.c
@@ -242,7 +242,7 @@ gdk_x11_device_core_warp (GdkDevice *device,
display = gdk_device_get_display (device);
xdisplay = GDK_DISPLAY_XDISPLAY (display);
screen = GDK_X11_DISPLAY (display)->screen;
- dest = GDK_WINDOW_XID (gdk_x11_display_get_root_window (display));
+ dest = GDK_SCREEN_XROOTWIN (screen);
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
round (x * GDK_X11_SCREEN (screen)->window_scale),
@@ -259,22 +259,30 @@ gdk_x11_device_core_query_state (GdkDevice *device,
gdouble *win_y,
GdkModifierType *mask)
{
- GdkWindowImplX11 *impl;
GdkDisplay *display;
GdkScreen *screen;
+ Window xwindow, w;
Window xroot_window, xchild_window;
int xroot_x, xroot_y, xwin_x, xwin_y;
unsigned int xmask;
+ int scale;
display = gdk_device_get_display (device);
screen = GDK_X11_DISPLAY (display)->screen;
if (window == NULL)
- window = gdk_x11_display_get_root_window (display);
- impl = GDK_WINDOW_IMPL_X11 (window->impl);
+ {
+ xwindow = GDK_SCREEN_XROOTWIN (screen);
+ scale = GDK_X11_SCREEN (screen)->window_scale;
+ }
+ else
+ {
+ xwindow = GDK_WINDOW_XID (window);
+ scale = GDK_WINDOW_IMPL_X11 (window->impl)->window_scale;
+ }
if (!GDK_X11_DISPLAY (display)->trusted_client ||
!XQueryPointer (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
+ xwindow,
&xroot_window,
&xchild_window,
&xroot_x, &xroot_y,
@@ -283,7 +291,6 @@ gdk_x11_device_core_query_state (GdkDevice *device,
{
XSetWindowAttributes attributes;
Display *xdisplay;
- Window xwindow, w;
/* FIXME: untrusted clients not multidevice-safe */
xdisplay = GDK_SCREEN_XDISPLAY (screen);
@@ -305,16 +312,16 @@ gdk_x11_device_core_query_state (GdkDevice *device,
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
- *root_x = (double)xroot_x / impl->window_scale;
+ *root_x = (double)xroot_x / scale;
if (root_y)
- *root_y = (double)xroot_y / impl->window_scale;
+ *root_y = (double)xroot_y / scale;
if (win_x)
- *win_x = (double)xwin_x / impl->window_scale;
+ *win_x = (double)xwin_x / scale;
if (win_y)
- *win_y = (double)xwin_y / impl->window_scale;
+ *win_y = (double)xwin_y / scale;
if (mask)
*mask = xmask;
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 90dc1a0..78f2782 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -212,8 +212,10 @@ gdk_x11_device_xi2_get_state (GdkDevice *device,
GdkDisplay *display;
XIDeviceInfo *info;
gint i, j, ndevices;
+ Screen *xscreen;
display = gdk_device_get_display (device);
+ xscreen = GDK_X11_SCREEN (GDK_X11_DISPLAY (display)->screen)->xscreen;
gdk_x11_display_error_trap_push (display);
info = XIQueryDevice (GDK_DISPLAY_XDISPLAY (display),
@@ -241,16 +243,14 @@ gdk_x11_device_xi2_get_state (GdkDevice *device,
_gdk_device_translate_window_coord (device, window, j, value, &axes[j]);
else
{
- GdkWindow *root_window;
gint root_x, root_y;
- root_window = gdk_x11_display_get_root_window (gdk_window_get_display (window));
/* FIXME: Maybe root coords chaching should happen here */
gdk_window_get_origin (window, &root_x, &root_y);
_gdk_device_translate_screen_coord (device, window,
root_x, root_y,
- gdk_window_get_width (root_window),
- gdk_window_get_height (root_window),
+ WidthOfScreen (xscreen),
+ HeightOfScreen (xscreen),
j, value,
&axes[j]);
}
@@ -303,18 +303,16 @@ gdk_x11_device_xi2_warp (GdkDevice *device,
gdouble y)
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
- Window dest;
GdkDisplay *display = gdk_device_get_display (device);
GdkScreen *screen = GDK_X11_DISPLAY (display)->screen;
-
- dest = GDK_WINDOW_XID (gdk_x11_display_get_root_window (display));
+ Window dest = GDK_DISPLAY_XROOTWIN (display);
XIWarpPointer (GDK_SCREEN_XDISPLAY (screen),
device_xi2->device_id,
None, dest,
0, 0, 0, 0,
- round (x * GDK_X11_SCREEN(screen)->window_scale),
- round (y * GDK_X11_SCREEN(screen)->window_scale));
+ round (x * GDK_X11_SCREEN (screen)->window_scale),
+ round (y * GDK_X11_SCREEN (screen)->window_scale));
}
static void
@@ -327,21 +325,28 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
gdouble *win_y,
GdkModifierType *mask)
{
- GdkWindowImplX11 *impl;
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display;
GdkScreen *default_screen;
- Window xroot_window, xchild_window;
+ Window xroot_window, xchild_window, xwindow;
gdouble xroot_x, xroot_y, xwin_x, xwin_y;
XIButtonState button_state;
XIModifierState mod_state;
XIGroupState group_state;
+ int scale;
display = gdk_device_get_display (device);
default_screen = GDK_X11_DISPLAY (display)->screen;
if (window == NULL)
- window = gdk_x11_display_get_root_window (display);
- impl = GDK_WINDOW_IMPL_X11 (window->impl);
+ {
+ xwindow = GDK_DISPLAY_XROOTWIN (display);
+ scale = GDK_X11_SCREEN (default_screen)->window_scale;
+ }
+ else
+ {
+ xwindow = GDK_WINDOW_XID (window);
+ scale = GDK_WINDOW_IMPL_X11 (window->impl)->window_scale;
+ }
if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE)
{
@@ -356,7 +361,7 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
if (!GDK_X11_DISPLAY (display)->trusted_client ||
!XIQueryPointer (GDK_WINDOW_XDISPLAY (window),
device_xi2->device_id,
- GDK_WINDOW_XID (window),
+ xwindow,
&xroot_window,
&xchild_window,
&xroot_x, &xroot_y,
@@ -367,7 +372,7 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
{
XSetWindowAttributes attributes;
Display *xdisplay;
- Window xwindow, w;
+ Window w;
/* FIXME: untrusted clients not multidevice-safe */
xdisplay = GDK_SCREEN_XDISPLAY (default_screen);
@@ -392,16 +397,16 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
- *root_x = xroot_x / impl->window_scale;
+ *root_x = xroot_x / scale;
if (root_y)
- *root_y = xroot_y / impl->window_scale;
+ *root_y = xroot_y / scale;
if (win_x)
- *win_x = xwin_x / impl->window_scale;
+ *win_x = xwin_x / scale;
if (win_y)
- *win_y = xwin_y / impl->window_scale;
+ *win_y = xwin_y / scale;
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 165c8d5..0a19caa 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -744,7 +744,7 @@ gdk_x11_device_manager_xi2_constructed (GObject *object)
event_mask.mask = mask;
_gdk_x11_device_manager_xi2_select_events (GDK_DEVICE_MANAGER (object),
- GDK_WINDOW_XID (gdk_x11_display_get_root_window (display)),
+ GDK_DISPLAY_XROOTWIN (display),
&event_mask);
}
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index d64706b..71e8c29 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -26,6 +26,7 @@
#include "gdkx11dnd.h"
#include "gdkdndprivate.h"
+#include "gdkdeviceprivate.h"
#include "gdkmain.h"
#include "gdkinternals.h"
@@ -61,13 +62,13 @@ typedef struct {
cairo_region_t *shape;
} GdkCacheChild;
-typedef struct {
+struct _GdkWindowCache {
GList *children;
GHashTable *child_hash;
guint old_event_mask;
GdkDisplay *display;
gint ref_count;
-} GdkWindowCache;
+};
struct _GdkX11DragContext
@@ -141,7 +142,6 @@ static GrabKey grab_keys[] = {
/* Forward declarations */
-static GdkWindowCache *gdk_window_cache_get (GdkDisplay *display);
static GdkWindowCache *gdk_window_cache_ref (GdkWindowCache *cache);
static void gdk_window_cache_unref (GdkWindowCache *cache);
@@ -402,7 +402,7 @@ gdk_window_cache_add (GdkWindowCache *cache,
cache->children);
}
-static GdkFilterReturn
+GdkFilterReturn
gdk_window_cache_shape_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
@@ -437,7 +437,7 @@ gdk_window_cache_shape_filter (GdkXEvent *xev,
return GDK_FILTER_CONTINUE;
}
-static GdkFilterReturn
+GdkFilterReturn
gdk_window_cache_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
@@ -564,7 +564,7 @@ gdk_window_cache_new (GdkDisplay *display)
XWindowAttributes xwa;
GdkScreen *screen = GDK_X11_DISPLAY (display)->screen;
Display *xdisplay = GDK_SCREEN_XDISPLAY (screen);
- GdkWindow *root_window = gdk_x11_display_get_root_window (display);
+ Window xroot_window = GDK_DISPLAY_XROOTWIN (display);
GdkChildInfoX11 *children;
guint nchildren, i;
#ifdef HAVE_XCOMPOSITE
@@ -578,7 +578,7 @@ gdk_window_cache_new (GdkDisplay *display)
result->display = display;
result->ref_count = 1;
- XGetWindowAttributes (xdisplay, GDK_WINDOW_XID (root_window), &xwa);
+ XGetWindowAttributes (xdisplay, xroot_window, &xwa);
result->old_event_mask = xwa.your_event_mask;
if (G_UNLIKELY (!GDK_X11_DISPLAY (display)->trusted_client))
@@ -604,13 +604,10 @@ gdk_window_cache_new (GdkDisplay *display)
return result;
}
- XSelectInput (xdisplay, GDK_WINDOW_XID (root_window),
- result->old_event_mask | SubstructureNotifyMask);
- gdk_window_add_filter (root_window, gdk_window_cache_filter, result);
- gdk_window_add_filter (NULL, gdk_window_cache_shape_filter, result);
+ XSelectInput (xdisplay, xroot_window, result->old_event_mask | SubstructureNotifyMask);
if (!_gdk_x11_get_window_child_info (display,
- GDK_WINDOW_XID (root_window),
+ xroot_window,
FALSE, NULL,
&children, &nchildren))
return result;
@@ -634,12 +631,12 @@ gdk_window_cache_new (GdkDisplay *display)
*/
if (gdk_display_is_composited (display))
{
- cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
- gdk_window_cache_add (result, cow, 0, 0,
- gdk_window_get_width (root_window) * GDK_X11_SCREEN(screen)->window_scale,
- gdk_window_get_height (root_window) * GDK_X11_SCREEN(screen)->window_scale,
+ cow = XCompositeGetOverlayWindow (xdisplay, xroot_window);
+ gdk_window_cache_add (result, cow, 0, 0,
+ WidthOfScreen (GDK_X11_SCREEN (screen)->xscreen) * GDK_X11_SCREEN
(screen)->window_scale,
+ HeightOfScreen (GDK_X11_SCREEN (screen)->xscreen) * GDK_X11_SCREEN
(screen)->window_scale,
TRUE);
- XCompositeReleaseOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
+ XCompositeReleaseOverlayWindow (xdisplay, xroot_window);
}
#endif
@@ -649,13 +646,9 @@ gdk_window_cache_new (GdkDisplay *display)
static void
gdk_window_cache_destroy (GdkWindowCache *cache)
{
- GdkWindow *root_window = gdk_x11_display_get_root_window (cache->display);
-
- XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
- GDK_WINDOW_XID (root_window),
+ XSelectInput (GDK_DISPLAY_XDISPLAY (cache->display),
+ GDK_DISPLAY_XROOTWIN (cache->display),
cache->old_event_mask);
- gdk_window_remove_filter (root_window, gdk_window_cache_filter, cache);
- gdk_window_remove_filter (NULL, gdk_window_cache_shape_filter, cache);
gdk_x11_display_error_trap_push (cache->display);
g_list_foreach (cache->children, (GFunc)free_cache_child, cache->display);
@@ -858,7 +851,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
if (retval)
return retval;
else
- return GDK_WINDOW_XID (gdk_x11_display_get_root_window (cache->display));
+ return GDK_DISPLAY_XROOTWIN (display);
}
#ifdef G_ENABLE_DEBUG
@@ -2670,7 +2663,7 @@ drag_context_grab (GdkDragContext *context)
GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context);
GdkDevice *device = gdk_drag_context_get_device (context);
GdkSeatCapabilities capabilities;
- GdkWindow *root;
+ Window root;
GdkSeat *seat;
gint keycode, i;
GdkCursor *cursor;
@@ -2678,7 +2671,7 @@ drag_context_grab (GdkDragContext *context)
if (!x11_context->ipc_window)
return FALSE;
- root = gdk_x11_display_get_root_window (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
+ root = GDK_DISPLAY_XROOTWIN (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
seat = gdk_device_get_seat (gdk_drag_context_get_device (context));
#ifdef XINPUT_2
@@ -2730,7 +2723,7 @@ drag_context_grab (GdkDragContext *context)
XIGrabKeycode (GDK_WINDOW_XDISPLAY (x11_context->ipc_window),
deviceid,
keycode,
- GDK_WINDOW_XID (root),
+ root,
GrabModeAsync,
GrabModeAsync,
False,
@@ -2743,7 +2736,7 @@ drag_context_grab (GdkDragContext *context)
{
XGrabKey (GDK_WINDOW_XDISPLAY (x11_context->ipc_window),
keycode, grab_keys[i].modifiers,
- GDK_WINDOW_XID (root),
+ root,
FALSE,
GrabModeAsync,
GrabModeAsync);
@@ -2758,7 +2751,7 @@ drag_context_ungrab (GdkDragContext *context)
{
GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context);
GdkDevice *keyboard;
- GdkWindow *root;
+ Window root;
gint keycode, i;
if (!x11_context->grab_seat)
@@ -2767,7 +2760,7 @@ drag_context_ungrab (GdkDragContext *context)
gdk_seat_ungrab (x11_context->grab_seat);
keyboard = gdk_seat_get_keyboard (x11_context->grab_seat);
- root = gdk_x11_display_get_root_window (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
+ root = GDK_DISPLAY_XROOTWIN (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
g_clear_object (&x11_context->grab_seat);
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
@@ -2789,7 +2782,7 @@ drag_context_ungrab (GdkDragContext *context)
XIUngrabKeycode (GDK_WINDOW_XDISPLAY (x11_context->ipc_window),
gdk_x11_device_get_id (keyboard),
keycode,
- GDK_WINDOW_XID (root),
+ root,
num_mods,
&mods);
}
@@ -2798,7 +2791,7 @@ drag_context_ungrab (GdkDragContext *context)
{
XUngrabKey (GDK_WINDOW_XDISPLAY (x11_context->ipc_window),
keycode, grab_keys[i].modifiers,
- GDK_WINDOW_XID (root));
+ root);
}
}
}
@@ -2969,7 +2962,6 @@ gdk_dnd_handle_key_event (GdkDragContext *context,
{
GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context);
GdkModifierType state;
- GdkWindow *root_window;
GdkDevice *pointer;
gint dx, dy;
@@ -3030,8 +3022,7 @@ gdk_dnd_handle_key_event (GdkDragContext *context,
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
- root_window = gdk_x11_display_get_root_window (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
- gdk_window_get_device_position (root_window, pointer, NULL, NULL, &state);
+ _gdk_device_query_state (pointer, NULL, NULL, NULL, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 80635bf..512ccb1 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -273,6 +273,7 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
GdkWindow *filter_window;
Display *dpy;
GdkX11Screen *x11_screen;
+ gpointer cache;
x11_screen = (GdkX11Screen *) gdk_x11_display_get_screen (event_source->display);
@@ -299,6 +300,17 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
xevent->xany.window == x11_screen->xsettings_manager_window)
result = gdk_xsettings_manager_window_filter (xevent, event, x11_screen);
+ cache = gdk_window_cache_get (event_source->display);
+ if (cache)
+ {
+ if (result == GDK_FILTER_CONTINUE)
+ result = gdk_window_cache_shape_filter (xevent, event, cache);
+
+ if (result == GDK_FILTER_CONTINUE &&
+ xevent->xany.window == XRootWindow (dpy, 0))
+ result = gdk_window_cache_filter (xevent, event, cache);
+ }
+
/* Run default filters */
if (result == GDK_FILTER_CONTINUE &&
_gdk_default_filters)
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index ade987d..48d4e85 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -258,6 +258,20 @@ _gdk_x11_dnd_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
+typedef struct _GdkWindowCache GdkWindowCache;
+
+GdkWindowCache *
+gdk_window_cache_get (GdkDisplay *display);
+
+GdkFilterReturn
+gdk_window_cache_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data);
+GdkFilterReturn
+gdk_window_cache_shape_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data);
+
void _gdk_x11_screen_init_root_window (GdkScreen *screen);
void _gdk_x11_screen_init_visuals (GdkScreen *screen,
gboolean setup_display);
@@ -278,15 +292,16 @@ gboolean _gdk_x11_get_xft_setting (GdkScreen *screen,
GdkGrabStatus _gdk_x11_convert_grab_status (gint status);
-cairo_surface_t * _gdk_x11_window_create_bitmap_surface (GdkWindow *window,
- int width,
- int height);
-
+cairo_surface_t * _gdk_x11_display_create_bitmap_surface (GdkDisplay *display,
+ int width,
+ int height);
+
extern const gint _gdk_x11_event_mask_table[];
extern const gint _gdk_x11_event_mask_table_size;
#define GDK_SCREEN_DISPLAY(screen) (GDK_X11_SCREEN (screen)->display)
#define GDK_SCREEN_XROOTWIN(screen) (GDK_X11_SCREEN (screen)->xroot_window)
+#define GDK_DISPLAY_XROOTWIN(display) (GDK_SCREEN_XROOTWIN (GDK_X11_DISPLAY (display)->screen))
#define GDK_WINDOW_SCREEN(win) (GDK_X11_DISPLAY (gdk_window_get_display (win))->screen)
#define GDK_WINDOW_DISPLAY(win) (gdk_window_get_display (win))
#define GDK_WINDOW_XROOTWIN(win) (GDK_X11_SCREEN (GDK_WINDOW_SCREEN (win))->xroot_window)
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index e4bd58f..e413d47 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -375,16 +375,18 @@ _gdk_x11_window_get_property (GdkWindow *window,
Atom xproperty;
Atom xtype;
int res;
+ Window xwindow;
g_return_val_if_fail (!window || GDK_WINDOW_IS_X11 (window), FALSE);
if (!window)
- window = gdk_x11_display_get_root_window (gdk_display_get_default ());
+ xwindow = GDK_DISPLAY_XROOTWIN (gdk_display_get_default ());
else if (!GDK_WINDOW_IS_X11 (window))
return FALSE;
-
- if (GDK_WINDOW_DESTROYED (window))
+ else if (GDK_WINDOW_DESTROYED (window))
return FALSE;
+ else
+ xwindow = GDK_WINDOW_XID (window);
display = gdk_window_get_display (window);
xproperty = gdk_x11_atom_to_xatom_for_display (display, property);
@@ -414,7 +416,7 @@ _gdk_x11_window_get_property (GdkWindow *window,
}
res = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
- GDK_WINDOW_XID (window), xproperty,
+ xwindow, xproperty,
offset, get_length, pdelete,
xtype, &ret_prop_type, &ret_format,
&ret_nitems, &ret_bytes_after,
@@ -510,12 +512,13 @@ _gdk_x11_window_change_property (GdkWindow *window,
g_return_if_fail (!window || GDK_WINDOW_IS_X11 (window));
if (!window)
- window = gdk_x11_display_get_root_window (gdk_display_get_default ());
+ xwindow = GDK_DISPLAY_XROOTWIN (gdk_display_get_default ());
else if (!GDK_WINDOW_IS_X11 (window))
return;
-
- if (GDK_WINDOW_DESTROYED (window))
+ else if (GDK_WINDOW_DESTROYED (window))
return;
+ else
+ xwindow = GDK_WINDOW_XID (window);
if (!gdk_window_has_native (window))
{
@@ -526,7 +529,6 @@ _gdk_x11_window_change_property (GdkWindow *window,
display = gdk_window_get_display (window);
xproperty = gdk_x11_atom_to_xatom_for_display (display, property);
xtype = gdk_x11_atom_to_xatom_for_display (display, type);
- xwindow = GDK_WINDOW_XID (window);
if (xtype == XA_ATOM ||
xtype == gdk_x11_get_xatom_by_name_for_display (display, "ATOM_PAIR"))
@@ -557,17 +559,20 @@ void
_gdk_x11_window_delete_property (GdkWindow *window,
GdkAtom property)
{
+ Window xwindow;
+
g_return_if_fail (!window || GDK_WINDOW_IS_X11 (window));
if (!window)
- window = gdk_x11_display_get_root_window (gdk_display_get_default ());
+ xwindow = GDK_DISPLAY_XROOTWIN (gdk_display_get_default ());
else if (!GDK_WINDOW_IS_X11 (window))
return;
-
- if (GDK_WINDOW_DESTROYED (window))
+ else if (GDK_WINDOW_DESTROYED (window))
return;
+ else
+ xwindow = GDK_WINDOW_XID (window);
- XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
+ XDeleteProperty (GDK_WINDOW_XDISPLAY (window), xwindow,
gdk_x11_atom_to_xatom_for_display (GDK_WINDOW_DISPLAY (window),
property));
}
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 814ebc2..e5c0f2c 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -200,7 +200,6 @@ gdk_x11_screen_get_work_area (GdkScreen *screen,
GdkRectangle *area)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- GdkWindow *root_window;
Atom workarea;
Atom type;
Window win;
@@ -215,14 +214,13 @@ gdk_x11_screen_get_work_area (GdkScreen *screen,
Display *display;
display = GDK_SCREEN_XDISPLAY (screen);
- root_window = gdk_x11_display_get_root_window (GDK_SCREEN_DISPLAY (screen));
workarea = XInternAtom (display, "_NET_WORKAREA", True);
/* Defaults in case of error */
area->x = 0;
area->y = 0;
- area->width = gdk_window_get_width (root_window);
- area->height = gdk_window_get_height (root_window);
+ area->width = WidthOfScreen (x11_screen->xscreen);
+ area->height = HeightOfScreen (x11_screen->xscreen);
if (!gdk_x11_screen_supports_net_wm_hint (screen,
gdk_atom_intern_static_string ("_NET_WORKAREA")))
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index a9f31fd..da3c6a5 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -578,21 +578,21 @@ attach_free_pixmap_handler (cairo_surface_t *surface,
* These functions ensure an Xlib surface.
*/
cairo_surface_t *
-_gdk_x11_window_create_bitmap_surface (GdkWindow *window,
- int width,
- int height)
+_gdk_x11_display_create_bitmap_surface (GdkDisplay *display,
+ int width,
+ int height)
{
cairo_surface_t *surface;
Pixmap pixmap;
- pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
+ pixmap = XCreatePixmap (GDK_DISPLAY_XDISPLAY (display),
+ GDK_SCREEN_XROOTWIN (GDK_X11_DISPLAY (display)->screen),
width, height, 1);
- surface = cairo_xlib_surface_create_for_bitmap (GDK_WINDOW_XDISPLAY (window),
+ surface = cairo_xlib_surface_create_for_bitmap (GDK_DISPLAY_XDISPLAY (display),
pixmap,
- GDK_X11_SCREEN (GDK_WINDOW_SCREEN (window))->xscreen,
+ GDK_X11_SCREEN (GDK_X11_DISPLAY
(display)->screen)->xscreen,
width, height);
- attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap);
+ attach_free_pixmap_handler (surface, display, pixmap);
return surface;
}
@@ -3190,9 +3190,7 @@ gdk_window_update_icon (GdkWindow *window,
cairo_surface_t *surface;
cairo_t *cr;
- toplevel->icon_pixmap = gdk_x11_window_create_pixmap_surface (window,
- width,
- height);
+ toplevel->icon_pixmap = gdk_x11_window_create_pixmap_surface (window, width, height);
surface = gdk_texture_download_surface (best_icon);
@@ -3213,9 +3211,9 @@ gdk_window_update_icon (GdkWindow *window,
if (cairo_surface_get_content (surface) == CAIRO_CONTENT_COLOR_ALPHA)
{
- toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window,
- width,
- height);
+ GdkDisplay *display = gdk_window_get_display (window);
+
+ toplevel->icon_mask = _gdk_x11_display_create_bitmap_surface (display, width, height);
cr = cairo_create (toplevel->icon_mask);
cairo_set_source_surface (cr, surface, 0, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]