Start splitting the X11-specific stuff of MetaWindow out into a subclass

This is fairly simple and basic for now, with just skip_taskbar /
skip_pager, but eventually a lot of "WM policy" like this, including
move-resize, will be in subclasses for each individual surface.
This commit is contained in:
Jasper St. Pierre 2014-03-18 11:20:22 -04:00
parent 63b158e4da
commit 6f7023bc6b
7 changed files with 142 additions and 15 deletions

View File

@ -165,6 +165,7 @@ libmutter_wayland_la_SOURCES = \
core/window-props.h \ core/window-props.h \
core/window-x11.c \ core/window-x11.c \
core/window-x11.h \ core/window-x11.h \
core/window-x11-private.h \
core/window.c \ core/window.c \
core/window-private.h \ core/window-private.h \
meta/window.h \ meta/window.h \

View File

@ -266,10 +266,6 @@ struct _MetaWindow
/* Weird "_NET_WM_STATE_MODAL" flag */ /* Weird "_NET_WM_STATE_MODAL" flag */
guint wm_state_modal : 1; guint wm_state_modal : 1;
/* TRUE if the client forced these on */
guint wm_state_skip_taskbar : 1;
guint wm_state_skip_pager : 1;
/* Computed whether to skip taskbar or not */ /* Computed whether to skip taskbar or not */
guint skip_taskbar : 1; guint skip_taskbar : 1;
guint skip_pager : 1; guint skip_pager : 1;
@ -465,6 +461,10 @@ struct _MetaWindow
struct _MetaWindowClass struct _MetaWindowClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
void (*get_default_skip_hints) (MetaWindow *window,
gboolean *skip_taskbar_out,
gboolean *skip_pager_out);
}; };
/* These differ from window->has_foo_func in that they consider /* These differ from window->has_foo_func in that they consider

View File

@ -40,6 +40,7 @@
#include <config.h> #include <config.h>
#include "window-props.h" #include "window-props.h"
#include "window-x11.h" #include "window-x11.h"
#include "window-x11-private.h"
#include <meta/errors.h> #include <meta/errors.h>
#include "xprops.h" #include "xprops.h"
#include "frame.h" #include "frame.h"
@ -666,6 +667,9 @@ reload_net_wm_state (MetaWindow *window,
MetaPropValue *value, MetaPropValue *value,
gboolean initial) gboolean initial)
{ {
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = window_x11->priv;
int i; int i;
/* We know this is only an initial window creation, /* We know this is only an initial window creation,
@ -684,8 +688,8 @@ reload_net_wm_state (MetaWindow *window,
window->maximized_vertically = FALSE; window->maximized_vertically = FALSE;
window->fullscreen = FALSE; window->fullscreen = FALSE;
window->wm_state_modal = FALSE; window->wm_state_modal = FALSE;
window->wm_state_skip_taskbar = FALSE; priv->wm_state_skip_taskbar = FALSE;
window->wm_state_skip_pager = FALSE; priv->wm_state_skip_pager = FALSE;
window->wm_state_above = FALSE; window->wm_state_above = FALSE;
window->wm_state_below = FALSE; window->wm_state_below = FALSE;
window->wm_state_demands_attention = FALSE; window->wm_state_demands_attention = FALSE;
@ -707,9 +711,9 @@ reload_net_wm_state (MetaWindow *window,
else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_MODAL) else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_MODAL)
window->wm_state_modal = TRUE; window->wm_state_modal = TRUE;
else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_SKIP_TASKBAR) else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_SKIP_TASKBAR)
window->wm_state_skip_taskbar = TRUE; priv->wm_state_skip_taskbar = TRUE;
else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_SKIP_PAGER) else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_SKIP_PAGER)
window->wm_state_skip_pager = TRUE; priv->wm_state_skip_pager = TRUE;
else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_FULLSCREEN) else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_FULLSCREEN)
window->fullscreen_after_placement = TRUE; window->fullscreen_after_placement = TRUE;
else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_ABOVE) else if (value->v.atom_list.atoms[i] == window->display->atom__NET_WM_STATE_ABOVE)

View File

@ -0,0 +1,48 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2001 Havoc Pennington, Anders Carlsson
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 Rob Adams
* Copyright (C) 2004-2006 Elijah Newren
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "window-private.h"
#ifndef META_WINDOW_X11_PRIVATE_H
#define META_WINDOW_X11_PRIVATE_H
G_BEGIN_DECLS
typedef struct _MetaWindowX11Private MetaWindowX11Private;
struct _MetaWindowX11
{
MetaWindow parent;
MetaWindowX11Private *priv;
};
struct _MetaWindowX11Private
{
/* TRUE if the client forced these on */
guint wm_state_skip_taskbar : 1;
guint wm_state_skip_pager : 1;
};
G_END_DECLS
#endif

View File

@ -23,6 +23,7 @@
#include "config.h" #include "config.h"
#include "window-x11.h" #include "window-x11.h"
#include "window-x11-private.h"
#include <string.h> #include <string.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
@ -44,6 +45,39 @@
#include "window-props.h" #include "window-props.h"
#include "xprops.h" #include "xprops.h"
struct _MetaWindowX11Class
{
MetaWindowClass parent_class;
};
G_DEFINE_TYPE_WITH_PRIVATE (MetaWindowX11, meta_window_x11, META_TYPE_WINDOW)
static void
meta_window_x11_init (MetaWindowX11 *window_x11)
{
window_x11->priv = meta_window_x11_get_instance_private (window_x11);
}
static void
meta_window_x11_get_default_skip_hints (MetaWindow *window,
gboolean *skip_taskbar_out,
gboolean *skip_pager_out)
{
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
*skip_taskbar_out = priv->wm_state_skip_taskbar;
*skip_pager_out = priv->wm_state_skip_pager;
}
static void
meta_window_x11_class_init (MetaWindowX11Class *klass)
{
MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints;
}
void void
meta_window_x11_set_net_wm_state (MetaWindow *window) meta_window_x11_set_net_wm_state (MetaWindow *window)
{ {
@ -694,6 +728,8 @@ gboolean
meta_window_x11_client_message (MetaWindow *window, meta_window_x11_client_message (MetaWindow *window,
XEvent *event) XEvent *event)
{ {
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
MetaDisplay *display; MetaDisplay *display;
display = window->display; display = window->display;
@ -879,7 +915,7 @@ meta_window_x11_client_message (MetaWindow *window,
if (first == display->atom__NET_WM_STATE_SKIP_PAGER || if (first == display->atom__NET_WM_STATE_SKIP_PAGER ||
second == display->atom__NET_WM_STATE_SKIP_PAGER) second == display->atom__NET_WM_STATE_SKIP_PAGER)
{ {
window->wm_state_skip_pager = priv->wm_state_skip_pager =
(action == _NET_WM_STATE_ADD) || (action == _NET_WM_STATE_ADD) ||
(action == _NET_WM_STATE_TOGGLE && !window->skip_pager); (action == _NET_WM_STATE_TOGGLE && !window->skip_pager);
@ -890,7 +926,7 @@ meta_window_x11_client_message (MetaWindow *window,
if (first == display->atom__NET_WM_STATE_SKIP_TASKBAR || if (first == display->atom__NET_WM_STATE_SKIP_TASKBAR ||
second == display->atom__NET_WM_STATE_SKIP_TASKBAR) second == display->atom__NET_WM_STATE_SKIP_TASKBAR)
{ {
window->wm_state_skip_taskbar = priv->wm_state_skip_taskbar =
(action == _NET_WM_STATE_ADD) || (action == _NET_WM_STATE_ADD) ||
(action == _NET_WM_STATE_TOGGLE && !window->skip_taskbar); (action == _NET_WM_STATE_TOGGLE && !window->skip_taskbar);

View File

@ -26,6 +26,20 @@
#include <meta/window.h> #include <meta/window.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
G_BEGIN_DECLS
#define META_TYPE_WINDOW_X11 (meta_window_x11_get_type())
#define META_WINDOW_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_WINDOW_X11, MetaWindowX11))
#define META_WINDOW_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_WINDOW_X11, MetaWindowX11Class))
#define META_IS_WINDOW_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_WINDOW_X11))
#define META_IS_WINDOW_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_WINDOW_X11))
#define META_WINDOW_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_WINDOW_X11, MetaWindowX11Class))
GType meta_window_x11_get_type (void);
typedef struct _MetaWindowX11 MetaWindowX11;
typedef struct _MetaWindowX11Class MetaWindowX11Class;
void meta_window_x11_set_net_wm_state (MetaWindow *window); void meta_window_x11_set_net_wm_state (MetaWindow *window);
void meta_window_x11_set_wm_state (MetaWindow *window); void meta_window_x11_set_wm_state (MetaWindow *window);

View File

@ -208,6 +208,15 @@ prefs_changed_callback (MetaPreference pref,
} }
} }
static void
meta_window_real_get_default_skip_hints (MetaWindow *window,
gboolean *skip_taskbar_out,
gboolean *skip_pager_out)
{
*skip_taskbar_out = FALSE;
*skip_pager_out = FALSE;
}
static void static void
meta_window_finalize (GObject *object) meta_window_finalize (GObject *object)
{ {
@ -365,6 +374,8 @@ meta_window_class_init (MetaWindowClass *klass)
object_class->get_property = meta_window_get_property; object_class->get_property = meta_window_get_property;
object_class->set_property = meta_window_set_property; object_class->set_property = meta_window_set_property;
klass->get_default_skip_hints = meta_window_real_get_default_skip_hints;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_TITLE, PROP_TITLE,
g_param_spec_string ("title", g_param_spec_string ("title",
@ -757,7 +768,10 @@ _meta_window_shared_new (MetaDisplay *display,
"IsUnviewable" : "IsUnviewable" :
"(unknown)"); "(unknown)");
window = g_object_new (META_TYPE_WINDOW, NULL); if (client_type == META_WINDOW_CLIENT_TYPE_X11)
window = g_object_new (META_TYPE_WINDOW_X11, NULL);
else
window = g_object_new (META_TYPE_WINDOW, NULL);
window->constructing = TRUE; window->constructing = TRUE;
@ -909,8 +923,6 @@ _meta_window_shared_new (MetaDisplay *display,
window->wm_state_modal = FALSE; window->wm_state_modal = FALSE;
window->skip_taskbar = FALSE; window->skip_taskbar = FALSE;
window->skip_pager = FALSE; window->skip_pager = FALSE;
window->wm_state_skip_taskbar = FALSE;
window->wm_state_skip_pager = FALSE;
window->wm_state_above = FALSE; window->wm_state_above = FALSE;
window->wm_state_below = FALSE; window->wm_state_below = FALSE;
window->wm_state_demands_attention = FALSE; window->wm_state_demands_attention = FALSE;
@ -7160,6 +7172,14 @@ set_allowed_actions_hint (MetaWindow *window)
#undef MAX_N_ACTIONS #undef MAX_N_ACTIONS
} }
static void
meta_window_get_default_skip_hints (MetaWindow *window,
gboolean *skip_taskbar_out,
gboolean *skip_pager_out)
{
META_WINDOW_GET_CLASS (window)->get_default_skip_hints (window, skip_taskbar_out, skip_pager_out);
}
static void static void
meta_window_recalc_skip_features (MetaWindow *window) meta_window_recalc_skip_features (MetaWindow *window)
{ {
@ -7194,8 +7214,12 @@ meta_window_recalc_skip_features (MetaWindow *window)
break; break;
case META_WINDOW_NORMAL: case META_WINDOW_NORMAL:
window->skip_taskbar = window->wm_state_skip_taskbar; {
window->skip_pager = window->wm_state_skip_pager; gboolean skip_taskbar_hint, skip_pager_hint;
meta_window_get_default_skip_hints (window, &skip_taskbar_hint, &skip_pager_hint);
window->skip_taskbar = skip_taskbar_hint;
window->skip_pager = skip_pager_hint;
}
break; break;
} }
} }