[metacity] compositor: add show_window and hide_window functions
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] compositor: add show_window and hide_window functions
- Date: Fri, 3 Mar 2017 13:22:02 +0000 (UTC)
commit a86bad86135003ba125e2b09522f28da1e7e76c1
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Mar 3 15:07:34 2017 +0200
compositor: add show_window and hide_window functions
Code / idea stolen from mutter:
https://git.gnome.org/browse/mutter/commit/?id=6726fcd25dbd335ec64a2415bb6aacf79903c6ae
https://git.gnome.org/browse/mutter/commit/?id=f0175d12347523d0c0c09255f541ec93f097af10
src/compositor/meta-compositor-none.c | 16 ++++++++
src/compositor/meta-compositor-private.h | 8 ++++
src/compositor/meta-compositor-xrender.c | 16 ++++++++
src/compositor/meta-compositor.c | 24 +++++++++++
src/core/display.c | 3 +-
src/core/screen.c | 3 +-
src/core/window-private.h | 20 ++++++++--
src/core/window.c | 63 +++++++++++++++++++++++++++--
src/include/meta-compositor.h | 17 ++++++++
9 files changed, 159 insertions(+), 11 deletions(-)
---
diff --git a/src/compositor/meta-compositor-none.c b/src/compositor/meta-compositor-none.c
index be72a46..f633790 100644
--- a/src/compositor/meta-compositor-none.c
+++ b/src/compositor/meta-compositor-none.c
@@ -57,6 +57,20 @@ meta_compositor_none_remove_window (MetaCompositor *compositor,
}
static void
+meta_compositor_none_show_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect)
+{
+}
+
+static void
+meta_compositor_none_hide_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect)
+{
+}
+
+static void
meta_compositor_none_set_updates (MetaCompositor *compositor,
MetaWindow *window,
gboolean updates)
@@ -137,6 +151,8 @@ meta_compositor_none_class_init (MetaCompositorNoneClass *none_class)
compositor_class->unmanage = meta_compositor_none_unmanage;
compositor_class->add_window = meta_compositor_none_add_window;
compositor_class->remove_window = meta_compositor_none_remove_window;
+ compositor_class->show_window = meta_compositor_none_show_window;
+ compositor_class->hide_window = meta_compositor_none_hide_window;
compositor_class->set_updates = meta_compositor_none_set_updates;
compositor_class->process_event = meta_compositor_none_process_event;
compositor_class->get_window_surface = meta_compositor_none_get_window_surface;
diff --git a/src/compositor/meta-compositor-private.h b/src/compositor/meta-compositor-private.h
index 6dcc811..bfaeb10 100644
--- a/src/compositor/meta-compositor-private.h
+++ b/src/compositor/meta-compositor-private.h
@@ -41,6 +41,14 @@ struct _MetaCompositorClass
void (* remove_window) (MetaCompositor *compositor,
MetaWindow *window);
+ void (* show_window) (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect);
+
+ void (* hide_window) (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect);
+
void (* set_updates) (MetaCompositor *compositor,
MetaWindow *window,
gboolean update);
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 7e2c62c..c036801 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -3272,6 +3272,20 @@ meta_compositor_xrender_remove_window (MetaCompositor *compositor,
}
static void
+meta_compositor_xrender_show_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect)
+{
+}
+
+static void
+meta_compositor_xrender_hide_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect)
+{
+}
+
+static void
meta_compositor_xrender_set_updates (MetaCompositor *compositor,
MetaWindow *window,
gboolean updates)
@@ -3721,6 +3735,8 @@ meta_compositor_xrender_class_init (MetaCompositorXRenderClass *xrender_class)
compositor_class->unmanage = meta_compositor_xrender_unmanage;
compositor_class->add_window = meta_compositor_xrender_add_window;
compositor_class->remove_window = meta_compositor_xrender_remove_window;
+ compositor_class->show_window = meta_compositor_xrender_show_window;
+ compositor_class->hide_window = meta_compositor_xrender_hide_window;
compositor_class->set_updates = meta_compositor_xrender_set_updates;
compositor_class->process_event = meta_compositor_xrender_process_event;
compositor_class->get_window_surface = meta_compositor_xrender_get_window_surface;
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index 40ded03..60c870d 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -227,6 +227,30 @@ meta_compositor_remove_window (MetaCompositor *compositor,
}
void
+meta_compositor_show_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect)
+{
+ MetaCompositorClass *compositor_class;
+
+ compositor_class = META_COMPOSITOR_GET_CLASS (compositor);
+
+ compositor_class->show_window (compositor, window, effect);
+}
+
+void
+meta_compositor_hide_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect)
+{
+ MetaCompositorClass *compositor_class;
+
+ compositor_class = META_COMPOSITOR_GET_CLASS (compositor);
+
+ compositor_class->hide_window (compositor, window, effect);
+}
+
+void
meta_compositor_set_updates (MetaCompositor *compositor,
MetaWindow *window,
gboolean updates)
diff --git a/src/core/display.c b/src/core/display.c
index 1091a2f..ee0a02d 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2268,7 +2268,8 @@ event_callback (XEvent *event,
Window xwindow;
xwindow = event->xmaprequest.window;
- window = meta_window_new (display, xwindow, FALSE);
+ window = meta_window_new (display, xwindow, FALSE,
+ META_EFFECT_TYPE_CREATE);
if (window != NULL)
{
diff --git a/src/core/screen.c b/src/core/screen.c
index e2cb762..51fd1d0 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -775,7 +775,8 @@ meta_screen_manage_all_windows (MetaScreen *screen)
WindowInfo *info = list->data;
MetaWindow *window;
- window = meta_window_new (screen->display, info->xwindow, TRUE);
+ window = meta_window_new (screen->display, info->xwindow, TRUE,
+ META_EFFECT_TYPE_NONE);
if (info->xwindow == screen->no_focus_window ||
info->xwindow == screen->flash_window ||
diff --git a/src/core/window-private.h b/src/core/window-private.h
index bad9176..ad9867d 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -32,7 +32,7 @@
#ifndef META_WINDOW_PRIVATE_H
#define META_WINDOW_PRIVATE_H
-#include <config.h>
+#include "meta-compositor.h"
#include "window.h"
#include "screen-private.h"
#include "util.h"
@@ -195,6 +195,17 @@ struct _MetaWindow
*/
guint mapped : 1;
+ /* Whether the compositor thinks the window is visible.
+ * This should match up with calls to meta_compositor_show_window /
+ * meta_compositor_hide_window.
+ */
+ guint visible_to_compositor : 1;
+
+ /* When we next show or hide the window, what effect we should
+ * tell the compositor to perform.
+ */
+ guint pending_compositor_effect : 4;
+
/* Iconic is the state in WM_STATE; happens for workspaces/shading
* in addition to minimize
*/
@@ -427,9 +438,10 @@ struct _MetaWindow
#define META_WINDOW_ALLOWS_HORIZONTAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) &&
(w)->size_hints.min_width < (w)->size_hints.max_width)
#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) &&
(w)->size_hints.min_height < (w)->size_hints.max_height)
-MetaWindow* meta_window_new (MetaDisplay *display,
- Window xwindow,
- gboolean must_be_viewable);
+MetaWindow* meta_window_new (MetaDisplay *display,
+ Window xwindow,
+ gboolean must_be_viewable,
+ MetaEffectType effect);
void meta_window_free (MetaWindow *window,
guint32 timestamp);
void meta_window_calc_showing (MetaWindow *window);
diff --git a/src/core/window.c b/src/core/window.c
index 9b171c6..355cc9e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -267,9 +267,10 @@ meta_window_should_attach_to_parent (MetaWindow *window)
}
MetaWindow*
-meta_window_new (MetaDisplay *display,
- Window xwindow,
- gboolean must_be_viewable)
+meta_window_new (MetaDisplay *display,
+ Window xwindow,
+ gboolean must_be_viewable,
+ MetaEffectType effect)
{
XWindowAttributes attrs;
MetaWindow *window;
@@ -508,6 +509,8 @@ meta_window_new (MetaDisplay *display,
window->tab_unminimized = FALSE;
window->iconic = FALSE;
window->mapped = attrs.map_state != IsUnmapped;
+ window->visible_to_compositor = FALSE;
+ window->pending_compositor_effect = effect;
/* if already mapped, no need to worry about focus-on-first-time-showing */
window->showing_for_first_time = !window->mapped;
/* if already mapped we don't want to do the placement thing;
@@ -2178,7 +2181,6 @@ window_would_be_covered (const MetaWindow *newbie)
return FALSE; /* none found */
}
-/* XXX META_EFFECT_*_MAP */
void
meta_window_show (MetaWindow *window)
{
@@ -2379,6 +2381,31 @@ meta_window_show (MetaWindow *window)
}
}
+ if (!window->visible_to_compositor)
+ {
+ MetaEffectType effect;
+
+ window->visible_to_compositor = TRUE;
+ effect = META_EFFECT_TYPE_NONE;
+
+ switch (window->pending_compositor_effect)
+ {
+ case META_EFFECT_TYPE_CREATE:
+ case META_EFFECT_TYPE_UNMINIMIZE:
+ effect = window->pending_compositor_effect;
+ break;
+
+ case META_EFFECT_TYPE_NONE:
+ case META_EFFECT_TYPE_DESTROY:
+ case META_EFFECT_TYPE_MINIMIZE:
+ default:
+ break;
+ }
+
+ meta_compositor_show_window (window->display->compositor, window, effect);
+ window->pending_compositor_effect = META_EFFECT_TYPE_NONE;
+ }
+
/* We don't want to worry about all cases from inside
* implement_showing(); we only want to worry about focus if this
* window has not been shown before.
@@ -2422,7 +2449,6 @@ meta_window_show (MetaWindow *window)
window->initial_timestamp_set = FALSE;
}
-/* XXX META_EFFECT_*_UNMAP */
static void
meta_window_hide (MetaWindow *window)
{
@@ -2431,6 +2457,31 @@ meta_window_hide (MetaWindow *window)
meta_topic (META_DEBUG_WINDOW_STATE,
"Hiding window %s\n", window->desc);
+ if (window->visible_to_compositor)
+ {
+ MetaEffectType effect;
+
+ window->visible_to_compositor = FALSE;
+ effect = META_EFFECT_TYPE_NONE;
+
+ switch (window->pending_compositor_effect)
+ {
+ case META_EFFECT_TYPE_DESTROY:
+ case META_EFFECT_TYPE_MINIMIZE:
+ effect = window->pending_compositor_effect;
+ break;
+
+ case META_EFFECT_TYPE_NONE:
+ case META_EFFECT_TYPE_CREATE:
+ case META_EFFECT_TYPE_UNMINIMIZE:
+ default:
+ break;
+ }
+
+ meta_compositor_hide_window (window->display->compositor, window, effect);
+ window->pending_compositor_effect = META_EFFECT_TYPE_NONE;
+ }
+
did_hide = FALSE;
if (window->frame && window->frame->mapped)
@@ -2489,6 +2540,7 @@ meta_window_minimize (MetaWindow *window)
if (!window->minimized)
{
window->minimized = TRUE;
+ window->pending_compositor_effect = META_EFFECT_TYPE_MINIMIZE;
meta_window_queue(window, META_QUEUE_CALC_SHOWING);
meta_window_foreach_transient (window,
@@ -2518,6 +2570,7 @@ meta_window_unminimize (MetaWindow *window)
if (window->minimized)
{
window->minimized = FALSE;
+ window->pending_compositor_effect = META_EFFECT_TYPE_UNMINIMIZE;
meta_window_queue(window, META_QUEUE_CALC_SHOWING);
meta_window_foreach_transient (window,
diff --git a/src/include/meta-compositor.h b/src/include/meta-compositor.h
index 719ee0f..0674711 100644
--- a/src/include/meta-compositor.h
+++ b/src/include/meta-compositor.h
@@ -37,6 +37,15 @@ typedef enum
META_COMPOSITOR_TYPE_XRENDER
} MetaCompositorType;
+typedef enum
+{
+ META_EFFECT_TYPE_NONE,
+ META_EFFECT_TYPE_CREATE,
+ META_EFFECT_TYPE_DESTROY,
+ META_EFFECT_TYPE_MINIMIZE,
+ META_EFFECT_TYPE_UNMINIMIZE,
+} MetaEffectType;
+
MetaCompositor *meta_compositor_new (MetaCompositorType type,
MetaDisplay *display);
@@ -51,6 +60,14 @@ void meta_compositor_add_window (MetaCompositor *composi
void meta_compositor_remove_window (MetaCompositor *compositor,
MetaWindow *window);
+void meta_compositor_show_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect);
+
+void meta_compositor_hide_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaEffectType effect);
+
void meta_compositor_set_updates (MetaCompositor *compositor,
MetaWindow *window,
gboolean updates);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]