Commit 1530f275 authored by Armin Krezović's avatar Armin Krezović Committed by Jonas Ådahl

Move X11 event, icon cache and property handling to MetaX11Display

https://bugzilla.gnome.org/show_bug.cgi?id=759538
parent 05899596
......@@ -687,8 +687,6 @@ meta_display_open (void)
meta_bell_init (display);
meta_display_init_events_x11 (display);
display->last_focus_time = timestamp;
display->last_user_time = timestamp;
display->compositor = NULL;
......@@ -913,9 +911,6 @@ meta_display_close (MetaDisplay *display,
if (display->compositor)
meta_compositor_destroy (display->compositor);
/* Stop caring about events */
meta_display_free_events_x11 (display);
if (display->x11_display)
{
g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0);
......
......@@ -137,9 +137,6 @@ void meta_screen_workspace_switched (MetaScreen *screen,
void meta_screen_set_active_workspace_hint (MetaScreen *screen);
gboolean meta_screen_handle_xevent (MetaScreen *screen,
XEvent *xevent);
MetaLogicalMonitor * meta_screen_xinerama_index_to_logical_monitor (MetaScreen *screen,
int index);
......
......@@ -69,9 +69,6 @@ static void set_workspace_names (MetaScreen *screen);
static void prefs_changed_callback (MetaPreference pref,
gpointer data);
static void set_desktop_geometry_hint (MetaScreen *screen);
static void set_desktop_viewport_hint (MetaScreen *screen);
enum
{
PROP_N_WORKSPACES = 1,
......@@ -250,95 +247,6 @@ meta_screen_init (MetaScreen *screen)
{
}
static int
set_wm_check_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[1];
g_return_val_if_fail (x11_display->leader_window != None, 0);
data[0] = x11_display->leader_window;
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SUPPORTING_WM_CHECK,
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
return Success;
}
static void
unset_wm_check_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
XDeleteProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SUPPORTING_WM_CHECK);
}
static int
set_supported_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
Atom atoms[] = {
#define EWMH_ATOMS_ONLY
#define item(x) x11_display->atom_##x,
#include <x11/atomnames.h>
#undef item
#undef EWMH_ATOMS_ONLY
x11_display->atom__GTK_FRAME_EXTENTS,
x11_display->atom__GTK_SHOW_WINDOW_MENU,
x11_display->atom__GTK_EDGE_CONSTRAINTS,
};
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SUPPORTED,
XA_ATOM,
32, PropModeReplace,
(guchar*) atoms, G_N_ELEMENTS(atoms));
return Success;
}
static int
set_wm_icon_size_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
#define N_VALS 6
gulong vals[N_VALS];
/* We've bumped the real icon size up to 96x96, but
* we really should not add these sorts of constraints
* on clients still using the legacy WM_HINTS interface.
*/
#define LEGACY_ICON_SIZE 32
/* min width, min height, max w, max h, width inc, height inc */
vals[0] = LEGACY_ICON_SIZE;
vals[1] = LEGACY_ICON_SIZE;
vals[2] = LEGACY_ICON_SIZE;
vals[3] = LEGACY_ICON_SIZE;
vals[4] = 0;
vals[5] = 0;
#undef LEGACY_ICON_SIZE
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom_WM_ICON_SIZE,
XA_CARDINAL,
32, PropModeReplace, (guchar*) vals, N_VALS);
return Success;
#undef N_VALS
}
static MetaScreenX11LogicalMonitorData *
get_screen_x11_logical_monitor_data (MetaLogicalMonitor *logical_monitor)
{
......@@ -505,16 +413,6 @@ meta_screen_new (MetaDisplay *display,
reload_logical_monitors (screen);
set_wm_icon_size_hint (screen);
set_supported_hint (screen);
set_wm_check_hint (screen);
set_desktop_viewport_hint (screen);
set_desktop_geometry_hint (screen);
meta_screen_update_workspace_layout (screen);
/* Screens must have at least one workspace at all times,
......@@ -586,8 +484,6 @@ meta_screen_free (MetaScreen *screen,
meta_ui_free (screen->ui);
unset_wm_check_hint (screen);
if (screen->work_area_later != 0)
meta_later_remove (screen->work_area_later);
if (screen->check_fullscreen_later != 0)
......@@ -670,55 +566,6 @@ set_number_of_spaces_hint (MetaScreen *screen,
meta_error_trap_pop (x11_display);
}
static void
set_desktop_geometry_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[2];
if (screen->closing > 0)
return;
data[0] = screen->display->rect.width;
data[1] = screen->display->rect.height;
meta_verbose ("Setting _NET_DESKTOP_GEOMETRY to %lu, %lu\n", data[0], data[1]);
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_DESKTOP_GEOMETRY,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (x11_display);
}
static void
set_desktop_viewport_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[2];
if (screen->closing > 0)
return;
/*
* Mutter does not implement viewports, so this is a fixed 0,0
*/
data[0] = 0;
data[1] = 0;
meta_verbose ("Setting _NET_DESKTOP_VIEWPORT to 0, 0\n");
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_DESKTOP_VIEWPORT,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (x11_display);
}
void
meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
guint32 timestamp)
......@@ -1768,7 +1615,6 @@ void
meta_screen_on_monitors_changed (MetaScreen *screen)
{
reload_logical_monitors (screen);
set_desktop_geometry_hint (screen);
meta_screen_queue_check_fullscreen (screen);
}
......@@ -2268,16 +2114,3 @@ meta_screen_get_monitor_in_fullscreen (MetaScreen *screen,
/* We use -1 as a flag to mean "not known yet" for notification purposes */
return logical_monitor->in_fullscreen == TRUE;
}
gboolean
meta_screen_handle_xevent (MetaScreen *screen,
XEvent *xevent)
{
MetaBackend *backend = meta_get_backend ();
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
if (meta_cursor_tracker_handle_xevent (cursor_tracker, xevent))
return TRUE;
return FALSE;
}
This diff is collapsed.
......@@ -25,7 +25,7 @@
#ifndef META_EVENTS_X11_H
#define META_EVENTS_X11_H
void meta_display_init_events_x11 (MetaDisplay *display);
void meta_display_free_events_x11 (MetaDisplay *display);
void meta_x11_display_init_events (MetaX11Display *x11_display);
void meta_x11_display_free_events (MetaX11Display *x11_display);
#endif
......@@ -189,7 +189,7 @@ argbdata_to_surface (gulong *argb_data, int w, int h)
}
static gboolean
read_rgb_icon (MetaDisplay *display,
read_rgb_icon (MetaX11Display *x11_display,
Window xwindow,
int ideal_width,
int ideal_height,
......@@ -210,16 +210,16 @@ read_rgb_icon (MetaDisplay *display,
int mini_w, mini_h;
gulong *data_as_long;
meta_error_trap_push (display->x11_display);
meta_error_trap_push (x11_display);
type = None;
data = NULL;
result = XGetWindowProperty (display->x11_display->xdisplay,
result = XGetWindowProperty (x11_display->xdisplay,
xwindow,
display->x11_display->atom__NET_WM_ICON,
x11_display->atom__NET_WM_ICON,
0, G_MAXLONG,
False, XA_CARDINAL, &type, &format, &nitems,
&bytes_after, &data);
err = meta_error_trap_pop_with_return (display->x11_display);
err = meta_error_trap_pop_with_return (x11_display);
if (err != Success ||
result != Success)
......@@ -258,11 +258,11 @@ read_rgb_icon (MetaDisplay *display,
}
static void
get_pixmap_geometry (MetaDisplay *display,
Pixmap pixmap,
int *w,
int *h,
int *d)
get_pixmap_geometry (MetaX11Display *x11_display,
Pixmap pixmap,
int *w,
int *h,
int *d)
{
Window root_ignored;
int x_ignored, y_ignored;
......@@ -277,7 +277,7 @@ get_pixmap_geometry (MetaDisplay *display,
if (d)
*d = 1;
XGetGeometry (display->x11_display->xdisplay,
XGetGeometry (x11_display->xdisplay,
pixmap, &root_ignored, &x_ignored, &y_ignored,
&width, &height, &border_width_ignored, &depth);
......@@ -328,32 +328,32 @@ surface_from_pixmap (Display *xdisplay, Pixmap xpixmap,
}
static gboolean
try_pixmap_and_mask (MetaDisplay *display,
try_pixmap_and_mask (MetaX11Display *x11_display,
Pixmap src_pixmap,
Pixmap src_mask,
cairo_surface_t **iconp)
{
Display *xdisplay = display->x11_display->xdisplay;
Display *xdisplay = x11_display->xdisplay;
cairo_surface_t *icon, *mask = NULL;
int w, h, d;
if (src_pixmap == None)
return FALSE;
meta_error_trap_push (display->x11_display);
meta_error_trap_push (x11_display);
get_pixmap_geometry (display, src_pixmap, &w, &h, &d);
get_pixmap_geometry (x11_display, src_pixmap, &w, &h, &d);
icon = surface_from_pixmap (xdisplay, src_pixmap, w, h);
if (icon && src_mask != None)
{
get_pixmap_geometry (display, src_mask, &w, &h, &d);
get_pixmap_geometry (x11_display, src_mask, &w, &h, &d);
if (d == 1)
mask = surface_from_pixmap (xdisplay, src_mask, w, h);
}
meta_error_trap_pop (display->x11_display);
meta_error_trap_pop (x11_display);
if (icon && mask)
{
......@@ -388,10 +388,10 @@ try_pixmap_and_mask (MetaDisplay *display,
}
static void
get_kwm_win_icon (MetaDisplay *display,
Window xwindow,
Pixmap *pixmap,
Pixmap *mask)
get_kwm_win_icon (MetaX11Display *x11_display,
Window xwindow,
Pixmap *pixmap,
Pixmap *mask)
{
Atom type;
int format;
......@@ -404,23 +404,23 @@ get_kwm_win_icon (MetaDisplay *display,
*pixmap = None;
*mask = None;
meta_error_trap_push (display->x11_display);
meta_error_trap_push (x11_display);
icons = NULL;
result = XGetWindowProperty (display->x11_display->xdisplay, xwindow,
display->x11_display->atom__KWM_WIN_ICON,
result = XGetWindowProperty (x11_display->xdisplay, xwindow,
x11_display->atom__KWM_WIN_ICON,
0, G_MAXLONG,
False,
display->x11_display->atom__KWM_WIN_ICON,
x11_display->atom__KWM_WIN_ICON,
&type, &format, &nitems,
&bytes_after, &data);
icons = (Pixmap *)data;
err = meta_error_trap_pop_with_return (display->x11_display);
err = meta_error_trap_pop_with_return (x11_display);
if (err != Success ||
result != Success)
return;
if (type != display->x11_display->atom__KWM_WIN_ICON)
if (type != x11_display->atom__KWM_WIN_ICON)
{
XFree (icons);
return;
......@@ -448,13 +448,13 @@ meta_icon_cache_init (MetaIconCache *icon_cache)
}
void
meta_icon_cache_property_changed (MetaIconCache *icon_cache,
MetaDisplay *display,
Atom atom)
meta_icon_cache_property_changed (MetaIconCache *icon_cache,
MetaX11Display *x11_display,
Atom atom)
{
if (atom == display->x11_display->atom__NET_WM_ICON)
if (atom == x11_display->atom__NET_WM_ICON)
icon_cache->net_wm_icon_dirty = TRUE;
else if (atom == display->x11_display->atom__KWM_WIN_ICON)
else if (atom == x11_display->atom__KWM_WIN_ICON)
icon_cache->kwm_win_icon_dirty = TRUE;
else if (atom == XA_WM_HINTS)
icon_cache->wm_hints_dirty = TRUE;
......@@ -479,7 +479,7 @@ meta_icon_cache_get_icon_invalidated (MetaIconCache *icon_cache)
}
gboolean
meta_read_icons (MetaScreen *screen,
meta_read_icons (MetaX11Display *x11_display,
Window xwindow,
MetaIconCache *icon_cache,
Pixmap wm_hints_pixmap,
......@@ -515,7 +515,7 @@ meta_read_icons (MetaScreen *screen,
{
icon_cache->net_wm_icon_dirty = FALSE;
if (read_rgb_icon (screen->display, xwindow,
if (read_rgb_icon (x11_display, xwindow,
ideal_width, ideal_height,
ideal_mini_width, ideal_mini_height,
iconp, mini_iconp))
......@@ -544,7 +544,7 @@ meta_read_icons (MetaScreen *screen,
mask != icon_cache->prev_mask) &&
pixmap != None)
{
if (try_pixmap_and_mask (screen->display, pixmap, mask, iconp))
if (try_pixmap_and_mask (x11_display, pixmap, mask, iconp))
{
*mini_iconp = cairo_surface_reference (*iconp);
icon_cache->prev_pixmap = pixmap;
......@@ -563,13 +563,13 @@ meta_read_icons (MetaScreen *screen,
icon_cache->kwm_win_icon_dirty = FALSE;
get_kwm_win_icon (screen->display, xwindow, &pixmap, &mask);
get_kwm_win_icon (x11_display, xwindow, &pixmap, &mask);
if ((pixmap != icon_cache->prev_pixmap ||
mask != icon_cache->prev_mask) &&
pixmap != None)
{
if (try_pixmap_and_mask (screen->display, pixmap, mask, iconp))
if (try_pixmap_and_mask (x11_display, pixmap, mask, iconp))
{
*mini_iconp = cairo_surface_reference (*iconp);
icon_cache->prev_pixmap = pixmap;
......
......@@ -22,7 +22,7 @@
#ifndef META_ICON_CACHE_H
#define META_ICON_CACHE_H
#include "screen-private.h"
#include "x11/meta-x11-display-private.h"
typedef struct _MetaIconCache MetaIconCache;
......@@ -50,13 +50,13 @@ struct _MetaIconCache
guint net_wm_icon_dirty : 1;
};
void meta_icon_cache_init (MetaIconCache *icon_cache);
void meta_icon_cache_property_changed (MetaIconCache *icon_cache,
MetaDisplay *display,
Atom atom);
gboolean meta_icon_cache_get_icon_invalidated (MetaIconCache *icon_cache);
void meta_icon_cache_init (MetaIconCache *icon_cache);
void meta_icon_cache_property_changed (MetaIconCache *icon_cache,
MetaX11Display *x11_display,
Atom atom);
gboolean meta_icon_cache_get_icon_invalidated (MetaIconCache *icon_cache);
gboolean meta_read_icons (MetaScreen *screen,
gboolean meta_read_icons (MetaX11Display *x11_display,
Window xwindow,
MetaIconCache *icon_cache,
Pixmap wm_hints_pixmap,
......
......@@ -54,6 +54,7 @@
#include "meta/errors.h"
#include "meta/main.h"
#include "x11/events.h"
#include "x11/group-props.h"
#include "x11/window-props.h"
#include "x11/xprops.h"
......@@ -74,6 +75,7 @@ static void on_monitors_changed (MetaDisplay *display,
MetaX11Display *x11_display);
static void update_cursor_theme (MetaX11Display *x11_display);
static void unset_wm_check_hint (MetaX11Display *x11_display);
static void
meta_x11_display_dispose (GObject *object)
......@@ -157,6 +159,8 @@ meta_x11_display_dispose (GObject *object)
if (x11_display->xroot != None)
{
unset_wm_check_hint (x11_display);
meta_error_trap_push (x11_display);
XSelectInput (x11_display->xdisplay, x11_display->xroot, 0);
if (meta_error_trap_pop_with_return (x11_display) != Success)
......@@ -169,6 +173,8 @@ meta_x11_display_dispose (GObject *object)
if (x11_display->xdisplay)
{
meta_x11_display_free_events (x11_display);
x11_display->xdisplay = NULL;
}
......@@ -371,6 +377,134 @@ query_xi_extension (MetaX11Display *x11_display)
meta_fatal ("X server doesn't have the XInput extension, version 2.2 or newer\n");
}
static void
set_desktop_geometry_hint (MetaX11Display *x11_display)
{
unsigned long data[2];
if (x11_display->display->closing > 0)
return;
data[0] = x11_display->display->rect.width;
data[1] = x11_display->display->rect.height;
meta_verbose ("Setting _NET_DESKTOP_GEOMETRY to %lu, %lu\n", data[0], data[1]);
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_DESKTOP_GEOMETRY,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (x11_display);
}
static void
set_desktop_viewport_hint (MetaX11Display *x11_display)
{
unsigned long data[2];
if (x11_display->display->closing > 0)
return;
/*
* Mutter does not implement viewports, so this is a fixed 0,0
*/
data[0] = 0;
data[1] = 0;
meta_verbose ("Setting _NET_DESKTOP_VIEWPORT to 0, 0\n");
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_DESKTOP_VIEWPORT,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (x11_display);
}
static int
set_wm_check_hint (MetaX11Display *x11_display)
{
unsigned long data[1];
g_return_val_if_fail (x11_display->leader_window != None, 0);
data[0] = x11_display->leader_window;
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SUPPORTING_WM_CHECK,
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
return Success;
}
static void
unset_wm_check_hint (MetaX11Display *x11_display)
{
XDeleteProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SUPPORTING_WM_CHECK);
}
static int
set_supported_hint (MetaX11Display *x11_display)
{
Atom atoms[] = {
#define EWMH_ATOMS_ONLY
#define item(x) x11_display->atom_##x,
#include "x11/atomnames.h"
#undef item
#undef EWMH_ATOMS_ONLY
x11_display->atom__GTK_FRAME_EXTENTS,
x11_display->atom__GTK_SHOW_WINDOW_MENU,
};
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_SUPPORTED,
XA_ATOM,
32, PropModeReplace,
(guchar*) atoms, G_N_ELEMENTS(atoms));
return Success;
}
static int
set_wm_icon_size_hint (MetaX11Display *x11_display)
{
#define N_VALS 6
gulong vals[N_VALS];
/* We've bumped the real icon size up to 96x96, but
* we really should not add these sorts of constraints
* on clients still using the legacy WM_HINTS interface.
*/
#define LEGACY_ICON_SIZE 32
/* min width, min height, max w, max h, width inc, height inc */
vals[0] = LEGACY_ICON_SIZE;
vals[1] = LEGACY_ICON_SIZE;
vals[2] = LEGACY_ICON_SIZE;
vals[3] = LEGACY_ICON_SIZE;
vals[4] = 0;
vals[5] = 0;
#undef LEGACY_ICON_SIZE
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom_WM_ICON_SIZE,
XA_CARDINAL,
32, PropModeReplace, (guchar*) vals, N_VALS);
return Success;
#undef N_VALS
}
static Window
take_manager_selection (MetaX11Display *x11_display,
Window xroot,
......@@ -755,6 +889,18 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
XMapWindow (xdisplay, x11_display->no_focus_window);
/* Done with no_focus_window stuff */
meta_x11_display_init_events (x11_display);
set_wm_icon_size_hint (x11_display);
set_supported_hint (x11_display);
set_wm_check_hint (x11_display);
set_desktop_viewport_hint (x11_display);
set_desktop_geometry_hint (x11_display);
return x11_display;
}
......@@ -1064,6 +1210,8 @@ static void
on_monitors_changed (MetaDisplay *display,
MetaX11Display *x11_display)
{
set_desktop_geometry_hint (x11_display);
/* Resize the guard window to fill the screen again. */
if (x11_display->guard_window != None)
{
......
......@@ -289,7 +289,7 @@ reload_icon (MetaWindow *window,
MetaWindowX11Private *priv = window_x11->priv;
meta_icon_cache_property_changed (&priv->icon_cache,
window->display,
window->display->x11_display,
atom);
meta_window_queue(window, META_QUEUE_UPDATE_ICON);
}
......@@ -1615,7 +1615,7 @@ reload_wm_hints (MetaWindow *window,
meta_window_set_urgent (window, urgent);
meta_icon_cache_property_changed (&priv->icon_cache,
window->display,
window->display->x11_display,
XA_WM_HINTS);
meta_window_queue (window, META_QUEUE_UPDATE_ICON | META_QUEUE_MOVE_RESIZE);
......
......@@ -1485,7 +1485,7 @@ meta_window_x11_update_icon (MetaWindow *window,
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
return meta_read_icons (window->screen,
return meta_read_icons (window->display->x11_display,
window->xwindow,
&priv->icon_cache,
priv->wm_hints_pixmap,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment