From a5d2c51392e610911b07ad06d68b609fb5e6d395 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 13 Mar 2014 16:49:17 -0400 Subject: [PATCH] window: Move recalc_type to window-x11.c It's only used by the X11 codepath. --- src/core/window-private.h | 2 - src/core/window-props.c | 2 +- src/core/window-x11.c | 119 +++++++++++++++++++++++++++++++++++++- src/core/window-x11.h | 2 + src/core/window.c | 118 +------------------------------------ 5 files changed, 122 insertions(+), 121 deletions(-) diff --git a/src/core/window-private.h b/src/core/window-private.h index 30805776d..7906bfcaa 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -684,8 +684,6 @@ void meta_window_update_layer (MetaWindow *window); void meta_window_recalc_features (MetaWindow *window); -/* recalc_window_type is x11 only, wayland does its thing and then calls type_changed */ -void meta_window_recalc_window_type (MetaWindow *window); void meta_window_type_changed (MetaWindow *window); void meta_window_frame_size_changed (MetaWindow *window); diff --git a/src/core/window-props.c b/src/core/window-props.c index f0454fe47..dc6f9ba70 100644 --- a/src/core/window-props.c +++ b/src/core/window-props.c @@ -727,7 +727,7 @@ reload_net_wm_state (MetaWindow *window, meta_verbose ("Reloaded _NET_WM_STATE for %s\n", window->desc); - meta_window_recalc_window_type (window); + meta_window_x11_recalc_window_type (window); meta_window_recalc_features (window); } diff --git a/src/core/window-x11.c b/src/core/window-x11.c index 1d473455e..47cd85360 100644 --- a/src/core/window-x11.c +++ b/src/core/window-x11.c @@ -226,7 +226,7 @@ meta_window_x11_update_net_wm_type (MetaWindow *window) meta_XFree (str); } - meta_window_recalc_window_type (window); + meta_window_x11_recalc_window_type (window); } void @@ -872,7 +872,7 @@ meta_window_x11_client_message (MetaWindow *window, (action == _NET_WM_STATE_ADD) || (action == _NET_WM_STATE_TOGGLE && !window->wm_state_modal); - meta_window_recalc_window_type (window); + meta_window_x11_recalc_window_type (window); meta_window_queue(window, META_QUEUE_MOVE_RESIZE); } @@ -1506,3 +1506,118 @@ error: meta_error_trap_pop (display); return NULL; } + +void +meta_window_x11_recalc_window_type (MetaWindow *window) +{ + MetaWindowType old_type; + + old_type = window->type; + + if (window->type_atom != None) + { + if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DESKTOP) + window->type = META_WINDOW_DESKTOP; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DOCK) + window->type = META_WINDOW_DOCK; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_TOOLBAR) + window->type = META_WINDOW_TOOLBAR; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_MENU) + window->type = META_WINDOW_MENU; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_UTILITY) + window->type = META_WINDOW_UTILITY; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_SPLASH) + window->type = META_WINDOW_SPLASHSCREEN; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DIALOG) + window->type = META_WINDOW_DIALOG; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_NORMAL) + window->type = META_WINDOW_NORMAL; + /* The below are *typically* override-redirect windows, but the spec does + * not disallow using them for managed windows. + */ + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DROPDOWN_MENU) + window->type = META_WINDOW_DROPDOWN_MENU; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_POPUP_MENU) + window->type = META_WINDOW_POPUP_MENU; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_TOOLTIP) + window->type = META_WINDOW_TOOLTIP; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_NOTIFICATION) + window->type = META_WINDOW_NOTIFICATION; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_COMBO) + window->type = META_WINDOW_COMBO; + else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DND) + window->type = META_WINDOW_DND; + else + { + char *atom_name; + + /* + * Fallback on a normal type, and print warning. Don't abort. + */ + window->type = META_WINDOW_NORMAL; + + meta_error_trap_push (window->display); + atom_name = XGetAtomName (window->display->xdisplay, + window->type_atom); + meta_error_trap_pop (window->display); + + meta_warning ("Unrecognized type atom [%s] set for %s \n", + atom_name ? atom_name : "unknown", + window->desc); + + if (atom_name) + XFree (atom_name); + } + } + else if (window->transient_for != NULL) + { + window->type = META_WINDOW_DIALOG; + } + else + { + window->type = META_WINDOW_NORMAL; + } + + if (window->type == META_WINDOW_DIALOG && + window->wm_state_modal) + window->type = META_WINDOW_MODAL_DIALOG; + + /* We don't want to allow override-redirect windows to have decorated-window + * types since that's just confusing. + */ + if (window->override_redirect) + { + switch (window->type) + { + /* Decorated types */ + case META_WINDOW_NORMAL: + case META_WINDOW_DIALOG: + case META_WINDOW_MODAL_DIALOG: + case META_WINDOW_MENU: + case META_WINDOW_UTILITY: + window->type = META_WINDOW_OVERRIDE_OTHER; + break; + /* Undecorated types, normally not override-redirect */ + case META_WINDOW_DESKTOP: + case META_WINDOW_DOCK: + case META_WINDOW_TOOLBAR: + case META_WINDOW_SPLASHSCREEN: + /* Undecorated types, normally override-redirect types */ + case META_WINDOW_DROPDOWN_MENU: + case META_WINDOW_POPUP_MENU: + case META_WINDOW_TOOLTIP: + case META_WINDOW_NOTIFICATION: + case META_WINDOW_COMBO: + case META_WINDOW_DND: + /* To complete enum */ + case META_WINDOW_OVERRIDE_OTHER: + break; + } + } + + meta_verbose ("Calculated type %u for %s, old type %u\n", + window->type, window->desc, old_type); + + if (old_type != window->type) + meta_window_type_changed (window); +} diff --git a/src/core/window-x11.h b/src/core/window-x11.h index 4657c7f33..d8f2ce2db 100644 --- a/src/core/window-x11.h +++ b/src/core/window-x11.h @@ -35,6 +35,8 @@ void meta_window_x11_update_opaque_region (MetaWindow *window); void meta_window_x11_update_input_region (MetaWindow *window); void meta_window_x11_update_shape_region (MetaWindow *window); +void meta_window_x11_recalc_window_type (MetaWindow *window); + gboolean meta_window_x11_configure_request (MetaWindow *window, XEvent *event); gboolean meta_window_x11_property_notify (MetaWindow *window, diff --git a/src/core/window.c b/src/core/window.c index bbce5a81d..f281b5774 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -7064,121 +7064,6 @@ meta_window_update_struts (MetaWindow *window) } } -void -meta_window_recalc_window_type (MetaWindow *window) -{ - MetaWindowType old_type; - - old_type = window->type; - - if (window->type_atom != None) - { - if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DESKTOP) - window->type = META_WINDOW_DESKTOP; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DOCK) - window->type = META_WINDOW_DOCK; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_TOOLBAR) - window->type = META_WINDOW_TOOLBAR; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_MENU) - window->type = META_WINDOW_MENU; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_UTILITY) - window->type = META_WINDOW_UTILITY; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_SPLASH) - window->type = META_WINDOW_SPLASHSCREEN; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DIALOG) - window->type = META_WINDOW_DIALOG; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_NORMAL) - window->type = META_WINDOW_NORMAL; - /* The below are *typically* override-redirect windows, but the spec does - * not disallow using them for managed windows. - */ - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DROPDOWN_MENU) - window->type = META_WINDOW_DROPDOWN_MENU; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_POPUP_MENU) - window->type = META_WINDOW_POPUP_MENU; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_TOOLTIP) - window->type = META_WINDOW_TOOLTIP; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_NOTIFICATION) - window->type = META_WINDOW_NOTIFICATION; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_COMBO) - window->type = META_WINDOW_COMBO; - else if (window->type_atom == window->display->atom__NET_WM_WINDOW_TYPE_DND) - window->type = META_WINDOW_DND; - else - { - char *atom_name; - - /* - * Fallback on a normal type, and print warning. Don't abort. - */ - window->type = META_WINDOW_NORMAL; - - meta_error_trap_push (window->display); - atom_name = XGetAtomName (window->display->xdisplay, - window->type_atom); - meta_error_trap_pop (window->display); - - meta_warning ("Unrecognized type atom [%s] set for %s \n", - atom_name ? atom_name : "unknown", - window->desc); - - if (atom_name) - XFree (atom_name); - } - } - else if (window->transient_for != NULL) - { - window->type = META_WINDOW_DIALOG; - } - else - { - window->type = META_WINDOW_NORMAL; - } - - if (window->type == META_WINDOW_DIALOG && - window->wm_state_modal) - window->type = META_WINDOW_MODAL_DIALOG; - - /* We don't want to allow override-redirect windows to have decorated-window - * types since that's just confusing. - */ - if (window->override_redirect) - { - switch (window->type) - { - /* Decorated types */ - case META_WINDOW_NORMAL: - case META_WINDOW_DIALOG: - case META_WINDOW_MODAL_DIALOG: - case META_WINDOW_MENU: - case META_WINDOW_UTILITY: - window->type = META_WINDOW_OVERRIDE_OTHER; - break; - /* Undecorated types, normally not override-redirect */ - case META_WINDOW_DESKTOP: - case META_WINDOW_DOCK: - case META_WINDOW_TOOLBAR: - case META_WINDOW_SPLASHSCREEN: - /* Undecorated types, normally override-redirect types */ - case META_WINDOW_DROPDOWN_MENU: - case META_WINDOW_POPUP_MENU: - case META_WINDOW_TOOLTIP: - case META_WINDOW_NOTIFICATION: - case META_WINDOW_COMBO: - case META_WINDOW_DND: - /* To complete enum */ - case META_WINDOW_OVERRIDE_OTHER: - break; - } - } - - meta_verbose ("Calculated type %u for %s, old type %u\n", - window->type, window->desc, old_type); - - if (old_type != window->type) - meta_window_type_changed (window); -} - void meta_window_type_changed (MetaWindow *window) { @@ -10258,7 +10143,8 @@ meta_window_set_transient_for (MetaWindow *window, meta_window_propagate_focus_appearance (window, FALSE); /* may now be a dialog */ - meta_window_recalc_window_type (window); + if (window->client_type == META_WINDOW_CLIENT_TYPE_X11) + meta_window_x11_recalc_window_type (window); if (!window->constructing) {