2008-10-24 09:07:24 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2013-02-18 13:19:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:compositor
|
|
|
|
* @Title: MetaCompositor
|
|
|
|
* @Short_Description: Compositor API
|
2013-03-15 10:28:53 +00:00
|
|
|
*
|
|
|
|
* At a high-level, a window is not-visible or visible. When a
|
|
|
|
* window is added (with meta_compositor_add_window()) it is not visible.
|
|
|
|
* meta_compositor_show_window() indicates a transition from not-visible to
|
|
|
|
* visible. Some of the reasons for this:
|
|
|
|
*
|
|
|
|
* - Window newly created
|
|
|
|
* - Window is unminimized
|
|
|
|
* - Window is moved to the current desktop
|
|
|
|
* - Window was made sticky
|
|
|
|
*
|
|
|
|
* meta_compositor_hide_window() indicates that the window has transitioned from
|
|
|
|
* visible to not-visible. Some reasons include:
|
|
|
|
*
|
|
|
|
* - Window was destroyed
|
|
|
|
* - Window is minimized
|
|
|
|
* - Window is moved to a different desktop
|
|
|
|
* - Window no longer sticky.
|
|
|
|
*
|
|
|
|
* Note that combinations are possible - a window might have first
|
|
|
|
* been minimized and then moved to a different desktop. The 'effect' parameter
|
|
|
|
* to meta_compositor_show_window() and meta_compositor_hide_window() is a hint
|
|
|
|
* as to the appropriate effect to show the user and should not
|
|
|
|
* be considered to be indicative of a state change.
|
|
|
|
*
|
|
|
|
* When the active workspace is changed, meta_compositor_switch_workspace() is
|
|
|
|
* called first, then meta_compositor_show_window() and
|
|
|
|
* meta_compositor_hide_window() are called individually for each window
|
|
|
|
* affected, with an effect of META_COMP_EFFECT_NONE.
|
|
|
|
* If hiding windows will affect the switch workspace animation, the
|
|
|
|
* compositor needs to delay hiding the windows until the switch
|
|
|
|
* workspace animation completes.
|
|
|
|
*
|
2013-03-15 10:29:19 +00:00
|
|
|
* # Containers #
|
|
|
|
*
|
2013-05-22 16:24:00 +00:00
|
|
|
* There's two containers in the stage that are used to place window actors, here
|
2013-03-15 10:29:19 +00:00
|
|
|
* are listed in the order in which they are painted:
|
|
|
|
*
|
|
|
|
* - window group, accessible with meta_get_window_group_for_screen()
|
|
|
|
* - top window group, accessible with meta_get_top_window_group_for_screen()
|
|
|
|
*
|
|
|
|
* Mutter will place actors representing windows in the window group, except for
|
|
|
|
* override-redirect windows (ie. popups and menus) which will be placed in the
|
2013-05-22 16:24:00 +00:00
|
|
|
* top window group.
|
2013-02-18 13:19:28 +00:00
|
|
|
*/
|
2008-10-24 09:07:24 +00:00
|
|
|
|
2008-06-04 12:58:36 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2009-06-26 19:33:20 +00:00
|
|
|
#include <clutter/x11/clutter-x11.h>
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2013-02-07 22:33:17 +00:00
|
|
|
#include "core.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/screen.h>
|
|
|
|
#include <meta/errors.h>
|
|
|
|
#include <meta/window.h>
|
2009-06-25 22:56:15 +00:00
|
|
|
#include "compositor-private.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/compositor-mutter.h>
|
|
|
|
#include <meta/prefs.h>
|
2011-06-21 18:05:59 +00:00
|
|
|
#include <meta/main.h>
|
2014-08-05 12:11:59 +00:00
|
|
|
#include <meta/meta-backend.h>
|
2013-01-23 20:54:41 +00:00
|
|
|
#include <meta/meta-background-actor.h>
|
|
|
|
#include <meta/meta-background-group.h>
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/meta-shadow-factory.h>
|
2010-10-18 17:27:14 +00:00
|
|
|
#include "meta-window-actor-private.h"
|
|
|
|
#include "meta-window-group.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include "window-private.h" /* to check window->hidden */
|
2014-07-22 00:07:19 +00:00
|
|
|
#include "display-private.h" /* for meta_display_lookup_x_window() and meta_display_cancel_touch() */
|
2013-09-11 08:18:53 +00:00
|
|
|
#include "util-private.h"
|
2014-02-26 22:46:08 +00:00
|
|
|
#include "frame.h"
|
2008-06-04 12:58:36 +00:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2014-04-18 18:21:20 +00:00
|
|
|
#include "meta-sync-ring.h"
|
2008-10-24 09:07:24 +00:00
|
|
|
|
2014-04-23 17:31:44 +00:00
|
|
|
#include "backends/x11/meta-backend-x11.h"
|
|
|
|
|
2014-08-27 16:41:26 +00:00
|
|
|
#ifdef HAVE_WAYLAND
|
2014-03-19 02:01:31 +00:00
|
|
|
#include "wayland/meta-wayland-private.h"
|
2014-08-27 16:41:26 +00:00
|
|
|
#endif
|
2014-03-19 02:01:31 +00:00
|
|
|
|
2014-03-18 21:11:25 +00:00
|
|
|
static gboolean
|
|
|
|
is_modal (MetaDisplay *display)
|
|
|
|
{
|
2014-08-15 17:12:22 +00:00
|
|
|
return display->event_route == META_EVENT_ROUTE_COMPOSITOR_GRAB;
|
2014-03-18 21:11:25 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
static void sync_actor_stacking (MetaCompositor *compositor);
|
2009-06-26 19:33:20 +00:00
|
|
|
|
2008-06-04 12:58:36 +00:00
|
|
|
static void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_finish_workspace_switch (MetaCompositor *compositor)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2009-06-26 19:33:20 +00:00
|
|
|
GList *l;
|
2008-06-04 12:58:36 +00:00
|
|
|
|
Simplify relationship between mapping and visibility
Previously, changes to the visibility of a window could be indicated
by meta_compositor_map_window(), meta_compositor_unminimize_window(),
meta_compositor_set_window_hidden(), etc, with the exact behavior
depending on the 'live_hidden_windows' preference.
Simplify this so that visibility is controlled by:
meta_compositor_show_window()
meta_compositor_hide_window()
With an 'effect' parameter provided to indicate the appropriate
effect (CREATE/UNMINIMIZE/MINIMIZE/DESTROY/NONE.)
The map state of the window is signalled separately by:
meta_compositor_map_window()
meta_compositor_unmap_window()
And is used only to control resource handling.
Other changes:
* The desired effect on show/hide is explicitly stored in
MetaWindow, avoiding the need for the was_minimized flag.
At idle, once we calculate the window state, we pass the
effect to the compositor if it matches the new window
state, and then clear the effect to start over for future
map state changes.
* meta_compositor_switch_workspace() is called before any windows
are hidden or shown, allowing the compositor to avoid hiding
or showing an effect for windows involved in the switch.
http://bugzilla.gnome.org/show_bug.cgi?id=582341
* Handling of post-effect cleanups for MutterWindow are
simplified - instead of trying to do different things based
on the individual needs of different effects, we just wait until
all effects complete and sync the window state to what it
should be.
* On unmap, once we destroy the pixmap, we tell ClutterX11Pixmap
that we've done so, so it can clean up and unbind. (The
unbinding doesn't seem to be working properly because of
ClutterGLXPixmap or video driver issues.)
http://bugzilla.gnome.org/show_bug.cgi?id=587251
2009-06-28 21:10:40 +00:00
|
|
|
/* Finish hiding and showing actors for the new workspace */
|
2014-03-18 21:31:22 +00:00
|
|
|
for (l = compositor->windows; l; l = l->next)
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_window_actor_sync_visibility (l->data);
|
2008-06-06 13:17:38 +00:00
|
|
|
|
2014-03-18 21:22:42 +00:00
|
|
|
/* Fix up stacking order. */
|
2014-03-18 21:31:22 +00:00
|
|
|
sync_actor_stacking (compositor);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2009-06-26 19:33:20 +00:00
|
|
|
void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_switch_workspace_completed (MetaCompositor *compositor)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2009-06-26 19:33:20 +00:00
|
|
|
/* FIXME -- must redo stacking order */
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->switch_workspace_in_progress--;
|
|
|
|
if (compositor->switch_workspace_in_progress < 0)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2009-06-26 19:33:20 +00:00
|
|
|
g_warning ("Error in workspace_switch accounting!");
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->switch_workspace_in_progress = 0;
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (!compositor->switch_workspace_in_progress)
|
|
|
|
meta_finish_workspace_switch (compositor);
|
2009-06-26 19:33:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_destroy (MetaCompositor *compositor)
|
|
|
|
{
|
2014-04-18 18:21:20 +00:00
|
|
|
clutter_threads_remove_repaint_func (compositor->pre_paint_func_id);
|
|
|
|
clutter_threads_remove_repaint_func (compositor->post_paint_func_id);
|
|
|
|
|
|
|
|
if (compositor->have_x11_sync_object)
|
|
|
|
meta_sync_ring_destroy ();
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-25 20:29:20 +00:00
|
|
|
process_damage (MetaCompositor *compositor,
|
2010-04-06 18:10:44 +00:00
|
|
|
XDamageNotifyEvent *event,
|
|
|
|
MetaWindow *window)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2014-03-18 21:22:42 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2012-01-07 22:21:32 +00:00
|
|
|
meta_window_actor_process_x11_damage (window_actor, event);
|
2014-05-12 13:11:53 +00:00
|
|
|
|
|
|
|
compositor->frame_has_updated_xsurfaces = TRUE;
|
2008-09-24 21:53:39 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
/* compat helper */
|
|
|
|
static MetaCompositor *
|
|
|
|
get_compositor_for_screen (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
return screen->display->compositor;
|
|
|
|
}
|
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
2010-10-18 17:27:14 +00:00
|
|
|
* meta_get_stage_for_screen:
|
2010-09-01 19:39:53 +00:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The #ClutterStage for the screen
|
|
|
|
*/
|
2008-10-09 12:22:32 +00:00
|
|
|
ClutterActor *
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_get_stage_for_screen (MetaScreen *screen)
|
2008-10-09 12:22:32 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
return compositor->stage;
|
2008-10-09 12:22:32 +00:00
|
|
|
}
|
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
2010-10-18 17:27:14 +00:00
|
|
|
* meta_get_window_group_for_screen:
|
2010-09-01 19:39:53 +00:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The window group corresponding to @screen
|
|
|
|
*/
|
2008-10-28 11:30:29 +00:00
|
|
|
ClutterActor *
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_get_window_group_for_screen (MetaScreen *screen)
|
2008-10-28 11:30:29 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
return compositor->window_group;
|
2008-10-28 11:30:29 +00:00
|
|
|
}
|
|
|
|
|
2012-12-27 13:04:12 +00:00
|
|
|
/**
|
|
|
|
* meta_get_top_window_group_for_screen:
|
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The top window group corresponding to @screen
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
|
|
|
meta_get_top_window_group_for_screen (MetaScreen *screen)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
return compositor->top_window_group;
|
2012-12-27 13:04:12 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 14:46:26 +00:00
|
|
|
/**
|
|
|
|
* meta_get_feedback_group_for_screen:
|
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The feedback group corresponding to @screen
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
|
|
|
meta_get_feedback_group_for_screen (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
return compositor->feedback_group;
|
|
|
|
}
|
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
2010-10-18 17:27:14 +00:00
|
|
|
* meta_get_window_actors:
|
2010-09-01 19:39:53 +00:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
2010-10-18 17:27:14 +00:00
|
|
|
* Returns: (transfer none) (element-type Clutter.Actor): The set of #MetaWindowActor on @screen
|
2010-09-01 19:39:53 +00:00
|
|
|
*/
|
2008-10-24 09:07:24 +00:00
|
|
|
GList *
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_get_window_actors (MetaScreen *screen)
|
2008-10-24 09:07:24 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
return compositor->windows;
|
2008-10-24 09:07:24 +00:00
|
|
|
}
|
2008-10-09 12:22:32 +00:00
|
|
|
|
2009-04-23 20:33:16 +00:00
|
|
|
void
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_set_stage_input_region (MetaScreen *screen,
|
|
|
|
XserverRegion region)
|
2009-04-23 20:33:16 +00:00
|
|
|
{
|
2012-01-07 22:21:32 +00:00
|
|
|
/* As a wayland compositor we can simply ignore all this trickery
|
|
|
|
* for setting an input region on the stage for capturing events in
|
|
|
|
* clutter since all input comes to us first and we get to choose
|
|
|
|
* who else sees them.
|
|
|
|
*/
|
|
|
|
if (!meta_is_wayland_compositor ())
|
2009-04-23 20:33:16 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = screen->display;
|
|
|
|
MetaCompositor *compositor = display->compositor;
|
|
|
|
Display *xdpy = meta_display_get_xdisplay (display);
|
|
|
|
Window xstage = clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage));
|
2014-01-16 20:27:58 +00:00
|
|
|
|
2014-01-16 20:27:58 +00:00
|
|
|
XFixesSetWindowShapeRegion (xdpy, xstage, ShapeInput, 0, 0, region);
|
|
|
|
|
|
|
|
/* It's generally a good heuristic that when a crossing event is generated because
|
|
|
|
* we reshape the overlay, we don't want it to affect focus-follows-mouse focus -
|
|
|
|
* it's not the user doing something, it's the environment changing under the user.
|
|
|
|
*/
|
|
|
|
meta_display_add_ignored_crossing_serial (display, XNextRequest (xdpy));
|
2014-03-18 21:31:22 +00:00
|
|
|
XFixesSetWindowShapeRegion (xdpy, compositor->output, ShapeInput, 0, 0, region);
|
2012-01-07 22:21:32 +00:00
|
|
|
}
|
2009-04-23 20:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_empty_stage_input_region (MetaScreen *screen)
|
2009-04-23 20:33:16 +00:00
|
|
|
{
|
|
|
|
/* Using a static region here is a bit hacky, but Metacity never opens more than
|
|
|
|
* one XDisplay, so it works fine. */
|
|
|
|
static XserverRegion region = None;
|
|
|
|
|
|
|
|
if (region == None)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdpy = meta_display_get_xdisplay (display);
|
|
|
|
region = XFixesCreateRegion (xdpy, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_set_stage_input_region (screen, region);
|
2009-04-23 20:33:16 +00:00
|
|
|
}
|
|
|
|
|
2013-05-23 20:21:24 +00:00
|
|
|
void
|
|
|
|
meta_focus_stage_window (MetaScreen *screen,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
ClutterStage *stage;
|
|
|
|
Window window;
|
|
|
|
|
|
|
|
stage = CLUTTER_STAGE (meta_get_stage_for_screen (screen));
|
|
|
|
if (!stage)
|
|
|
|
return;
|
|
|
|
|
2014-02-23 17:28:51 +00:00
|
|
|
window = clutter_x11_get_stage_window (stage);
|
2013-05-23 20:21:24 +00:00
|
|
|
|
2014-02-23 17:28:51 +00:00
|
|
|
if (window == None)
|
|
|
|
return;
|
2013-05-23 20:21:24 +00:00
|
|
|
|
2014-02-23 17:28:51 +00:00
|
|
|
meta_display_set_input_focus_xwindow (screen->display,
|
|
|
|
screen,
|
|
|
|
window,
|
|
|
|
timestamp);
|
2013-05-23 20:21:24 +00:00
|
|
|
}
|
|
|
|
|
2013-05-24 21:58:55 +00:00
|
|
|
gboolean
|
|
|
|
meta_stage_is_focused (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
ClutterStage *stage;
|
2014-02-23 17:28:51 +00:00
|
|
|
Window window;
|
2013-05-24 21:58:55 +00:00
|
|
|
|
2014-02-23 17:29:21 +00:00
|
|
|
if (meta_is_wayland_compositor ())
|
|
|
|
return TRUE;
|
|
|
|
|
2013-05-24 21:58:55 +00:00
|
|
|
stage = CLUTTER_STAGE (meta_get_stage_for_screen (screen));
|
|
|
|
if (!stage)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-02-23 17:28:51 +00:00
|
|
|
window = clutter_x11_get_stage_window (stage);
|
|
|
|
|
|
|
|
if (window == None)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (screen->display->focus_xwindow == window);
|
2013-05-24 21:58:55 +00:00
|
|
|
}
|
|
|
|
|
2013-08-13 14:51:33 +00:00
|
|
|
static gboolean
|
2014-04-23 17:37:21 +00:00
|
|
|
grab_devices (MetaModalOptions options,
|
|
|
|
guint32 timestamp)
|
2009-08-12 04:12:52 +00:00
|
|
|
{
|
2014-04-23 17:37:21 +00:00
|
|
|
MetaBackend *backend = META_BACKEND (meta_get_backend ());
|
|
|
|
gboolean pointer_grabbed = FALSE;
|
|
|
|
gboolean keyboard_grabbed = FALSE;
|
2009-08-12 04:12:52 +00:00
|
|
|
|
|
|
|
if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
|
|
|
|
{
|
2014-04-23 17:37:21 +00:00
|
|
|
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp))
|
2009-08-12 04:12:52 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
pointer_grabbed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
|
|
|
|
{
|
2014-04-23 17:37:21 +00:00
|
|
|
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp))
|
2009-08-12 04:12:52 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
keyboard_grabbed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (pointer_grabbed)
|
2014-04-23 17:37:21 +00:00
|
|
|
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
|
2009-08-12 04:12:52 +00:00
|
|
|
if (keyboard_grabbed)
|
2014-04-23 17:37:21 +00:00
|
|
|
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
2009-08-12 04:12:52 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-08-13 14:51:33 +00:00
|
|
|
gboolean
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_begin_modal_for_plugin (MetaCompositor *compositor,
|
2013-08-13 14:51:33 +00:00
|
|
|
MetaPlugin *plugin,
|
|
|
|
MetaModalOptions options,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
/* To some extent this duplicates code in meta_display_begin_grab_op(), but there
|
|
|
|
* are significant differences in how we handle grabs that make it difficult to
|
|
|
|
* merge the two.
|
|
|
|
*/
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = compositor->display;
|
2013-08-13 14:51:33 +00:00
|
|
|
|
2014-03-18 21:11:25 +00:00
|
|
|
if (is_modal (display) || display->grab_op != META_GRAB_OP_NONE)
|
2013-08-13 14:51:33 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2014-04-24 15:16:55 +00:00
|
|
|
/* XXX: why is this needed? */
|
|
|
|
XIUngrabDevice (display->xdisplay,
|
|
|
|
META_VIRTUAL_CORE_POINTER_ID,
|
|
|
|
timestamp);
|
|
|
|
XSync (display->xdisplay, False);
|
|
|
|
|
2014-04-23 17:37:21 +00:00
|
|
|
if (!grab_devices (options, timestamp))
|
|
|
|
return FALSE;
|
2013-08-13 14:51:33 +00:00
|
|
|
|
|
|
|
display->grab_op = META_GRAB_OP_COMPOSITOR;
|
2014-08-15 17:12:22 +00:00
|
|
|
display->event_route = META_EVENT_ROUTE_COMPOSITOR_GRAB;
|
2013-08-13 14:51:33 +00:00
|
|
|
display->grab_window = NULL;
|
|
|
|
display->grab_have_pointer = TRUE;
|
|
|
|
display->grab_have_keyboard = TRUE;
|
|
|
|
|
2014-06-25 14:38:29 +00:00
|
|
|
g_signal_emit_by_name (display, "grab-op-begin",
|
|
|
|
meta_plugin_get_screen (plugin),
|
|
|
|
display->grab_window, display->grab_op);
|
|
|
|
|
2014-03-11 17:45:39 +00:00
|
|
|
if (meta_is_wayland_compositor ())
|
2014-07-22 00:07:19 +00:00
|
|
|
{
|
|
|
|
meta_display_sync_wayland_input_focus (display);
|
|
|
|
meta_display_cancel_touch (display);
|
|
|
|
}
|
2014-03-11 17:45:39 +00:00
|
|
|
|
2013-08-13 14:51:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-08-12 04:12:52 +00:00
|
|
|
void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_end_modal_for_plugin (MetaCompositor *compositor,
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaPlugin *plugin,
|
|
|
|
guint32 timestamp)
|
2009-08-12 04:12:52 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = compositor->display;
|
2014-04-23 17:37:21 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
2009-08-12 04:12:52 +00:00
|
|
|
|
2014-03-18 21:11:25 +00:00
|
|
|
g_return_if_fail (is_modal (display));
|
2009-08-12 04:12:52 +00:00
|
|
|
|
2014-06-25 14:38:29 +00:00
|
|
|
g_signal_emit_by_name (display, "grab-op-end",
|
|
|
|
meta_plugin_get_screen (plugin),
|
|
|
|
display->grab_window, display->grab_op);
|
|
|
|
|
2009-08-12 04:12:52 +00:00
|
|
|
display->grab_op = META_GRAB_OP_NONE;
|
2014-08-15 17:12:22 +00:00
|
|
|
display->event_route = META_EVENT_ROUTE_NORMAL;
|
2009-08-12 04:12:52 +00:00
|
|
|
display->grab_window = NULL;
|
|
|
|
display->grab_have_pointer = FALSE;
|
|
|
|
display->grab_have_keyboard = FALSE;
|
2014-03-11 17:45:39 +00:00
|
|
|
|
2014-04-23 17:37:21 +00:00
|
|
|
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
|
|
|
|
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
|
|
|
|
2014-03-11 17:45:39 +00:00
|
|
|
if (meta_is_wayland_compositor ())
|
2014-04-23 17:37:21 +00:00
|
|
|
meta_display_sync_wayland_input_focus (display);
|
2009-08-12 04:12:52 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 20:49:06 +00:00
|
|
|
static void
|
|
|
|
after_stage_paint (ClutterStage *stage,
|
|
|
|
gpointer data)
|
2011-06-13 22:09:59 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = data;
|
2011-06-13 22:09:59 +00:00
|
|
|
GList *l;
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
for (l = compositor->windows; l; l = l->next)
|
2011-06-13 22:09:59 +00:00
|
|
|
meta_window_actor_post_paint (l->data);
|
2013-12-03 19:43:53 +00:00
|
|
|
|
2014-08-14 00:19:35 +00:00
|
|
|
#ifdef HAVE_WAYLAND
|
2013-12-05 20:39:40 +00:00
|
|
|
if (meta_is_wayland_compositor ())
|
|
|
|
meta_wayland_compositor_paint_finished (meta_wayland_compositor_get_default ());
|
2014-08-14 00:19:35 +00:00
|
|
|
#endif
|
2011-06-13 22:09:59 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 19:41:11 +00:00
|
|
|
static void
|
2014-03-18 21:31:22 +00:00
|
|
|
redirect_windows (MetaScreen *screen)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2013-03-01 19:41:11 +00:00
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
Window xroot = meta_screen_get_xroot (screen);
|
|
|
|
int screen_number = meta_screen_get_screen_number (screen);
|
|
|
|
guint n_retries;
|
|
|
|
guint max_retries;
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2011-06-21 18:05:59 +00:00
|
|
|
if (meta_get_replace_current_wm ())
|
|
|
|
max_retries = 5;
|
|
|
|
else
|
|
|
|
max_retries = 1;
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2011-06-21 18:05:59 +00:00
|
|
|
n_retries = 0;
|
|
|
|
|
2011-06-30 19:23:41 +00:00
|
|
|
/* Some compositors (like old versions of Mutter) might not properly unredirect
|
|
|
|
* subwindows before destroying the WM selection window; so we wait a while
|
|
|
|
* for such a compositor to exit before giving up.
|
2011-06-21 18:05:59 +00:00
|
|
|
*/
|
|
|
|
while (TRUE)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2014-04-06 19:52:44 +00:00
|
|
|
meta_error_trap_push (display);
|
2011-06-21 18:05:59 +00:00
|
|
|
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
|
|
|
XSync (xdisplay, FALSE);
|
|
|
|
|
|
|
|
if (!meta_error_trap_pop_with_return (display))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (n_retries == max_retries)
|
2011-06-30 19:23:41 +00:00
|
|
|
{
|
|
|
|
/* This probably means that a non-WM compositor like xcompmgr is running;
|
|
|
|
* we have no way to get it to exit */
|
|
|
|
meta_fatal (_("Another compositing manager is already running on screen %i on display \"%s\"."),
|
|
|
|
screen_number, display->name);
|
|
|
|
}
|
2011-06-21 18:05:59 +00:00
|
|
|
|
|
|
|
n_retries++;
|
|
|
|
g_usleep (G_USEC_PER_SEC);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
2013-03-01 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_compositor_manage (MetaCompositor *compositor)
|
2013-03-01 19:41:11 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = compositor->display;
|
|
|
|
Display *xdisplay = display->xdisplay;
|
|
|
|
MetaScreen *screen = display->screen;
|
2014-04-18 18:21:20 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
2013-03-01 19:41:11 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_screen_set_cm_selection (display->screen);
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2014-04-18 18:21:20 +00:00
|
|
|
compositor->stage = meta_backend_get_stage (backend);
|
2013-03-02 12:15:23 +00:00
|
|
|
|
2014-07-16 14:41:48 +00:00
|
|
|
/* We use connect_after() here to accomodate code in GNOME Shell that,
|
|
|
|
* when benchmarking drawing performance, connects to ::after-paint
|
|
|
|
* and calls glFinish(). The timing information from that will be
|
|
|
|
* more accurate if we hold off until that completes before we signal
|
|
|
|
* apps to begin drawing the next frame. If there are no other
|
|
|
|
* connections to ::after-paint, connect() vs. connect_after() doesn't
|
|
|
|
* matter.
|
|
|
|
*/
|
|
|
|
g_signal_connect_after (CLUTTER_STAGE (compositor->stage), "after-paint",
|
|
|
|
G_CALLBACK (after_stage_paint), compositor);
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
clutter_stage_set_sync_delay (CLUTTER_STAGE (compositor->stage), META_SYNC_DELAY);
|
2012-11-12 18:39:59 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->window_group = meta_window_group_new (screen);
|
|
|
|
compositor->top_window_group = meta_window_group_new (screen);
|
2014-10-06 14:46:26 +00:00
|
|
|
compositor->feedback_group = meta_window_group_new (screen);
|
2008-10-02 11:16:15 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
clutter_actor_add_child (compositor->stage, compositor->window_group);
|
|
|
|
clutter_actor_add_child (compositor->stage, compositor->top_window_group);
|
2014-10-06 14:46:26 +00:00
|
|
|
clutter_actor_add_child (compositor->stage, compositor->feedback_group);
|
2008-10-02 11:16:15 +00:00
|
|
|
|
2012-01-07 22:21:32 +00:00
|
|
|
if (meta_is_wayland_compositor ())
|
2009-04-23 20:33:16 +00:00
|
|
|
{
|
2012-01-07 22:21:32 +00:00
|
|
|
/* NB: When running as a wayland compositor we don't need an X
|
|
|
|
* composite overlay window, and we don't need to play any input
|
|
|
|
* region tricks to redirect events into clutter. */
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->output = None;
|
2009-04-23 20:33:16 +00:00
|
|
|
}
|
2012-01-07 22:21:32 +00:00
|
|
|
else
|
|
|
|
{
|
2014-08-13 23:46:32 +00:00
|
|
|
Window xwin;
|
|
|
|
|
2014-07-15 20:24:27 +00:00
|
|
|
compositor->output = screen->composite_overlay_window;
|
|
|
|
|
2014-04-18 18:21:20 +00:00
|
|
|
xwin = meta_backend_x11_get_xwindow (META_BACKEND_X11 (backend));
|
2014-08-13 23:46:32 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
XReparentWindow (xdisplay, xwin, compositor->output, 0, 0);
|
2012-01-07 22:21:32 +00:00
|
|
|
|
2014-01-16 20:27:58 +00:00
|
|
|
meta_empty_stage_input_region (screen);
|
|
|
|
|
2014-05-02 13:34:02 +00:00
|
|
|
/* Make sure there isn't any left-over output shape on the
|
2012-01-07 22:21:32 +00:00
|
|
|
* overlay window by setting the whole screen to be an
|
|
|
|
* output region.
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2012-01-07 22:21:32 +00:00
|
|
|
* Note: there doesn't seem to be any real chance of that
|
|
|
|
* because the X server will destroy the overlay window
|
|
|
|
* when the last client using it exits.
|
|
|
|
*/
|
2014-03-18 21:31:22 +00:00
|
|
|
XFixesSetWindowShapeRegion (xdisplay, compositor->output, ShapeBounding, 0, 0, None);
|
2009-04-23 20:33:16 +00:00
|
|
|
|
2012-01-07 22:21:32 +00:00
|
|
|
/* Map overlay window before redirecting windows offscreen so we catch their
|
|
|
|
* contents until we show the stage.
|
|
|
|
*/
|
2014-03-18 21:31:22 +00:00
|
|
|
XMapWindow (xdisplay, compositor->output);
|
2014-04-18 18:21:20 +00:00
|
|
|
|
2015-08-12 13:26:34 +00:00
|
|
|
compositor->have_x11_sync_object = meta_sync_ring_init (xdisplay);
|
2012-01-07 22:21:32 +00:00
|
|
|
}
|
2013-11-19 20:37:31 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
redirect_windows (display->screen);
|
2013-11-25 11:00:55 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->plugin_mgr = meta_plugin_manager_new (compositor);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_compositor_unmanage (MetaCompositor *compositor)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2012-01-07 22:21:32 +00:00
|
|
|
if (!meta_is_wayland_compositor ())
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = compositor->display;
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
Window xroot = display->screen->xroot;
|
2012-01-07 22:21:32 +00:00
|
|
|
|
|
|
|
/* This is the most important part of cleanup - we have to do this
|
|
|
|
* before giving up the window manager selection or the next
|
|
|
|
* window manager won't be able to redirect subwindows */
|
|
|
|
XCompositeUnredirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
|
|
|
}
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 21:34:07 +00:00
|
|
|
/**
|
|
|
|
* meta_shape_cow_for_window:
|
2014-03-18 21:31:22 +00:00
|
|
|
* @compositor: A #MetaCompositor
|
2014-05-28 19:44:23 +00:00
|
|
|
* @window: (nullable): A #MetaWindow to shape the COW for
|
2014-03-18 21:34:07 +00:00
|
|
|
*
|
|
|
|
* Sets an bounding shape on the COW so that the given window
|
|
|
|
* is exposed. If @window is %NULL it clears the shape again.
|
|
|
|
*
|
|
|
|
* Used so we can unredirect windows, by shaping away the part
|
|
|
|
* of the COW, letting the raw window be seen through below.
|
2011-08-27 09:43:09 +00:00
|
|
|
*/
|
|
|
|
static void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_shape_cow_for_window (MetaCompositor *compositor,
|
2014-03-18 21:34:07 +00:00
|
|
|
MetaWindow *window)
|
2011-08-27 09:43:09 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = compositor->display;
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
2011-08-27 09:43:09 +00:00
|
|
|
|
2014-03-18 21:34:07 +00:00
|
|
|
if (window == NULL)
|
2014-03-18 21:31:22 +00:00
|
|
|
XFixesSetWindowShapeRegion (xdisplay, compositor->output, ShapeBounding, 0, 0, None);
|
2011-08-27 09:43:09 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
XserverRegion output_region;
|
2011-09-15 19:50:28 +00:00
|
|
|
XRectangle screen_rect, window_bounds;
|
2011-08-27 09:43:09 +00:00
|
|
|
int width, height;
|
2011-09-15 19:50:28 +00:00
|
|
|
MetaRectangle rect;
|
|
|
|
|
2014-03-18 21:34:07 +00:00
|
|
|
meta_window_get_frame_rect (window, &rect);
|
2011-09-15 19:50:28 +00:00
|
|
|
|
|
|
|
window_bounds.x = rect.x;
|
|
|
|
window_bounds.y = rect.y;
|
|
|
|
window_bounds.width = rect.width;
|
|
|
|
window_bounds.height = rect.height;
|
2011-08-27 09:43:09 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_screen_get_size (display->screen, &width, &height);
|
2011-08-27 09:43:09 +00:00
|
|
|
screen_rect.x = 0;
|
|
|
|
screen_rect.y = 0;
|
|
|
|
screen_rect.width = width;
|
|
|
|
screen_rect.height = height;
|
|
|
|
|
2011-09-15 19:50:28 +00:00
|
|
|
output_region = XFixesCreateRegion (xdisplay, &window_bounds, 1);
|
|
|
|
|
2011-08-27 09:43:09 +00:00
|
|
|
XFixesInvertRegion (xdisplay, output_region, &screen_rect, output_region);
|
2014-03-18 21:31:22 +00:00
|
|
|
XFixesSetWindowShapeRegion (xdisplay, compositor->output, ShapeBounding, 0, 0, output_region);
|
2011-08-27 09:43:09 +00:00
|
|
|
XFixesDestroyRegion (xdisplay, output_region);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-06 22:10:44 +00:00
|
|
|
static void
|
2014-03-18 21:31:22 +00:00
|
|
|
set_unredirected_window (MetaCompositor *compositor,
|
2013-12-06 22:10:44 +00:00
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->unredirected_window == window)
|
2013-12-06 22:10:44 +00:00
|
|
|
return;
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->unredirected_window != NULL)
|
2013-12-06 22:10:44 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (compositor->unredirected_window));
|
2013-12-06 22:36:09 +00:00
|
|
|
meta_window_actor_set_unredirected (window_actor, FALSE);
|
2013-12-06 22:10:44 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 14:18:06 +00:00
|
|
|
meta_shape_cow_for_window (compositor, window);
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->unredirected_window = window;
|
2013-12-06 22:10:44 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->unredirected_window != NULL)
|
2013-12-06 22:10:44 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (compositor->unredirected_window));
|
2013-12-06 22:36:09 +00:00
|
|
|
meta_window_actor_set_unredirected (window_actor, TRUE);
|
2013-12-06 22:10:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
|
|
|
meta_compositor_add_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = compositor->display;
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2014-02-24 17:56:30 +00:00
|
|
|
meta_error_trap_push (display);
|
2008-10-24 09:07:24 +00:00
|
|
|
|
2014-03-18 21:22:42 +00:00
|
|
|
meta_window_actor_new (window);
|
2014-03-18 21:31:22 +00:00
|
|
|
sync_actor_stacking (compositor);
|
2008-11-23 19:28:40 +00:00
|
|
|
|
2010-10-25 18:44:30 +00:00
|
|
|
meta_error_trap_pop (display);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
|
|
|
meta_compositor_remove_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2014-03-18 21:22:42 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2012-01-07 22:21:32 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->unredirected_window == window)
|
|
|
|
set_unredirected_window (compositor, NULL);
|
2011-08-27 09:43:09 +00:00
|
|
|
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_window_actor_destroy (window_actor);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
2014-06-17 17:06:10 +00:00
|
|
|
meta_compositor_sync_updates_frozen (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2014-03-18 21:22:42 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2014-06-17 17:06:10 +00:00
|
|
|
meta_window_actor_sync_updates_frozen (window_actor);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 18:40:55 +00:00
|
|
|
void
|
|
|
|
meta_compositor_queue_frame_drawn (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean no_delay_frame)
|
|
|
|
{
|
2014-03-18 21:22:42 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2013-02-14 18:40:55 +00:00
|
|
|
meta_window_actor_queue_frame_drawn (window_actor, no_delay_frame);
|
|
|
|
}
|
|
|
|
|
2011-07-20 04:29:06 +00:00
|
|
|
void
|
2014-02-27 01:45:38 +00:00
|
|
|
meta_compositor_window_shape_changed (MetaCompositor *compositor,
|
2013-08-24 02:20:49 +00:00
|
|
|
MetaWindow *window)
|
2011-07-20 04:29:06 +00:00
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2013-03-14 02:34:20 +00:00
|
|
|
if (!window_actor)
|
|
|
|
return;
|
|
|
|
|
2014-02-27 01:45:38 +00:00
|
|
|
meta_window_actor_update_shape (window_actor);
|
2011-07-20 04:29:06 +00:00
|
|
|
}
|
|
|
|
|
2013-12-06 18:44:31 +00:00
|
|
|
void
|
|
|
|
meta_compositor_window_opacity_changed (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
if (!window_actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_window_actor_update_opacity (window_actor);
|
|
|
|
}
|
|
|
|
|
2014-02-25 00:22:56 +00:00
|
|
|
void
|
|
|
|
meta_compositor_window_surface_changed (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
if (!window_actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_window_actor_update_surface (window_actor);
|
|
|
|
}
|
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
|
|
|
* meta_compositor_process_event: (skip)
|
2014-05-02 13:34:02 +00:00
|
|
|
* @compositor:
|
|
|
|
* @event:
|
|
|
|
* @window:
|
2010-09-01 19:39:53 +00:00
|
|
|
*
|
|
|
|
*/
|
2009-06-25 20:17:27 +00:00
|
|
|
gboolean
|
|
|
|
meta_compositor_process_event (MetaCompositor *compositor,
|
|
|
|
XEvent *event,
|
|
|
|
MetaWindow *window)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2013-12-06 18:44:31 +00:00
|
|
|
if (!meta_is_wayland_compositor () &&
|
|
|
|
event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2013-12-06 18:44:31 +00:00
|
|
|
/* Core code doesn't handle damage events, so we need to extract the MetaWindow
|
|
|
|
* ourselves
|
|
|
|
*/
|
|
|
|
if (window == NULL)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2013-12-06 18:44:31 +00:00
|
|
|
Window xwin = ((XDamageNotifyEvent *) event)->drawable;
|
|
|
|
window = meta_display_lookup_x_window (compositor->display, xwin);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
2013-12-06 18:44:31 +00:00
|
|
|
|
2014-03-27 12:57:53 +00:00
|
|
|
if (window)
|
|
|
|
process_damage (compositor, (XDamageNotifyEvent *) event, window);
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
2008-08-18 14:44:26 +00:00
|
|
|
|
2015-08-12 13:26:34 +00:00
|
|
|
if (compositor->have_x11_sync_object)
|
|
|
|
meta_sync_ring_handle_event (event);
|
|
|
|
|
2009-01-30 11:57:46 +00:00
|
|
|
/* Clutter needs to know about MapNotify events otherwise it will
|
|
|
|
think the stage is invisible */
|
2012-01-07 22:21:32 +00:00
|
|
|
if (!meta_is_wayland_compositor () && event->type == MapNotify)
|
2009-01-30 11:57:46 +00:00
|
|
|
clutter_x11_handle_event (event);
|
|
|
|
|
2008-11-22 18:07:32 +00:00
|
|
|
/* The above handling is basically just "observing" the events, so we return
|
|
|
|
* FALSE to indicate that the event should not be filtered out; if we have
|
|
|
|
* GTK+ windows in the same process, GTK+ needs the ConfigureNotify event, for example.
|
|
|
|
*/
|
|
|
|
return FALSE;
|
2008-06-04 12:58:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-10 00:27:18 +00:00
|
|
|
gboolean
|
|
|
|
meta_compositor_filter_keybinding (MetaCompositor *compositor,
|
|
|
|
MetaKeyBinding *binding)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
return meta_plugin_manager_filter_keybinding (compositor->plugin_mgr, binding);
|
2012-08-10 00:27:18 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
Simplify relationship between mapping and visibility
Previously, changes to the visibility of a window could be indicated
by meta_compositor_map_window(), meta_compositor_unminimize_window(),
meta_compositor_set_window_hidden(), etc, with the exact behavior
depending on the 'live_hidden_windows' preference.
Simplify this so that visibility is controlled by:
meta_compositor_show_window()
meta_compositor_hide_window()
With an 'effect' parameter provided to indicate the appropriate
effect (CREATE/UNMINIMIZE/MINIMIZE/DESTROY/NONE.)
The map state of the window is signalled separately by:
meta_compositor_map_window()
meta_compositor_unmap_window()
And is used only to control resource handling.
Other changes:
* The desired effect on show/hide is explicitly stored in
MetaWindow, avoiding the need for the was_minimized flag.
At idle, once we calculate the window state, we pass the
effect to the compositor if it matches the new window
state, and then clear the effect to start over for future
map state changes.
* meta_compositor_switch_workspace() is called before any windows
are hidden or shown, allowing the compositor to avoid hiding
or showing an effect for windows involved in the switch.
http://bugzilla.gnome.org/show_bug.cgi?id=582341
* Handling of post-effect cleanups for MutterWindow are
simplified - instead of trying to do different things based
on the individual needs of different effects, we just wait until
all effects complete and sync the window state to what it
should be.
* On unmap, once we destroy the pixmap, we tell ClutterX11Pixmap
that we've done so, so it can clean up and unbind. (The
unbinding doesn't seem to be working properly because of
ClutterGLXPixmap or video driver issues.)
http://bugzilla.gnome.org/show_bug.cgi?id=587251
2009-06-28 21:10:40 +00:00
|
|
|
meta_compositor_show_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaCompEffect effect)
|
2008-06-09 16:50:56 +00:00
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2014-03-18 21:22:42 +00:00
|
|
|
meta_window_actor_show (window_actor, effect);
|
2008-11-23 19:28:40 +00:00
|
|
|
}
|
2008-06-09 16:50:56 +00:00
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
Simplify relationship between mapping and visibility
Previously, changes to the visibility of a window could be indicated
by meta_compositor_map_window(), meta_compositor_unminimize_window(),
meta_compositor_set_window_hidden(), etc, with the exact behavior
depending on the 'live_hidden_windows' preference.
Simplify this so that visibility is controlled by:
meta_compositor_show_window()
meta_compositor_hide_window()
With an 'effect' parameter provided to indicate the appropriate
effect (CREATE/UNMINIMIZE/MINIMIZE/DESTROY/NONE.)
The map state of the window is signalled separately by:
meta_compositor_map_window()
meta_compositor_unmap_window()
And is used only to control resource handling.
Other changes:
* The desired effect on show/hide is explicitly stored in
MetaWindow, avoiding the need for the was_minimized flag.
At idle, once we calculate the window state, we pass the
effect to the compositor if it matches the new window
state, and then clear the effect to start over for future
map state changes.
* meta_compositor_switch_workspace() is called before any windows
are hidden or shown, allowing the compositor to avoid hiding
or showing an effect for windows involved in the switch.
http://bugzilla.gnome.org/show_bug.cgi?id=582341
* Handling of post-effect cleanups for MutterWindow are
simplified - instead of trying to do different things based
on the individual needs of different effects, we just wait until
all effects complete and sync the window state to what it
should be.
* On unmap, once we destroy the pixmap, we tell ClutterX11Pixmap
that we've done so, so it can clean up and unbind. (The
unbinding doesn't seem to be working properly because of
ClutterGLXPixmap or video driver issues.)
http://bugzilla.gnome.org/show_bug.cgi?id=587251
2009-06-28 21:10:40 +00:00
|
|
|
meta_compositor_hide_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaCompEffect effect)
|
2008-11-23 19:28:40 +00:00
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
meta_window_actor_hide (window_actor, effect);
|
2008-06-09 16:50:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
2015-07-06 04:08:08 +00:00
|
|
|
meta_compositor_size_change_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaSizeChange which_change,
|
|
|
|
MetaRectangle *old_frame_rect,
|
|
|
|
MetaRectangle *old_buffer_rect)
|
2008-08-19 10:47:30 +00:00
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2015-10-12 15:55:51 +00:00
|
|
|
meta_window_actor_size_change (window_actor, which_change, old_frame_rect, old_buffer_rect);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
|
|
|
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
|
|
|
MetaWorkspace *from,
|
|
|
|
MetaWorkspace *to,
|
|
|
|
MetaMotionDirection direction)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
gint to_indx, from_indx;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
|
|
|
to_indx = meta_workspace_index (to);
|
|
|
|
from_indx = meta_workspace_index (from);
|
2008-11-07 10:13:40 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->switch_workspace_in_progress++;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (!meta_plugin_manager_switch_workspace (compositor->plugin_mgr,
|
|
|
|
from_indx,
|
|
|
|
to_indx,
|
2014-03-18 22:12:29 +00:00
|
|
|
direction))
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->switch_workspace_in_progress--;
|
2008-10-24 09:07:24 +00:00
|
|
|
|
|
|
|
/* We have to explicitely call this to fix up stacking order of the
|
|
|
|
* actors; this is because the abs stacking position of actors does not
|
|
|
|
* necessarily change during the window hiding/unhiding, only their
|
|
|
|
* relative position toward the destkop window.
|
|
|
|
*/
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_finish_workspace_switch (compositor);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
2008-08-19 10:47:30 +00:00
|
|
|
}
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2008-11-23 19:28:40 +00:00
|
|
|
static void
|
2014-03-18 21:31:22 +00:00
|
|
|
sync_actor_stacking (MetaCompositor *compositor)
|
2008-11-23 19:28:40 +00:00
|
|
|
{
|
2010-11-13 19:45:01 +00:00
|
|
|
GList *children;
|
2013-02-14 04:10:33 +00:00
|
|
|
GList *expected_window_node;
|
2008-11-23 19:28:40 +00:00
|
|
|
GList *tmp;
|
2010-11-13 19:45:01 +00:00
|
|
|
GList *old;
|
2013-01-23 20:54:41 +00:00
|
|
|
GList *backgrounds;
|
2013-02-14 04:10:33 +00:00
|
|
|
gboolean has_windows;
|
2010-11-13 19:45:01 +00:00
|
|
|
gboolean reordered;
|
2008-12-18 12:41:56 +00:00
|
|
|
|
2010-11-13 19:45:01 +00:00
|
|
|
/* NB: The first entries in the lists are stacked the lowest */
|
2008-11-23 19:28:40 +00:00
|
|
|
|
2010-11-13 19:45:01 +00:00
|
|
|
/* Restacking will trigger full screen redraws, so it's worth a
|
|
|
|
* little effort to make sure we actually need to restack before
|
|
|
|
* we go ahead and do it */
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
children = clutter_actor_get_children (compositor->window_group);
|
2013-09-03 20:03:17 +00:00
|
|
|
has_windows = FALSE;
|
2010-11-13 19:45:01 +00:00
|
|
|
reordered = FALSE;
|
|
|
|
|
2010-11-14 17:37:17 +00:00
|
|
|
/* We allow for actors in the window group other than the actors we
|
|
|
|
* know about, but it's up to a plugin to try and keep them stacked correctly
|
|
|
|
* (we really need extra API to make that reliable.)
|
|
|
|
*/
|
|
|
|
|
2013-01-23 20:54:41 +00:00
|
|
|
/* First we collect a list of all backgrounds, and check if they're at the
|
|
|
|
* bottom. Then we check if the window actors are in the correct sequence */
|
|
|
|
backgrounds = NULL;
|
2014-03-18 21:31:22 +00:00
|
|
|
expected_window_node = compositor->windows;
|
2013-02-14 04:10:33 +00:00
|
|
|
for (old = children; old != NULL; old = old->next)
|
2010-11-14 17:37:17 +00:00
|
|
|
{
|
2013-02-14 04:10:33 +00:00
|
|
|
ClutterActor *actor = old->data;
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2013-01-23 20:54:41 +00:00
|
|
|
if (META_IS_BACKGROUND_GROUP (actor) ||
|
|
|
|
META_IS_BACKGROUND_ACTOR (actor))
|
2010-11-13 19:45:01 +00:00
|
|
|
{
|
2013-01-23 20:54:41 +00:00
|
|
|
backgrounds = g_list_prepend (backgrounds, actor);
|
|
|
|
|
2013-02-14 04:10:33 +00:00
|
|
|
if (has_windows)
|
|
|
|
reordered = TRUE;
|
2010-11-13 19:45:01 +00:00
|
|
|
}
|
2013-02-14 04:10:33 +00:00
|
|
|
else if (META_IS_WINDOW_ACTOR (actor) && !reordered)
|
|
|
|
{
|
|
|
|
has_windows = TRUE;
|
2010-11-13 19:45:01 +00:00
|
|
|
|
2013-02-14 04:10:33 +00:00
|
|
|
if (expected_window_node != NULL && actor == expected_window_node->data)
|
|
|
|
expected_window_node = expected_window_node->next;
|
|
|
|
else
|
|
|
|
reordered = TRUE;
|
|
|
|
}
|
2010-11-13 19:45:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
|
|
|
|
if (!reordered)
|
2013-01-23 20:54:41 +00:00
|
|
|
{
|
|
|
|
g_list_free (backgrounds);
|
|
|
|
return;
|
|
|
|
}
|
2010-11-13 19:45:01 +00:00
|
|
|
|
2013-02-14 04:10:33 +00:00
|
|
|
/* reorder the actors by lowering them in turn to the bottom of the stack.
|
2013-03-12 16:01:51 +00:00
|
|
|
* windows first, then background.
|
|
|
|
*
|
|
|
|
* We reorder the actors even if they're not parented to the window group,
|
|
|
|
* to allow stacking to work with intermediate actors (eg during effects)
|
|
|
|
*/
|
2014-03-18 21:31:22 +00:00
|
|
|
for (tmp = g_list_last (compositor->windows); tmp != NULL; tmp = tmp->prev)
|
2008-11-23 19:28:40 +00:00
|
|
|
{
|
2013-03-12 16:01:51 +00:00
|
|
|
ClutterActor *actor = tmp->data, *parent;
|
2008-11-23 19:28:40 +00:00
|
|
|
|
2013-03-12 16:01:51 +00:00
|
|
|
parent = clutter_actor_get_parent (actor);
|
|
|
|
clutter_actor_set_child_below_sibling (parent, actor, NULL);
|
2008-11-23 19:28:40 +00:00
|
|
|
}
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2013-01-23 20:54:41 +00:00
|
|
|
/* we prepended the backgrounds above so the last actor in the list
|
|
|
|
* should get lowered to the bottom last.
|
|
|
|
*/
|
|
|
|
for (tmp = backgrounds; tmp != NULL; tmp = tmp->next)
|
|
|
|
{
|
2013-03-12 16:01:51 +00:00
|
|
|
ClutterActor *actor = tmp->data, *parent;
|
2013-01-23 20:54:41 +00:00
|
|
|
|
2013-03-12 16:01:51 +00:00
|
|
|
parent = clutter_actor_get_parent (actor);
|
|
|
|
clutter_actor_set_child_below_sibling (parent, actor, NULL);
|
2013-01-23 20:54:41 +00:00
|
|
|
}
|
|
|
|
g_list_free (backgrounds);
|
2008-11-23 19:28:40 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
|
|
|
meta_compositor_sync_stack (MetaCompositor *compositor,
|
|
|
|
GList *stack)
|
2008-10-24 09:07:24 +00:00
|
|
|
{
|
2009-06-26 21:05:11 +00:00
|
|
|
GList *old_stack;
|
2008-11-27 13:40:52 +00:00
|
|
|
|
2009-06-26 21:05:11 +00:00
|
|
|
/* This is painful because hidden windows that we are in the process
|
|
|
|
* of animating out of existence. They'll be at the bottom of the
|
|
|
|
* stack of X windows, but we want to leave them in their old position
|
|
|
|
* until the animation effect finishes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Sources: first window is the highest */
|
|
|
|
stack = g_list_copy (stack); /* The new stack of MetaWindow */
|
2014-03-18 21:31:22 +00:00
|
|
|
old_stack = g_list_reverse (compositor->windows); /* The old stack of MetaWindowActor */
|
|
|
|
compositor->windows = NULL;
|
2009-06-26 21:05:11 +00:00
|
|
|
|
|
|
|
while (TRUE)
|
2008-10-24 09:07:24 +00:00
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaWindowActor *old_actor = NULL, *stack_actor = NULL, *actor;
|
2009-06-26 21:05:11 +00:00
|
|
|
MetaWindow *old_window = NULL, *stack_window = NULL, *window;
|
2008-11-03 14:50:22 +00:00
|
|
|
|
2009-06-26 21:05:11 +00:00
|
|
|
/* Find the remaining top actor in our existing stack (ignoring
|
|
|
|
* windows that have been hidden and are no longer animating) */
|
|
|
|
while (old_stack)
|
|
|
|
{
|
|
|
|
old_actor = old_stack->data;
|
2010-10-18 17:27:14 +00:00
|
|
|
old_window = meta_window_actor_get_meta_window (old_actor);
|
2009-06-26 21:05:11 +00:00
|
|
|
|
2014-09-10 20:24:26 +00:00
|
|
|
if ((old_window->hidden || old_window->unmanaging) &&
|
2010-10-18 17:27:14 +00:00
|
|
|
!meta_window_actor_effect_in_progress (old_actor))
|
2011-01-26 21:35:18 +00:00
|
|
|
{
|
|
|
|
old_stack = g_list_delete_link (old_stack, old_stack);
|
|
|
|
old_actor = NULL;
|
|
|
|
}
|
2009-06-26 21:05:11 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And the remaining top actor in the new stack */
|
|
|
|
while (stack)
|
|
|
|
{
|
|
|
|
stack_window = stack->data;
|
2010-10-18 17:27:14 +00:00
|
|
|
stack_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (stack_window));
|
2009-06-26 21:05:11 +00:00
|
|
|
if (!stack_actor)
|
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_verbose ("Failed to find corresponding MetaWindowActor "
|
2009-06-26 21:05:11 +00:00
|
|
|
"for window %s\n", meta_window_get_description (stack_window));
|
|
|
|
stack = g_list_delete_link (stack, stack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!old_actor && !stack_actor) /* Nothing more to stack */
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* We usually prefer the window in the new stack, but if if we
|
|
|
|
* found a hidden window in the process of being animated out
|
|
|
|
* of existence in the old stack we use that instead. We've
|
|
|
|
* filtered out non-animating hidden windows above.
|
|
|
|
*/
|
|
|
|
if (old_actor &&
|
2014-09-10 20:24:26 +00:00
|
|
|
(!stack_actor || old_window->hidden || old_window->unmanaging))
|
2009-06-26 21:05:11 +00:00
|
|
|
{
|
|
|
|
actor = old_actor;
|
|
|
|
window = old_window;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actor = stack_actor;
|
|
|
|
window = stack_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OK, we know what actor we want next. Add it to our window
|
|
|
|
* list, and remove it from both source lists. (It will
|
|
|
|
* be at the front of at least one, hopefully it will be
|
|
|
|
* near the front of the other.)
|
|
|
|
*/
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->windows = g_list_prepend (compositor->windows, actor);
|
2008-11-07 10:13:40 +00:00
|
|
|
|
2009-06-26 21:05:11 +00:00
|
|
|
stack = g_list_remove (stack, window);
|
|
|
|
old_stack = g_list_remove (old_stack, actor);
|
2008-11-03 14:50:22 +00:00
|
|
|
}
|
2008-11-23 19:28:40 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
sync_actor_stacking (compositor);
|
2008-11-03 14:50:22 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 20:17:27 +00:00
|
|
|
void
|
|
|
|
meta_compositor_sync_window_geometry (MetaCompositor *compositor,
|
2013-02-16 02:27:00 +00:00
|
|
|
MetaWindow *window,
|
|
|
|
gboolean did_placement)
|
2008-11-27 13:40:52 +00:00
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2013-02-16 02:27:00 +00:00
|
|
|
meta_window_actor_sync_actor_geometry (window_actor, did_placement);
|
2008-11-27 13:40:52 +00:00
|
|
|
}
|
|
|
|
|
2012-11-12 19:11:08 +00:00
|
|
|
static void
|
|
|
|
frame_callback (CoglOnscreen *onscreen,
|
|
|
|
CoglFrameEvent event,
|
|
|
|
CoglFrameInfo *frame_info,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = user_data;
|
2012-11-12 19:11:08 +00:00
|
|
|
GList *l;
|
|
|
|
|
|
|
|
if (event == COGL_FRAME_EVENT_COMPLETE)
|
|
|
|
{
|
|
|
|
gint64 presentation_time_cogl = cogl_frame_info_get_presentation_time (frame_info);
|
|
|
|
gint64 presentation_time;
|
|
|
|
|
|
|
|
if (presentation_time_cogl != 0)
|
|
|
|
{
|
|
|
|
/* Cogl reports presentation in terms of its own clock, which is
|
|
|
|
* guaranteed to be in nanoseconds but with no specified base. The
|
|
|
|
* normal case with the open source GPU drivers on Linux 3.8 and
|
|
|
|
* newer is that the base of cogl_get_clock_time() is that of
|
|
|
|
* clock_gettime(CLOCK_MONOTONIC), so the same as g_get_monotonic_time),
|
|
|
|
* but there's no exposure of that through the API. clock_gettime()
|
|
|
|
* is fairly fast, so calling it twice and subtracting to get a
|
|
|
|
* nearly-zero number is acceptable, if a litle ugly.
|
|
|
|
*/
|
|
|
|
CoglContext *context = cogl_framebuffer_get_context (COGL_FRAMEBUFFER (onscreen));
|
|
|
|
gint64 current_cogl_time = cogl_get_clock_time (context);
|
|
|
|
gint64 current_monotonic_time = g_get_monotonic_time ();
|
|
|
|
|
|
|
|
presentation_time =
|
|
|
|
current_monotonic_time + (presentation_time_cogl - current_cogl_time) / 1000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
presentation_time = 0;
|
|
|
|
}
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
for (l = compositor->windows; l; l = l->next)
|
2012-11-12 19:11:08 +00:00
|
|
|
meta_window_actor_frame_complete (l->data, frame_info, presentation_time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-18 18:21:20 +00:00
|
|
|
static gboolean
|
|
|
|
meta_pre_paint_func (gpointer data)
|
2009-06-28 16:26:23 +00:00
|
|
|
{
|
|
|
|
GList *l;
|
2011-08-27 09:43:09 +00:00
|
|
|
MetaWindowActor *top_window;
|
2014-04-18 18:21:20 +00:00
|
|
|
MetaCompositor *compositor = data;
|
2011-08-27 09:43:09 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->onscreen == NULL)
|
2012-11-12 19:11:08 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->onscreen = COGL_ONSCREEN (cogl_get_draw_framebuffer ());
|
|
|
|
compositor->frame_closure = cogl_onscreen_add_frame_callback (compositor->onscreen,
|
|
|
|
frame_callback,
|
|
|
|
compositor,
|
|
|
|
NULL);
|
2012-11-12 19:11:08 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->windows == NULL)
|
2014-04-18 18:21:20 +00:00
|
|
|
return TRUE;
|
2011-08-30 10:42:01 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
top_window = g_list_last (compositor->windows)->data;
|
2014-01-22 14:16:56 +00:00
|
|
|
|
2013-12-06 22:10:44 +00:00
|
|
|
if (meta_window_actor_should_unredirect (top_window) &&
|
2014-03-18 21:31:22 +00:00
|
|
|
compositor->disable_unredirect_count == 0)
|
|
|
|
set_unredirected_window (compositor, meta_window_actor_get_meta_window (top_window));
|
2013-12-06 22:10:44 +00:00
|
|
|
else
|
2014-03-18 21:31:22 +00:00
|
|
|
set_unredirected_window (compositor, NULL);
|
2009-06-28 16:26:23 +00:00
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
for (l = compositor->windows; l; l = l->next)
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_window_actor_pre_paint (l->data);
|
2014-05-12 13:11:53 +00:00
|
|
|
|
|
|
|
if (compositor->frame_has_updated_xsurfaces)
|
|
|
|
{
|
|
|
|
/* We need to make sure that any X drawing that happens before
|
|
|
|
* the XDamageSubtract() for each window above is visible to
|
2014-04-18 18:21:20 +00:00
|
|
|
* subsequent GL rendering; the standardized way to do this is
|
|
|
|
* GL_EXT_X11_sync_object. Since this isn't implemented yet in
|
|
|
|
* mesa, we also have a path that relies on the implementation
|
|
|
|
* of the open source drivers.
|
|
|
|
*
|
|
|
|
* Anything else, we just hope for the best.
|
2014-05-12 13:11:53 +00:00
|
|
|
*
|
|
|
|
* Xorg and open source driver specifics:
|
|
|
|
*
|
|
|
|
* The X server makes sure to flush drawing to the kernel before
|
|
|
|
* sending out damage events, but since we use
|
|
|
|
* DamageReportBoundingBox there may be drawing between the last
|
|
|
|
* damage event and the XDamageSubtract() that needs to be
|
|
|
|
* flushed as well.
|
|
|
|
*
|
|
|
|
* Xorg always makes sure that drawing is flushed to the kernel
|
|
|
|
* before writing events or responses to the client, so any
|
|
|
|
* round trip request at this point is sufficient to flush the
|
|
|
|
* GLX buffers.
|
|
|
|
*/
|
2014-04-18 18:21:20 +00:00
|
|
|
if (compositor->have_x11_sync_object)
|
|
|
|
compositor->have_x11_sync_object = meta_sync_ring_insert_wait ();
|
|
|
|
else
|
|
|
|
XSync (compositor->display->xdisplay, False);
|
2014-05-12 13:11:53 +00:00
|
|
|
}
|
2014-04-18 18:21:20 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2009-06-28 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-04-18 18:21:20 +00:00
|
|
|
meta_post_paint_func (gpointer data)
|
2009-06-28 16:26:23 +00:00
|
|
|
{
|
|
|
|
MetaCompositor *compositor = data;
|
2014-04-18 18:21:20 +00:00
|
|
|
|
|
|
|
if (compositor->frame_has_updated_xsurfaces)
|
|
|
|
{
|
|
|
|
if (compositor->have_x11_sync_object)
|
|
|
|
compositor->have_x11_sync_object = meta_sync_ring_after_frame ();
|
|
|
|
|
|
|
|
compositor->frame_has_updated_xsurfaces = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-06-28 16:26:23 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-11-11 21:24:43 +00:00
|
|
|
static void
|
|
|
|
on_shadow_factory_changed (MetaShadowFactory *factory,
|
|
|
|
MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
for (l = compositor->windows; l; l = l->next)
|
2013-10-03 22:31:09 +00:00
|
|
|
meta_window_actor_invalidate_shadow (l->data);
|
2010-11-11 21:24:43 +00:00
|
|
|
}
|
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
|
|
|
* meta_compositor_new: (skip)
|
2013-02-15 18:42:08 +00:00
|
|
|
* @display:
|
2010-09-01 19:39:53 +00:00
|
|
|
*
|
|
|
|
*/
|
2008-06-04 12:58:36 +00:00
|
|
|
MetaCompositor *
|
2009-06-25 20:17:27 +00:00
|
|
|
meta_compositor_new (MetaDisplay *display)
|
2008-06-04 12:58:36 +00:00
|
|
|
{
|
2008-08-20 08:33:39 +00:00
|
|
|
MetaCompositor *compositor;
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2009-06-25 20:29:20 +00:00
|
|
|
compositor = g_new0 (MetaCompositor, 1);
|
|
|
|
compositor->display = display;
|
2008-06-04 12:58:36 +00:00
|
|
|
|
2010-10-18 17:27:14 +00:00
|
|
|
if (g_getenv("META_DISABLE_MIPMAPS"))
|
2009-06-25 20:29:20 +00:00
|
|
|
compositor->no_mipmaps = TRUE;
|
2008-11-05 11:48:07 +00:00
|
|
|
|
2010-11-11 21:24:43 +00:00
|
|
|
g_signal_connect (meta_shadow_factory_get_default (),
|
|
|
|
"changed",
|
|
|
|
G_CALLBACK (on_shadow_factory_changed),
|
|
|
|
compositor);
|
|
|
|
|
2014-04-18 18:21:20 +00:00
|
|
|
compositor->pre_paint_func_id =
|
|
|
|
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_PRE_PAINT,
|
|
|
|
meta_pre_paint_func,
|
|
|
|
compositor,
|
|
|
|
NULL);
|
|
|
|
compositor->post_paint_func_id =
|
|
|
|
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT,
|
|
|
|
meta_post_paint_func,
|
|
|
|
compositor,
|
|
|
|
NULL);
|
2008-06-04 12:58:36 +00:00
|
|
|
return compositor;
|
|
|
|
}
|
2008-06-06 13:17:38 +00:00
|
|
|
|
2010-09-01 19:39:53 +00:00
|
|
|
/**
|
2010-10-18 17:27:14 +00:00
|
|
|
* meta_get_overlay_window: (skip)
|
2013-02-15 18:42:08 +00:00
|
|
|
* @screen: a #MetaScreen
|
2010-09-01 19:39:53 +00:00
|
|
|
*
|
|
|
|
*/
|
2008-10-16 06:50:49 +00:00
|
|
|
Window
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_get_overlay_window (MetaScreen *screen)
|
2008-10-16 06:50:49 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
return compositor->output;
|
2008-10-16 06:50:49 +00:00
|
|
|
}
|
2011-03-18 13:36:28 +00:00
|
|
|
|
2011-08-27 09:43:09 +00:00
|
|
|
/**
|
|
|
|
* meta_disable_unredirect_for_screen:
|
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Disables unredirection, can be usefull in situations where having
|
|
|
|
* unredirected windows is undesireable like when recording a video.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
meta_disable_unredirect_for_screen (MetaScreen *screen)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
compositor->disable_unredirect_count++;
|
2011-08-27 09:43:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_enable_unredirect_for_screen:
|
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Enables unredirection which reduces the overhead for apps like games.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
meta_enable_unredirect_for_screen (MetaScreen *screen)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor = get_compositor_for_screen (screen);
|
|
|
|
if (compositor->disable_unredirect_count == 0)
|
2013-06-18 19:36:20 +00:00
|
|
|
g_warning ("Called enable_unredirect_for_screen while unredirection is enabled.");
|
2014-03-18 21:31:22 +00:00
|
|
|
if (compositor->disable_unredirect_count > 0)
|
|
|
|
compositor->disable_unredirect_count--;
|
2011-08-27 09:43:09 +00:00
|
|
|
}
|
|
|
|
|
2011-03-18 13:36:28 +00:00
|
|
|
#define FLASH_TIME_MS 50
|
|
|
|
|
|
|
|
static void
|
2012-01-17 14:16:46 +00:00
|
|
|
flash_out_completed (ClutterTimeline *timeline,
|
2013-03-03 23:17:17 +00:00
|
|
|
gboolean is_finished,
|
2012-01-17 14:16:46 +00:00
|
|
|
gpointer user_data)
|
2011-03-18 13:36:28 +00:00
|
|
|
{
|
2012-01-17 14:16:46 +00:00
|
|
|
ClutterActor *flash = CLUTTER_ACTOR (user_data);
|
2011-03-18 13:36:28 +00:00
|
|
|
clutter_actor_destroy (flash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_flash_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
|
|
|
ClutterActor *stage;
|
|
|
|
ClutterActor *flash;
|
2012-01-17 14:16:46 +00:00
|
|
|
ClutterTransition *transition;
|
2011-03-18 13:36:28 +00:00
|
|
|
gfloat width, height;
|
|
|
|
|
|
|
|
stage = meta_get_stage_for_screen (screen);
|
|
|
|
clutter_actor_get_size (stage, &width, &height);
|
|
|
|
|
2012-01-17 14:16:46 +00:00
|
|
|
flash = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (flash, CLUTTER_COLOR_Black);
|
2011-03-18 13:36:28 +00:00
|
|
|
clutter_actor_set_size (flash, width, height);
|
|
|
|
clutter_actor_set_opacity (flash, 0);
|
2012-01-17 14:16:46 +00:00
|
|
|
clutter_actor_add_child (stage, flash);
|
|
|
|
|
|
|
|
clutter_actor_save_easing_state (flash);
|
|
|
|
clutter_actor_set_easing_mode (flash, CLUTTER_EASE_IN_QUAD);
|
|
|
|
clutter_actor_set_easing_duration (flash, FLASH_TIME_MS);
|
|
|
|
clutter_actor_set_opacity (flash, 192);
|
|
|
|
|
|
|
|
transition = clutter_actor_get_transition (flash, "opacity");
|
|
|
|
clutter_timeline_set_auto_reverse (CLUTTER_TIMELINE (transition), TRUE);
|
|
|
|
clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (transition), 2);
|
|
|
|
|
2013-03-03 23:17:17 +00:00
|
|
|
g_signal_connect (transition, "stopped",
|
2012-01-17 14:16:46 +00:00
|
|
|
G_CALLBACK (flash_out_completed), flash);
|
2011-03-18 13:36:28 +00:00
|
|
|
|
2012-01-17 14:16:46 +00:00
|
|
|
clutter_actor_restore_easing_state (flash);
|
2011-03-18 13:36:28 +00:00
|
|
|
}
|
2012-11-12 19:09:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_compositor_monotonic_time_to_server_time:
|
|
|
|
* @display: a #MetaDisplay
|
|
|
|
* @monotonic_time: time in the units of g_get_monotonic_time()
|
|
|
|
*
|
|
|
|
* _NET_WM_FRAME_DRAWN and _NET_WM_FRAME_TIMINGS messages represent time
|
|
|
|
* as a "high resolution server time" - this is the server time interpolated
|
|
|
|
* to microsecond resolution. The advantage of this time representation
|
|
|
|
* is that if X server is running on the same computer as a client, and
|
|
|
|
* the Xserver uses 'clock_gettime(CLOCK_MONOTONIC, ...)' for the server
|
|
|
|
* time, the client can detect this, and all such clients will share a
|
|
|
|
* a time representation with high accuracy. If there is not a common
|
|
|
|
* time source, then the time synchronization will be less accurate.
|
|
|
|
*/
|
|
|
|
gint64
|
|
|
|
meta_compositor_monotonic_time_to_server_time (MetaDisplay *display,
|
|
|
|
gint64 monotonic_time)
|
|
|
|
{
|
|
|
|
MetaCompositor *compositor = display->compositor;
|
|
|
|
|
|
|
|
if (compositor->server_time_query_time == 0 ||
|
|
|
|
(!compositor->server_time_is_monotonic_time &&
|
|
|
|
monotonic_time > compositor->server_time_query_time + 10*1000*1000)) /* 10 seconds */
|
|
|
|
{
|
|
|
|
guint32 server_time = meta_display_get_current_time_roundtrip (display);
|
|
|
|
gint64 server_time_usec = (gint64)server_time * 1000;
|
|
|
|
gint64 current_monotonic_time = g_get_monotonic_time ();
|
|
|
|
compositor->server_time_query_time = current_monotonic_time;
|
|
|
|
|
|
|
|
/* If the server time is within a second of the monotonic time,
|
|
|
|
* we assume that they are identical. This seems like a big margin,
|
|
|
|
* but we want to be as robust as possible even if the system
|
|
|
|
* is under load and our processing of the server response is
|
|
|
|
* delayed.
|
|
|
|
*/
|
|
|
|
if (server_time_usec > current_monotonic_time - 1000*1000 &&
|
|
|
|
server_time_usec < current_monotonic_time + 1000*1000)
|
|
|
|
compositor->server_time_is_monotonic_time = TRUE;
|
|
|
|
|
|
|
|
compositor->server_time_offset = server_time_usec - current_monotonic_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compositor->server_time_is_monotonic_time)
|
|
|
|
return monotonic_time;
|
|
|
|
else
|
|
|
|
return monotonic_time + compositor->server_time_offset;
|
|
|
|
}
|
2012-03-24 10:29:39 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_show_tile_preview (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *tile_rect,
|
|
|
|
int tile_monitor_number)
|
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_plugin_manager_show_tile_preview (compositor->plugin_mgr,
|
2012-03-24 10:29:39 +00:00
|
|
|
window, tile_rect, tile_monitor_number);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_compositor_hide_tile_preview (MetaCompositor *compositor)
|
2012-03-24 10:29:39 +00:00
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_plugin_manager_hide_tile_preview (compositor->plugin_mgr);
|
2012-03-24 10:29:39 +00:00
|
|
|
}
|
2014-03-13 22:34:14 +00:00
|
|
|
|
|
|
|
void
|
2014-05-23 21:14:51 +00:00
|
|
|
meta_compositor_show_window_menu (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaWindowMenuType menu,
|
|
|
|
int x,
|
|
|
|
int y)
|
2014-03-13 22:34:14 +00:00
|
|
|
{
|
2014-05-23 21:14:51 +00:00
|
|
|
meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, menu, x, y);
|
2014-03-13 22:34:14 +00:00
|
|
|
}
|
2014-05-30 22:52:06 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_show_window_menu_for_rect (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaWindowMenuType menu,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
|
|
|
meta_plugin_manager_show_window_menu_for_rect (compositor->plugin_mgr, window, menu, rect);
|
|
|
|
}
|