Commit 9e5ea8de authored by Armin Krezović's avatar Armin Krezović Committed by Jonas Ådahl
Browse files

Move groups and window/group prop hooks to MetaX11Display

https://bugzilla.gnome.org/show_bug.cgi?id=759538
parent 722c975a
...@@ -50,9 +50,6 @@ ...@@ -50,9 +50,6 @@
typedef struct _MetaStack MetaStack; typedef struct _MetaStack MetaStack;
typedef struct _MetaUISlave MetaUISlave; typedef struct _MetaUISlave MetaUISlave;
typedef struct _MetaGroupPropHooks MetaGroupPropHooks;
typedef struct _MetaWindowPropHooks MetaWindowPropHooks;
typedef struct MetaEdgeResistanceData MetaEdgeResistanceData; typedef struct MetaEdgeResistanceData MetaEdgeResistanceData;
typedef enum { typedef enum {
...@@ -235,17 +232,6 @@ struct _MetaDisplay ...@@ -235,17 +232,6 @@ struct _MetaDisplay
/* Closing down the display */ /* Closing down the display */
int closing; int closing;
/* Managed by group.c */
GHashTable *groups_by_leader;
/* Managed by window-props.c */
MetaWindowPropHooks *prop_hooks_table;
GHashTable *prop_hooks;
int n_prop_hooks;
/* Managed by group-props.c */
MetaGroupPropHooks *group_prop_hooks;
/* Managed by compositor.c */ /* Managed by compositor.c */
MetaCompositor *compositor; MetaCompositor *compositor;
......
...@@ -72,8 +72,6 @@ ...@@ -72,8 +72,6 @@
#include "x11/events.h" #include "x11/events.h"
#include "x11/window-x11.h" #include "x11/window-x11.h"
#include "x11/window-props.h"
#include "x11/group-props.h"
#include "x11/xprops.h" #include "x11/xprops.h"
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
...@@ -717,19 +715,12 @@ meta_display_open (void) ...@@ -717,19 +715,12 @@ meta_display_open (void)
meta_bell_init (display); meta_bell_init (display);
display->prop_hooks = NULL;
meta_display_init_window_prop_hooks (display);
display->group_prop_hooks = NULL;
meta_display_init_group_prop_hooks (display);
/* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK, /* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK,
* created in screen_new * created in screen_new
*/ */
display->leader_window = None; display->leader_window = None;
display->timestamp_pinging_window = None; display->timestamp_pinging_window = None;
display->groups_by_leader = NULL;
meta_display_init_events_x11 (display); meta_display_init_events_x11 (display);
/* Create the leader window here. Set its properties and /* Create the leader window here. Set its properties and
...@@ -1020,9 +1011,6 @@ meta_display_close (MetaDisplay *display, ...@@ -1020,9 +1011,6 @@ meta_display_close (MetaDisplay *display,
if (display->leader_window != None) if (display->leader_window != None)
XDestroyWindow (display->x11_display->xdisplay, display->leader_window); XDestroyWindow (display->x11_display->xdisplay, display->leader_window);
meta_display_free_window_prop_hooks (display);
meta_display_free_group_prop_hooks (display);
if (display->x11_display) if (display->x11_display)
{ {
g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0); g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0);
......
...@@ -34,7 +34,7 @@ void meta_window_shutdown_group (MetaWindow *window); ...@@ -34,7 +34,7 @@ void meta_window_shutdown_group (MetaWindow *window);
void meta_window_group_leader_changed (MetaWindow *window); void meta_window_group_leader_changed (MetaWindow *window);
/* note, can return NULL */ /* note, can return NULL */
MetaGroup* meta_display_lookup_group (MetaDisplay *display, MetaGroup *meta_x11_display_lookup_group (MetaX11Display *x11_display,
Window group_leader); Window group_leader);
GSList* meta_group_list_windows (MetaGroup *group); GSList* meta_group_list_windows (MetaGroup *group);
...@@ -49,7 +49,3 @@ gboolean meta_group_property_notify (MetaGroup *group, ...@@ -49,7 +49,3 @@ gboolean meta_group_property_notify (MetaGroup *group,
XEvent *event); XEvent *event);
#endif #endif
...@@ -1480,7 +1480,7 @@ handle_other_xevent (MetaDisplay *display, ...@@ -1480,7 +1480,7 @@ handle_other_xevent (MetaDisplay *display,
else if (property_for_window && !frame_was_receiver) else if (property_for_window && !frame_was_receiver)
meta_window_x11_property_notify (property_for_window, event); meta_window_x11_property_notify (property_for_window, event);
group = meta_display_lookup_group (display, group = meta_x11_display_lookup_group (x11_display,
event->xproperty.window); event->xproperty.window);
if (group != NULL) if (group != NULL)
meta_group_property_notify (group, event); meta_group_property_notify (group, event);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
struct _MetaGroup struct _MetaGroup
{ {
int refcount; int refcount;
MetaDisplay *display; MetaX11Display *x11_display;
GSList *windows; GSList *windows;
Window group_leader; Window group_leader;
char *startup_id; char *startup_id;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
#include <X11/Xatom.h> #include <X11/Xatom.h>
typedef void (* InitValueFunc) (MetaDisplay *display, typedef void (* InitValueFunc) (MetaX11Display *x11_display,
Atom property, Atom property,
MetaPropValue *value); MetaPropValue *value);
typedef void (* ReloadValueFunc) (MetaGroup *group, typedef void (* ReloadValueFunc) (MetaGroup *group,
...@@ -39,16 +39,14 @@ struct _MetaGroupPropHooks ...@@ -39,16 +39,14 @@ struct _MetaGroupPropHooks
ReloadValueFunc reload_func; ReloadValueFunc reload_func;
}; };
static void init_prop_value (MetaDisplay *display, static void init_prop_value (MetaX11Display *x11_display,
Atom property, Atom property,
MetaPropValue *value); MetaPropValue *value);
static void reload_prop_value (MetaGroup *group, static void reload_prop_value (MetaGroup *group,
MetaPropValue *value); MetaPropValue *value);
static MetaGroupPropHooks* find_hooks (MetaDisplay *display, static MetaGroupPropHooks *find_hooks (MetaX11Display *x11_display,
Atom property); Atom property);
void void
meta_group_reload_property (MetaGroup *group, meta_group_reload_property (MetaGroup *group,
Atom property) Atom property)
...@@ -72,11 +70,12 @@ meta_group_reload_properties (MetaGroup *group, ...@@ -72,11 +70,12 @@ meta_group_reload_properties (MetaGroup *group,
i = 0; i = 0;
while (i < n_properties) while (i < n_properties)
{ {
init_prop_value (group->display, properties[i], &values[i]); init_prop_value (group->x11_display, properties[i], &values[i]);
++i; ++i;
} }
meta_prop_get_values (group->display, group->group_leader, meta_prop_get_values (group->x11_display->display,
group->group_leader,
values, n_properties); values, n_properties);
i = 0; i = 0;
...@@ -94,7 +93,7 @@ meta_group_reload_properties (MetaGroup *group, ...@@ -94,7 +93,7 @@ meta_group_reload_properties (MetaGroup *group,
/* Fill in the MetaPropValue used to get the value of "property" */ /* Fill in the MetaPropValue used to get the value of "property" */
static void static void
init_prop_value (MetaDisplay *display, init_prop_value (MetaX11Display *x11_display,
Atom property, Atom property,
MetaPropValue *value) MetaPropValue *value)
{ {
...@@ -103,9 +102,9 @@ init_prop_value (MetaDisplay *display, ...@@ -103,9 +102,9 @@ init_prop_value (MetaDisplay *display,
value->type = META_PROP_VALUE_INVALID; value->type = META_PROP_VALUE_INVALID;
value->atom = None; value->atom = None;
hooks = find_hooks (display, property); hooks = find_hooks (x11_display, property);
if (hooks && hooks->init_func != NULL) if (hooks && hooks->init_func != NULL)
(* hooks->init_func) (display, property, value); (* hooks->init_func) (x11_display, property, value);
} }
static void static void
...@@ -114,18 +113,18 @@ reload_prop_value (MetaGroup *group, ...@@ -114,18 +113,18 @@ reload_prop_value (MetaGroup *group,
{ {
MetaGroupPropHooks *hooks; MetaGroupPropHooks *hooks;
hooks = find_hooks (group->display, value->atom); hooks = find_hooks (group->x11_display, value->atom);
if (hooks && hooks->reload_func != NULL) if (hooks && hooks->reload_func != NULL)
(* hooks->reload_func) (group, value); (* hooks->reload_func) (group, value);
} }
static void static void
init_wm_client_machine (MetaDisplay *display, init_wm_client_machine (MetaX11Display *x11_display,
Atom property, Atom property,
MetaPropValue *value) MetaPropValue *value)
{ {
value->type = META_PROP_VALUE_STRING; value->type = META_PROP_VALUE_STRING;
value->atom = display->x11_display->atom_WM_CLIENT_MACHINE; value->atom = x11_display->atom_WM_CLIENT_MACHINE;
} }
static void static void
...@@ -143,12 +142,12 @@ reload_wm_client_machine (MetaGroup *group, ...@@ -143,12 +142,12 @@ reload_wm_client_machine (MetaGroup *group,
} }
static void static void
init_net_startup_id (MetaDisplay *display, init_net_startup_id (MetaX11Display *x11_display,
Atom property, Atom property,
MetaPropValue *value) MetaPropValue *value)
{ {
value->type = META_PROP_VALUE_UTF8; value->type = META_PROP_VALUE_UTF8;
value->atom = display->x11_display->atom__NET_STARTUP_ID; value->atom = x11_display->atom__NET_STARTUP_ID;
} }
static void static void
...@@ -168,29 +167,29 @@ reload_net_startup_id (MetaGroup *group, ...@@ -168,29 +167,29 @@ reload_net_startup_id (MetaGroup *group,
#define N_HOOKS 3 #define N_HOOKS 3
void void
meta_display_init_group_prop_hooks (MetaDisplay *display) meta_x11_display_init_group_prop_hooks (MetaX11Display *x11_display)
{ {
int i; int i;
MetaGroupPropHooks *hooks; MetaGroupPropHooks *hooks;
g_assert (display->group_prop_hooks == NULL); g_assert (x11_display->group_prop_hooks == NULL);
display->group_prop_hooks = g_new0 (MetaGroupPropHooks, N_HOOKS); x11_display->group_prop_hooks = g_new0 (MetaGroupPropHooks, N_HOOKS);
hooks = display->group_prop_hooks; hooks = x11_display->group_prop_hooks;
i = 0; i = 0;
hooks[i].property = display->x11_display->atom_WM_CLIENT_MACHINE; hooks[i].property = x11_display->atom_WM_CLIENT_MACHINE;
hooks[i].init_func = init_wm_client_machine; hooks[i].init_func = init_wm_client_machine;
hooks[i].reload_func = reload_wm_client_machine; hooks[i].reload_func = reload_wm_client_machine;
++i; ++i;
hooks[i].property = display->x11_display->atom__NET_WM_PID; hooks[i].property = x11_display->atom__NET_WM_PID;
hooks[i].init_func = NULL; hooks[i].init_func = NULL;
hooks[i].reload_func = NULL; hooks[i].reload_func = NULL;
++i; ++i;
hooks[i].property = display->x11_display->atom__NET_STARTUP_ID; hooks[i].property = x11_display->atom__NET_STARTUP_ID;
hooks[i].init_func = init_net_startup_id; hooks[i].init_func = init_net_startup_id;
hooks[i].reload_func = reload_net_startup_id; hooks[i].reload_func = reload_net_startup_id;
++i; ++i;
...@@ -202,16 +201,16 @@ meta_display_init_group_prop_hooks (MetaDisplay *display) ...@@ -202,16 +201,16 @@ meta_display_init_group_prop_hooks (MetaDisplay *display)
} }
void void
meta_display_free_group_prop_hooks (MetaDisplay *display) meta_x11_display_free_group_prop_hooks (MetaX11Display *x11_display)
{ {
g_assert (display->group_prop_hooks != NULL); g_assert (x11_display->group_prop_hooks != NULL);
g_free (display->group_prop_hooks); g_free (x11_display->group_prop_hooks);
display->group_prop_hooks = NULL; x11_display->group_prop_hooks = NULL;
} }
static MetaGroupPropHooks* static MetaGroupPropHooks*
find_hooks (MetaDisplay *display, find_hooks (MetaX11Display *x11_display,
Atom property) Atom property)
{ {
int i; int i;
...@@ -223,8 +222,8 @@ find_hooks (MetaDisplay *display, ...@@ -223,8 +222,8 @@ find_hooks (MetaDisplay *display,
i = 0; i = 0;
while (i < N_HOOKS) while (i < N_HOOKS)
{ {
if (display->group_prop_hooks[i].property == property) if (x11_display->group_prop_hooks[i].property == property)
return &display->group_prop_hooks[i]; return &x11_display->group_prop_hooks[i];
++i; ++i;
} }
......
...@@ -30,7 +30,8 @@ void meta_group_reload_property (MetaGroup *group, ...@@ -30,7 +30,8 @@ void meta_group_reload_property (MetaGroup *group,
void meta_group_reload_properties (MetaGroup *group, void meta_group_reload_properties (MetaGroup *group,
const Atom *properties, const Atom *properties,
int n_properties); int n_properties);
void meta_display_init_group_prop_hooks (MetaDisplay *display);
void meta_display_free_group_prop_hooks (MetaDisplay *display); void meta_x11_display_init_group_prop_hooks (MetaX11Display *x11_display);
void meta_x11_display_free_group_prop_hooks (MetaX11Display *x11_display);
#endif /* META_GROUP_PROPS_H */ #endif /* META_GROUP_PROPS_H */
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <X11/Xlib-xcb.h> #include <X11/Xlib-xcb.h>
static MetaGroup* static MetaGroup*
meta_group_new (MetaDisplay *display, meta_group_new (MetaX11Display *x11_display,
Window group_leader) Window group_leader)
{ {
MetaGroup *group; MetaGroup *group;
...@@ -47,12 +47,12 @@ meta_group_new (MetaDisplay *display, ...@@ -47,12 +47,12 @@ meta_group_new (MetaDisplay *display,
group = g_new0 (MetaGroup, 1); group = g_new0 (MetaGroup, 1);
group->display = display; group->x11_display = x11_display;
group->windows = NULL; group->windows = NULL;
group->group_leader = group_leader; group->group_leader = group_leader;
group->refcount = 1; /* owned by caller, hash table has only weak ref */ group->refcount = 1; /* owned by caller, hash table has only weak ref */
xcb_connection_t *xcb_conn = XGetXCBConnection (display->x11_display->xdisplay); xcb_connection_t *xcb_conn = XGetXCBConnection (x11_display->xdisplay);
xcb_generic_error_t *e; xcb_generic_error_t *e;
g_autofree xcb_get_window_attributes_reply_t *attrs = g_autofree xcb_get_window_attributes_reply_t *attrs =
xcb_get_window_attributes_reply (xcb_conn, xcb_get_window_attributes_reply (xcb_conn,
...@@ -65,21 +65,21 @@ meta_group_new (MetaDisplay *display, ...@@ -65,21 +65,21 @@ meta_group_new (MetaDisplay *display,
xcb_change_window_attributes (xcb_conn, group_leader, xcb_change_window_attributes (xcb_conn, group_leader,
XCB_CW_EVENT_MASK, events); XCB_CW_EVENT_MASK, events);
if (display->groups_by_leader == NULL) if (x11_display->groups_by_leader == NULL)
display->groups_by_leader = g_hash_table_new (meta_unsigned_long_hash, x11_display->groups_by_leader = g_hash_table_new (meta_unsigned_long_hash,
meta_unsigned_long_equal); meta_unsigned_long_equal);
g_assert (g_hash_table_lookup (display->groups_by_leader, &group_leader) == NULL); g_assert (g_hash_table_lookup (x11_display->groups_by_leader, &group_leader) == NULL);
g_hash_table_insert (display->groups_by_leader, g_hash_table_insert (x11_display->groups_by_leader,
&group->group_leader, &group->group_leader,
group); group);
/* Fill these in the order we want them to be gotten */ /* Fill these in the order we want them to be gotten */
i = 0; i = 0;
initial_props[i++] = display->x11_display->atom_WM_CLIENT_MACHINE; initial_props[i++] = x11_display->atom_WM_CLIENT_MACHINE;
initial_props[i++] = display->x11_display->atom__NET_WM_PID; initial_props[i++] = x11_display->atom__NET_WM_PID;
initial_props[i++] = display->x11_display->atom__NET_STARTUP_ID; initial_props[i++] = x11_display->atom__NET_STARTUP_ID;
g_assert (N_INITIAL_PROPS == i); g_assert (N_INITIAL_PROPS == i);
meta_group_reload_properties (group, initial_props, N_INITIAL_PROPS); meta_group_reload_properties (group, initial_props, N_INITIAL_PROPS);
...@@ -103,16 +103,16 @@ meta_group_unref (MetaGroup *group) ...@@ -103,16 +103,16 @@ meta_group_unref (MetaGroup *group)
"Destroying group with leader 0x%lx\n", "Destroying group with leader 0x%lx\n",
group->group_leader); group->group_leader);
g_assert (group->display->groups_by_leader != NULL); g_assert (group->x11_display->groups_by_leader != NULL);
g_hash_table_remove (group->display->groups_by_leader, g_hash_table_remove (group->x11_display->groups_by_leader,
&group->group_leader); &group->group_leader);
/* mop up hash table, this is how it gets freed on display close */ /* mop up hash table, this is how it gets freed on display close */
if (g_hash_table_size (group->display->groups_by_leader) == 0) if (g_hash_table_size (group->x11_display->groups_by_leader) == 0)
{ {
g_hash_table_destroy (group->display->groups_by_leader); g_hash_table_destroy (group->x11_display->groups_by_leader);
group->display->groups_by_leader = NULL; group->x11_display->groups_by_leader = NULL;
} }
g_free (group->wm_client_machine); g_free (group->wm_client_machine);
...@@ -141,6 +141,7 @@ meta_window_compute_group (MetaWindow* window) ...@@ -141,6 +141,7 @@ meta_window_compute_group (MetaWindow* window)
{ {
MetaGroup *group; MetaGroup *group;
MetaWindow *ancestor; MetaWindow *ancestor;
MetaX11Display *x11_display = window->display->x11_display;
/* use window->xwindow if no window->xgroup_leader */ /* use window->xwindow if no window->xgroup_leader */
...@@ -151,15 +152,15 @@ meta_window_compute_group (MetaWindow* window) ...@@ -151,15 +152,15 @@ meta_window_compute_group (MetaWindow* window)
*/ */
ancestor = meta_window_find_root_ancestor (window); ancestor = meta_window_find_root_ancestor (window);
if (window->display->groups_by_leader) if (x11_display->groups_by_leader)
{ {
if (ancestor != window) if (ancestor != window)
group = ancestor->group; group = ancestor->group;
else if (window->xgroup_leader != None) else if (window->xgroup_leader != None)
group = g_hash_table_lookup (window->display->groups_by_leader, group = g_hash_table_lookup (x11_display->groups_by_leader,
&window->xgroup_leader); &window->xgroup_leader);
else else
group = g_hash_table_lookup (window->display->groups_by_leader, group = g_hash_table_lookup (x11_display->groups_by_leader,
&window->xwindow); &window->xwindow);
} }
...@@ -171,13 +172,13 @@ meta_window_compute_group (MetaWindow* window) ...@@ -171,13 +172,13 @@ meta_window_compute_group (MetaWindow* window)
else else
{ {
if (ancestor != window && ancestor->xgroup_leader != None) if (ancestor != window && ancestor->xgroup_leader != None)
group = meta_group_new (window->display, group = meta_group_new (x11_display,
ancestor->xgroup_leader); ancestor->xgroup_leader);
else if (window->xgroup_leader != None) else if (window->xgroup_leader != None)
group = meta_group_new (window->display, group = meta_group_new (x11_display,
window->xgroup_leader); window->xgroup_leader);
else else
group = meta_group_new (window->display, group = meta_group_new (x11_display,
window->xwindow); window->xwindow);
window->group = group; window->group = group;
...@@ -224,21 +225,21 @@ meta_window_shutdown_group (MetaWindow *window) ...@@ -224,21 +225,21 @@ meta_window_shutdown_group (MetaWindow *window)
} }
/** /**
* meta_display_lookup_group: (skip) * meta_x11_display_lookup_group: (skip)
* @display: a #MetaDisplay * @x11_display: a #MetaX11Display
* @group_leader: a X window * @group_leader: a X window
* *
*/ */
MetaGroup* MetaGroup *
meta_display_lookup_group (MetaDisplay *display, meta_x11_display_lookup_group (MetaX11Display *x11_display,
Window group_leader) Window group_leader)
{ {
MetaGroup *group; MetaGroup *group;
group = NULL; group = NULL;
if (display->groups_by_leader) if (x11_display->groups_by_leader)
group = g_hash_table_lookup (display->groups_by_leader, group = g_hash_table_lookup (x11_display->groups_by_leader,
&group_leader); &group_leader);
return group; return group;
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include "meta/types.h" #include "meta/types.h"
#include "meta/meta-x11-display.h" #include "meta/meta-x11-display.h"
typedef struct _MetaGroupPropHooks MetaGroupPropHooks;