2008-10-24 05:07:24 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
#include <config.h>
|
|
|
|
|
2009-06-26 15:33:20 -04:00
|
|
|
#include <clutter/x11/clutter-x11.h>
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2011-03-05 19:29:12 -05:00
|
|
|
#include <meta/screen.h>
|
|
|
|
#include <meta/errors.h>
|
|
|
|
#include <meta/window.h>
|
2009-06-25 18:56:15 -04:00
|
|
|
#include "compositor-private.h"
|
2011-03-05 19:29:12 -05:00
|
|
|
#include <meta/compositor-mutter.h>
|
2008-06-04 08:58:36 -04:00
|
|
|
#include "xprops.h"
|
2011-03-05 19:29:12 -05:00
|
|
|
#include <meta/prefs.h>
|
2011-06-21 14:05:59 -04:00
|
|
|
#include <meta/main.h>
|
2011-03-05 19:29:12 -05:00
|
|
|
#include <meta/meta-shadow-factory.h>
|
2010-10-18 13:27:14 -04:00
|
|
|
#include "meta-window-actor-private.h"
|
|
|
|
#include "meta-window-group.h"
|
2011-08-28 21:20:29 -04:00
|
|
|
#include "meta-background-actor-private.h"
|
2011-03-05 19:29:12 -05:00
|
|
|
#include "window-private.h" /* to check window->hidden */
|
|
|
|
#include "display-private.h" /* for meta_display_lookup_x_window() */
|
2008-06-04 08:58:36 -04:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2008-10-24 05:07:24 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
/* #define DEBUG_TRACE g_print */
|
2008-12-18 07:41:56 -05:00
|
|
|
#define DEBUG_TRACE(X)
|
2008-10-24 05:07:24 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
static inline gboolean
|
2008-08-20 04:33:39 -04:00
|
|
|
composite_at_least_version (MetaDisplay *display, int maj, int min)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
static int major = -1;
|
|
|
|
static int minor = -1;
|
|
|
|
|
|
|
|
if (major == -1)
|
|
|
|
meta_display_get_compositor_version (display, &major, &minor);
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return (major > maj || (major == maj && minor >= min));
|
|
|
|
}
|
|
|
|
|
2010-11-13 14:45:01 -05:00
|
|
|
static void sync_actor_stacking (MetaCompScreen *info);
|
2009-06-26 15:33:20 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_finish_workspace_switch (MetaCompScreen *info)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2009-06-26 15:33:20 -04:00
|
|
|
GList *l;
|
2008-06-04 08:58:36 -04: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 17:10:40 -04:00
|
|
|
/* Finish hiding and showing actors for the new workspace */
|
|
|
|
for (l = info->windows; l; l = l->next)
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_sync_visibility (l->data);
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
2009-06-26 15:33:20 -04:00
|
|
|
* Fix up stacking order in case the plugin messed it up.
|
2008-09-18 11:09:11 -04:00
|
|
|
*/
|
2010-11-13 14:45:01 -05:00
|
|
|
sync_actor_stacking (info);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2009-06-26 15:33:20 -04:00
|
|
|
/* printf ("... FINISHED DESKTOP SWITCH\n"); */
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2009-06-26 15:33:20 -04:00
|
|
|
void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_switch_workspace_completed (MetaScreen *screen)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2009-06-26 15:33:20 -04:00
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2009-06-26 15:33:20 -04:00
|
|
|
/* FIXME -- must redo stacking order */
|
|
|
|
info->switch_workspace_in_progress--;
|
|
|
|
if (info->switch_workspace_in_progress < 0)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2009-06-26 15:33:20 -04:00
|
|
|
g_warning ("Error in workspace_switch accounting!");
|
|
|
|
info->switch_workspace_in_progress = 0;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2009-06-26 15:33:20 -04:00
|
|
|
if (!info->switch_workspace_in_progress)
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_finish_workspace_switch (info);
|
2009-06-26 15:33:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_destroy (MetaCompositor *compositor)
|
|
|
|
{
|
2009-06-28 12:26:23 -04:00
|
|
|
clutter_threads_remove_repaint_func (compositor->repaint_func_id);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
add_win (MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_new (window);
|
2008-11-23 14:28:40 -05:00
|
|
|
|
2010-11-13 14:45:01 -05:00
|
|
|
sync_actor_stacking (info);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-25 16:29:20 -04:00
|
|
|
process_damage (MetaCompositor *compositor,
|
2010-04-06 14:10:44 -04:00
|
|
|
XDamageNotifyEvent *event,
|
|
|
|
MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor;
|
2010-04-06 14:10:44 -04:00
|
|
|
|
|
|
|
if (window == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
if (window_actor == NULL)
|
2008-08-19 12:02:00 -04:00
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_process_damage (window_actor, event);
|
2008-09-24 17:53:39 -04:00
|
|
|
}
|
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
static void
|
2009-06-25 16:29:20 -04:00
|
|
|
process_property_notify (MetaCompositor *compositor,
|
2010-04-06 14:10:44 -04:00
|
|
|
XPropertyEvent *event,
|
|
|
|
MetaWindow *window)
|
2008-06-04 15:51:08 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor;
|
2010-04-06 14:10:44 -04:00
|
|
|
|
2010-11-14 12:37:17 -05:00
|
|
|
if (event->atom == compositor->atom_x_root_pixmap)
|
|
|
|
{
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
for (l = meta_display_get_screens (compositor->display); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaScreen *screen = l->data;
|
|
|
|
if (event->window == meta_screen_get_xroot (screen))
|
|
|
|
{
|
2011-08-28 14:09:42 -04:00
|
|
|
meta_background_actor_update (screen);
|
2010-11-14 12:37:17 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-06 14:10:44 -04:00
|
|
|
if (window == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
if (window_actor == NULL)
|
2010-04-06 14:10:44 -04:00
|
|
|
return;
|
2008-06-04 15:51:08 -04:00
|
|
|
|
|
|
|
/* Check for the opacity changing */
|
2008-08-18 10:44:26 -04:00
|
|
|
if (event->atom == compositor->atom_net_wm_window_opacity)
|
2008-06-04 15:51:08 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_update_opacity (window_actor);
|
2010-04-06 14:10:44 -04:00
|
|
|
DEBUG_TRACE ("process_property_notify: net_wm_window_opacity\n");
|
|
|
|
return;
|
2008-06-04 15:51:08 -04:00
|
|
|
}
|
2010-09-30 12:35:12 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("process_property_notify: unknown\n");
|
2008-06-04 15:51:08 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
static Window
|
|
|
|
get_output_window (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
2008-08-20 04:33:39 -04:00
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
Window output, xroot;
|
2009-01-09 11:28:12 -05:00
|
|
|
XWindowAttributes attr;
|
|
|
|
long event_mask;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
xroot = meta_screen_get_xroot (screen);
|
|
|
|
|
2009-01-09 11:28:12 -05:00
|
|
|
event_mask = FocusChangeMask |
|
|
|
|
ExposureMask |
|
2009-05-03 18:21:41 -04:00
|
|
|
EnterWindowMask | LeaveWindowMask |
|
2009-01-09 11:28:12 -05:00
|
|
|
PointerMotionMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeyPressMask | KeyReleaseMask;
|
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
output = XCompositeGetOverlayWindow (xdisplay, xroot);
|
2009-01-09 11:28:12 -05:00
|
|
|
|
|
|
|
if (XGetWindowAttributes (xdisplay, output, &attr))
|
|
|
|
{
|
|
|
|
event_mask |= attr.your_event_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
XSelectInput (xdisplay, output, event_mask);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
2010-10-18 13:27:14 -04:00
|
|
|
* meta_get_stage_for_screen:
|
2010-09-01 15:39:53 -04:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The #ClutterStage for the screen
|
|
|
|
*/
|
2008-10-09 08:22:32 -04:00
|
|
|
ClutterActor *
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_get_stage_for_screen (MetaScreen *screen)
|
2008-10-09 08:22:32 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->stage;
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
2010-10-18 13:27:14 -04:00
|
|
|
* meta_get_overlay_group_for_screen:
|
2010-09-01 15:39:53 -04:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The overlay group corresponding to @screen
|
|
|
|
*/
|
2008-10-09 08:22:32 -04:00
|
|
|
ClutterActor *
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_get_overlay_group_for_screen (MetaScreen *screen)
|
2008-10-09 08:22:32 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->overlay_group;
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
2010-10-18 13:27:14 -04:00
|
|
|
* meta_get_window_group_for_screen:
|
2010-09-01 15:39:53 -04:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The window group corresponding to @screen
|
|
|
|
*/
|
2008-10-28 07:30:29 -04:00
|
|
|
ClutterActor *
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_get_window_group_for_screen (MetaScreen *screen)
|
2008-10-28 07:30:29 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->window_group;
|
|
|
|
}
|
|
|
|
|
2010-11-14 12:37:17 -05:00
|
|
|
/**
|
|
|
|
* meta_get_background_actor_for_screen:
|
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
|
|
|
* Gets the actor that draws the root window background under the windows.
|
|
|
|
* The root window background automatically tracks the image or color set
|
|
|
|
* by the environment.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The background actor corresponding to @screen
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
|
|
|
meta_get_background_actor_for_screen (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->background_actor;
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
2010-10-18 13:27:14 -04:00
|
|
|
* meta_get_window_actors:
|
2010-09-01 15:39:53 -04:00
|
|
|
* @screen: a #MetaScreen
|
|
|
|
*
|
2010-10-18 13:27:14 -04:00
|
|
|
* Returns: (transfer none) (element-type Clutter.Actor): The set of #MetaWindowActor on @screen
|
2010-09-01 15:39:53 -04:00
|
|
|
*/
|
2008-10-24 05:07:24 -04:00
|
|
|
GList *
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_get_window_actors (MetaScreen *screen)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->windows;
|
|
|
|
}
|
2008-10-09 08:22:32 -04:00
|
|
|
|
2009-06-19 16:42:10 -04:00
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
do_set_stage_input_region (MetaScreen *screen,
|
2009-06-19 16:42:10 -04:00
|
|
|
XserverRegion region)
|
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdpy = meta_display_get_xdisplay (display);
|
|
|
|
Window xstage = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
|
|
|
|
|
|
|
XFixesSetWindowShapeRegion (xdpy, xstage, ShapeInput, 0, 0, region);
|
|
|
|
XFixesSetWindowShapeRegion (xdpy, info->output, ShapeInput, 0, 0, region);
|
|
|
|
}
|
|
|
|
|
2009-04-23 16:33:16 -04:00
|
|
|
void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_set_stage_input_region (MetaScreen *screen,
|
|
|
|
XserverRegion region)
|
2009-04-23 16:33:16 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdpy = meta_display_get_xdisplay (display);
|
|
|
|
|
|
|
|
if (info->stage && info->output)
|
|
|
|
{
|
2009-06-19 16:42:10 -04:00
|
|
|
do_set_stage_input_region (screen, region);
|
2009-04-23 16:33:16 -04:00
|
|
|
}
|
2009-06-19 16:42:10 -04:00
|
|
|
else
|
2009-04-23 16:33:16 -04:00
|
|
|
{
|
2009-06-19 16:42:10 -04:00
|
|
|
/* Reset info->pending_input_region if one existed before and set the new
|
|
|
|
* one to use it later. */
|
|
|
|
if (info->pending_input_region)
|
|
|
|
{
|
|
|
|
XFixesDestroyRegion (xdpy, info->pending_input_region);
|
|
|
|
info->pending_input_region = None;
|
|
|
|
}
|
|
|
|
if (region != None)
|
|
|
|
{
|
|
|
|
info->pending_input_region = XFixesCreateRegion (xdpy, NULL, 0);
|
|
|
|
XFixesCopyRegion (xdpy, info->pending_input_region, region);
|
|
|
|
}
|
|
|
|
}
|
2009-04-23 16:33:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_empty_stage_input_region (MetaScreen *screen)
|
2009-04-23 16:33:16 -04: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 13:27:14 -04:00
|
|
|
meta_set_stage_input_region (screen, region);
|
2009-04-23 16:33:16 -04:00
|
|
|
}
|
|
|
|
|
2009-08-12 00:12:52 -04:00
|
|
|
gboolean
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_begin_modal_for_plugin (MetaScreen *screen,
|
|
|
|
MetaPlugin *plugin,
|
|
|
|
Window grab_window,
|
|
|
|
Cursor cursor,
|
|
|
|
MetaModalOptions options,
|
|
|
|
guint32 timestamp)
|
2009-08-12 00:12:52 -04:00
|
|
|
{
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdpy = meta_display_get_xdisplay (display);
|
|
|
|
MetaCompositor *compositor = display->compositor;
|
|
|
|
gboolean pointer_grabbed = FALSE;
|
|
|
|
gboolean keyboard_grabbed = FALSE;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
if (compositor->modal_plugin != NULL || display->grab_op != META_GRAB_OP_NONE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
|
|
|
|
{
|
|
|
|
result = XGrabPointer (xdpy, grab_window,
|
|
|
|
False, /* owner_events */
|
|
|
|
(ButtonPressMask | ButtonReleaseMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask | PointerMotionMask),
|
|
|
|
GrabModeAsync, GrabModeAsync,
|
|
|
|
None, /* confine to */
|
|
|
|
cursor,
|
|
|
|
timestamp);
|
|
|
|
if (result != Success)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
pointer_grabbed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
|
|
|
|
{
|
2009-09-25 12:58:01 -04:00
|
|
|
result = XGrabKeyboard (xdpy, grab_window,
|
|
|
|
False, /* owner_events */
|
|
|
|
GrabModeAsync, GrabModeAsync,
|
|
|
|
timestamp);
|
2009-08-12 00:12:52 -04:00
|
|
|
|
|
|
|
if (result != Success)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
keyboard_grabbed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
display->grab_op = META_GRAB_OP_COMPOSITOR;
|
|
|
|
display->grab_window = NULL;
|
|
|
|
display->grab_screen = screen;
|
|
|
|
display->grab_have_pointer = TRUE;
|
|
|
|
display->grab_have_keyboard = TRUE;
|
|
|
|
|
|
|
|
compositor->modal_plugin = plugin;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (pointer_grabbed)
|
|
|
|
XUngrabPointer (xdpy, timestamp);
|
|
|
|
if (keyboard_grabbed)
|
|
|
|
XUngrabKeyboard (xdpy, timestamp);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_end_modal_for_plugin (MetaScreen *screen,
|
|
|
|
MetaPlugin *plugin,
|
|
|
|
guint32 timestamp)
|
2009-08-12 00:12:52 -04:00
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdpy = meta_display_get_xdisplay (display);
|
|
|
|
MetaCompositor *compositor = display->compositor;
|
|
|
|
|
|
|
|
g_return_if_fail (compositor->modal_plugin == plugin);
|
|
|
|
|
|
|
|
XUngrabPointer (xdpy, timestamp);
|
|
|
|
XUngrabKeyboard (xdpy, timestamp);
|
|
|
|
|
|
|
|
display->grab_op = META_GRAB_OP_NONE;
|
|
|
|
display->grab_window = NULL;
|
|
|
|
display->grab_screen = NULL;
|
|
|
|
display->grab_have_pointer = FALSE;
|
|
|
|
display->grab_have_keyboard = FALSE;
|
|
|
|
|
|
|
|
compositor->modal_plugin = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is used when reloading plugins to make sure we don't have
|
|
|
|
* a left-over modal grab for this screen.
|
|
|
|
*/
|
|
|
|
void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_check_end_modal (MetaScreen *screen)
|
2009-08-12 00:12:52 -04:00
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
MetaCompositor *compositor = display->compositor;
|
|
|
|
|
|
|
|
if (compositor->modal_plugin &&
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_get_screen (compositor->modal_plugin) == screen)
|
2009-08-12 00:12:52 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_end_modal_for_plugin (screen,
|
2009-08-12 00:12:52 -04:00
|
|
|
compositor->modal_plugin,
|
|
|
|
CurrentTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_manage_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info;
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
int screen_number = meta_screen_get_screen_number (screen);
|
|
|
|
Window xroot = meta_screen_get_xroot (screen);
|
|
|
|
Window xwin;
|
|
|
|
gint width, height;
|
2009-01-09 11:28:12 -05:00
|
|
|
XWindowAttributes attr;
|
|
|
|
long event_mask;
|
2011-06-21 14:05:59 -04:00
|
|
|
guint n_retries;
|
|
|
|
guint max_retries;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
/* Check if the screen is already managed */
|
|
|
|
if (meta_screen_get_compositor_data (screen))
|
|
|
|
return;
|
|
|
|
|
2011-06-21 14:05:59 -04:00
|
|
|
if (meta_get_replace_current_wm ())
|
|
|
|
max_retries = 5;
|
|
|
|
else
|
|
|
|
max_retries = 1;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2011-06-21 14:05:59 -04:00
|
|
|
n_retries = 0;
|
|
|
|
|
2011-06-30 15:23:41 -04: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 14:05:59 -04:00
|
|
|
*/
|
|
|
|
while (TRUE)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2011-06-21 14:05:59 -04:00
|
|
|
meta_error_trap_push_with_return (display);
|
|
|
|
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
|
|
|
XSync (xdisplay, FALSE);
|
|
|
|
|
|
|
|
if (!meta_error_trap_pop_with_return (display))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (n_retries == max_retries)
|
2011-06-30 15:23:41 -04: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 14:05:59 -04:00
|
|
|
|
|
|
|
n_retries++;
|
|
|
|
g_usleep (G_USEC_PER_SEC);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
info = g_new0 (MetaCompScreen, 1);
|
2009-06-19 16:42:10 -04:00
|
|
|
/*
|
|
|
|
* We use an empty input region for Clutter as a default because that allows
|
|
|
|
* the user to interact with all the windows displayed on the screen.
|
|
|
|
* We have to initialize info->pending_input_region to an empty region explicitly,
|
|
|
|
* because None value is used to mean that the whole screen is an input region.
|
|
|
|
*/
|
|
|
|
info->pending_input_region = XFixesCreateRegion (xdisplay, NULL, 0);
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
info->screen = screen;
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_screen_set_compositor_data (screen, info);
|
|
|
|
|
2009-03-30 11:56:52 -04:00
|
|
|
info->output = None;
|
2008-06-04 08:58:36 -04:00
|
|
|
info->windows = NULL;
|
|
|
|
|
|
|
|
meta_screen_set_cm_selection (screen);
|
|
|
|
|
|
|
|
info->stage = clutter_stage_get_default ();
|
|
|
|
|
|
|
|
meta_screen_get_size (screen, &width, &height);
|
|
|
|
clutter_actor_set_size (info->stage, width, height);
|
|
|
|
|
|
|
|
xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
|
|
|
|
2009-01-09 11:28:12 -05:00
|
|
|
event_mask = FocusChangeMask |
|
|
|
|
ExposureMask |
|
2009-05-03 18:21:41 -04:00
|
|
|
EnterWindowMask | LeaveWindowMask |
|
2009-01-09 11:28:12 -05:00
|
|
|
PointerMotionMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
2009-01-30 06:57:46 -05:00
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
StructureNotifyMask;
|
2009-01-09 11:28:12 -05:00
|
|
|
|
|
|
|
if (XGetWindowAttributes (xdisplay, xwin, &attr))
|
|
|
|
{
|
|
|
|
event_mask |= attr.your_event_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
XSelectInput (xdisplay, xwin, event_mask);
|
2008-10-16 10:50:03 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
info->window_group = meta_window_group_new (screen);
|
2011-08-28 21:20:29 -04:00
|
|
|
info->background_actor = meta_background_actor_new_for_screen (screen);
|
2008-10-02 07:16:15 -04:00
|
|
|
info->overlay_group = clutter_group_new ();
|
2008-11-03 05:26:21 -05:00
|
|
|
info->hidden_group = clutter_group_new ();
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2010-11-14 12:37:17 -05:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER (info->window_group),
|
|
|
|
info->background_actor,
|
|
|
|
NULL);
|
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER (info->stage),
|
|
|
|
info->window_group,
|
|
|
|
info->overlay_group,
|
2008-11-03 05:26:21 -05:00
|
|
|
info->hidden_group,
|
2008-10-02 07:16:15 -04:00
|
|
|
NULL);
|
|
|
|
|
2008-11-03 05:26:21 -05:00
|
|
|
clutter_actor_hide (info->hidden_group);
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2009-03-30 11:56:52 -04:00
|
|
|
info->plugin_mgr =
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_get (screen);
|
2011-03-04 15:11:38 -05:00
|
|
|
meta_plugin_manager_initialize (info->plugin_mgr);
|
2009-03-30 11:56:52 -04:00
|
|
|
|
2008-10-21 03:58:44 -04:00
|
|
|
/*
|
2009-03-30 11:56:52 -04:00
|
|
|
* Delay the creation of the overlay window as long as we can, to avoid
|
|
|
|
* blanking out the screen. This means that during the plugin loading, the
|
2009-04-23 16:33:16 -04:00
|
|
|
* overlay window is not accessible; if the plugin needs to access it
|
|
|
|
* directly, it should hook into the "show" signal on stage, and do
|
|
|
|
* its stuff there.
|
2008-10-21 03:58:44 -04:00
|
|
|
*/
|
2009-03-30 11:56:52 -04:00
|
|
|
info->output = get_output_window (screen);
|
|
|
|
XReparentWindow (xdisplay, xwin, info->output, 0, 0);
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2009-06-19 16:42:10 -04:00
|
|
|
/* Make sure there isn't any left-over output shape on the
|
|
|
|
* overlay window by setting the whole screen to be an
|
|
|
|
* output region.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
XFixesSetWindowShapeRegion (xdisplay, info->output, ShapeBounding, 0, 0, None);
|
|
|
|
|
|
|
|
do_set_stage_input_region (screen, info->pending_input_region);
|
2009-04-23 16:33:16 -04:00
|
|
|
if (info->pending_input_region != None)
|
|
|
|
{
|
|
|
|
XFixesDestroyRegion (xdisplay, info->pending_input_region);
|
|
|
|
info->pending_input_region = None;
|
|
|
|
}
|
|
|
|
|
2008-10-31 18:59:04 -04:00
|
|
|
clutter_actor_show (info->overlay_group);
|
2009-03-30 11:56:52 -04:00
|
|
|
clutter_actor_show (info->stage);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2011-06-30 15:23:41 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
Window xroot = meta_screen_get_xroot (screen);
|
|
|
|
|
|
|
|
/* 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 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_add_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_add_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
meta_error_trap_push (display);
|
2008-10-24 05:07:24 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
add_win (window);
|
|
|
|
|
2010-10-25 14:44:30 -04:00
|
|
|
meta_error_trap_pop (display);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_remove_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = NULL;
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_remove_window\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
if (!window_actor)
|
2008-11-23 14:28:40 -05:00
|
|
|
return;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_destroy (window_actor);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_set_updates (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean updates)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-08-12 00:12:52 -04:00
|
|
|
static gboolean
|
|
|
|
is_grabbed_event (XEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->xany.type)
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
case EnterNotify:
|
|
|
|
case LeaveNotify:
|
|
|
|
case MotionNotify:
|
2009-09-28 15:47:39 -04:00
|
|
|
case KeyPress:
|
|
|
|
case KeyRelease:
|
2009-08-12 00:12:52 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-20 00:29:06 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_window_shape_changed (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
meta_window_actor_update_shape (window_actor);
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
|
|
|
* meta_compositor_process_event: (skip)
|
|
|
|
*
|
|
|
|
*/
|
2009-06-25 16:17:27 -04:00
|
|
|
gboolean
|
|
|
|
meta_compositor_process_event (MetaCompositor *compositor,
|
|
|
|
XEvent *event,
|
|
|
|
MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2009-08-12 00:12:52 -04:00
|
|
|
if (compositor->modal_plugin && is_grabbed_event (event))
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (compositor->modal_plugin);
|
2009-08-12 00:12:52 -04:00
|
|
|
|
|
|
|
if (klass->xevent_filter)
|
|
|
|
klass->xevent_filter (compositor->modal_plugin, event);
|
|
|
|
|
|
|
|
/* We always consume events even if the plugin says it didn't handle them;
|
|
|
|
* exclusive is exclusive */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
MetaCompScreen *info;
|
|
|
|
MetaScreen *screen;
|
|
|
|
|
|
|
|
screen = meta_window_get_screen (window);
|
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event))
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n");
|
2008-11-22 13:07:32 -05:00
|
|
|
return TRUE;
|
2008-11-27 08:40:52 -05:00
|
|
|
}
|
2008-10-02 07:16:15 -04:00
|
|
|
}
|
2008-10-16 10:50:03 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GSList *l;
|
|
|
|
|
2009-06-25 16:29:20 -04:00
|
|
|
l = meta_display_get_screens (compositor->display);
|
2008-10-16 10:50:03 -04:00
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
MetaScreen *screen = l->data;
|
|
|
|
MetaCompScreen *info;
|
|
|
|
|
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event))
|
2008-10-16 10:50:03 -04:00
|
|
|
{
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n");
|
2008-11-22 13:07:32 -05:00
|
|
|
return TRUE;
|
2008-10-16 10:50:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
}
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
switch (event->type)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
case PropertyNotify:
|
2010-04-06 14:10:44 -04:00
|
|
|
process_property_notify (compositor, (XPropertyEvent *) event, window);
|
2008-06-04 08:58:36 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-06-25 16:29:20 -04:00
|
|
|
if (event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2010-04-06 14:10:44 -04:00
|
|
|
/* Core code doesn't handle damage events, so we need to extract the MetaWindow
|
|
|
|
* ourselves
|
|
|
|
*/
|
|
|
|
if (window == NULL)
|
|
|
|
{
|
|
|
|
Window xwin = ((XDamageNotifyEvent *) event)->drawable;
|
|
|
|
window = meta_display_lookup_x_window (compositor->display, xwin);
|
|
|
|
}
|
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_process_event (process_damage)\n");
|
2010-04-06 14:10:44 -04:00
|
|
|
process_damage (compositor, (XDamageNotifyEvent *) event, window);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2009-01-30 06:57:46 -05:00
|
|
|
/* Clutter needs to know about MapNotify events otherwise it will
|
|
|
|
think the stage is invisible */
|
|
|
|
if (event->type == MapNotify)
|
|
|
|
clutter_x11_handle_event (event);
|
|
|
|
|
2008-11-22 13:07:32 -05: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 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04: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 17:10:40 -04:00
|
|
|
meta_compositor_show_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaCompEffect effect)
|
2008-06-09 12:50:56 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
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 17:10:40 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_show_window\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
2008-11-23 14:28:40 -05:00
|
|
|
return;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_show (window_actor, effect);
|
2008-11-23 14:28:40 -05:00
|
|
|
}
|
2008-06-09 12:50:56 -04:00
|
|
|
|
2009-06-25 16:17:27 -04: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 17:10:40 -04:00
|
|
|
meta_compositor_hide_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaCompEffect effect)
|
2008-11-23 14:28:40 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
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 17:10:40 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_hide_window\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
2008-10-24 05:07:24 -04:00
|
|
|
return;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_hide (window_actor, effect);
|
2008-06-09 12:50:56 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_maximize_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
2009-06-28 12:26:23 -04:00
|
|
|
MetaRectangle *old_rect,
|
|
|
|
MetaRectangle *new_rect)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_maximize_window\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
2008-09-18 11:09:11 -04:00
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_maximize (window_actor, old_rect, new_rect);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_unmaximize_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
2009-06-28 12:26:23 -04:00
|
|
|
MetaRectangle *old_rect,
|
|
|
|
MetaRectangle *new_rect)
|
2008-08-19 06:47:30 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_unmaximize_window\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
2008-08-19 06:47:30 -04:00
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_unmaximize (window_actor, old_rect, new_rect);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
|
|
|
|
MetaWorkspace *workspace)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
#if 0
|
|
|
|
/* FIXME -- should do away with this function in favour of MetaWorkspace
|
|
|
|
* signal.
|
|
|
|
*/
|
2008-09-18 11:09:11 -04:00
|
|
|
MetaScreen *screen = meta_workspace_get_screen (workspace);
|
|
|
|
MetaCompScreen *info;
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPluginManager *mgr;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_update_workspace_geometry\n");
|
2008-09-18 11:09:11 -04:00
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
mgr = info->plugin_mgr;
|
|
|
|
|
|
|
|
if (!mgr || !workspace)
|
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_update_workspace (mgr, workspace);
|
2008-09-18 11:09:11 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
MetaWorkspace *from,
|
|
|
|
MetaWorkspace *to,
|
|
|
|
MetaMotionDirection direction)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info;
|
|
|
|
gint to_indx, from_indx;
|
|
|
|
|
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
to_indx = meta_workspace_index (to);
|
|
|
|
from_indx = meta_workspace_index (from);
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_switch_workspace\n");
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2009-07-06 03:41:59 -04:00
|
|
|
if (!info) /* During startup before manage_screen() */
|
|
|
|
return;
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
info->switch_workspace_in_progress++;
|
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
2010-10-18 13:27:14 -04:00
|
|
|
!meta_plugin_manager_switch_workspace (info->plugin_mgr,
|
2008-10-24 05:07:24 -04:00
|
|
|
from_indx,
|
|
|
|
to_indx,
|
|
|
|
direction))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
info->switch_workspace_in_progress--;
|
2008-10-24 05:07:24 -04: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.
|
|
|
|
*/
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_finish_workspace_switch (info);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-08-19 06:47:30 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
static void
|
2010-11-13 14:45:01 -05:00
|
|
|
sync_actor_stacking (MetaCompScreen *info)
|
2008-11-23 14:28:40 -05:00
|
|
|
{
|
2010-11-13 14:45:01 -05:00
|
|
|
GList *children;
|
2008-11-23 14:28:40 -05:00
|
|
|
GList *tmp;
|
2010-11-13 14:45:01 -05:00
|
|
|
GList *old;
|
|
|
|
gboolean reordered;
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2010-11-13 14:45:01 -05:00
|
|
|
/* NB: The first entries in the lists are stacked the lowest */
|
2008-11-23 14:28:40 -05:00
|
|
|
|
2010-11-13 14:45:01 -05: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 */
|
|
|
|
|
|
|
|
children = clutter_container_get_children (CLUTTER_CONTAINER (info->window_group));
|
|
|
|
reordered = FALSE;
|
|
|
|
|
|
|
|
old = children;
|
2010-11-14 12:37:17 -05: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.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Of the actors we know, the bottom actor should be the background actor */
|
|
|
|
|
|
|
|
while (old && old->data != info->background_actor && !META_IS_WINDOW_ACTOR (old->data))
|
|
|
|
old = old->next;
|
|
|
|
if (old == NULL || old->data != info->background_actor)
|
|
|
|
{
|
|
|
|
reordered = TRUE;
|
|
|
|
goto done_with_check;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then the window actors should follow in sequence */
|
|
|
|
|
|
|
|
old = old->next;
|
2010-11-13 14:45:01 -05:00
|
|
|
for (tmp = info->windows; tmp != NULL; tmp = tmp->next)
|
|
|
|
{
|
|
|
|
while (old && !META_IS_WINDOW_ACTOR (old->data))
|
|
|
|
old = old->next;
|
|
|
|
|
|
|
|
/* old == NULL: someone reparented a window out of the window group,
|
|
|
|
* order undefined, always restack */
|
|
|
|
if (old == NULL || old->data != tmp->data)
|
|
|
|
{
|
|
|
|
reordered = TRUE;
|
2010-11-14 12:37:17 -05:00
|
|
|
goto done_with_check;
|
2010-11-13 14:45:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
old = old->next;
|
|
|
|
}
|
|
|
|
|
2010-11-14 12:37:17 -05:00
|
|
|
done_with_check:
|
2010-11-13 14:45:01 -05:00
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
|
|
|
|
if (!reordered)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (tmp = g_list_last (info->windows); tmp != NULL; tmp = tmp->prev)
|
2008-11-23 14:28:40 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = tmp->data;
|
2008-11-23 14:28:40 -05:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
clutter_actor_lower_bottom (CLUTTER_ACTOR (window_actor));
|
2008-11-23 14:28:40 -05:00
|
|
|
}
|
2010-11-14 12:37:17 -05:00
|
|
|
|
|
|
|
clutter_actor_lower_bottom (info->background_actor);
|
2008-11-23 14:28:40 -05:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_sync_stack (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
GList *stack)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
2009-06-26 17:05:11 -04:00
|
|
|
GList *old_stack;
|
2008-11-03 09:50:22 -05:00
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-11-27 08:40:52 -05:00
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_sync_stack\n");
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2009-06-26 17:05:11 -04: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 */
|
2010-10-18 13:27:14 -04:00
|
|
|
old_stack = g_list_reverse (info->windows); /* The old stack of MetaWindowActor */
|
2009-06-26 17:05:11 -04:00
|
|
|
info->windows = NULL;
|
|
|
|
|
|
|
|
while (TRUE)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *old_actor = NULL, *stack_actor = NULL, *actor;
|
2009-06-26 17:05:11 -04:00
|
|
|
MetaWindow *old_window = NULL, *stack_window = NULL, *window;
|
2008-11-03 09:50:22 -05:00
|
|
|
|
2009-06-26 17:05:11 -04: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 13:27:14 -04:00
|
|
|
old_window = meta_window_actor_get_meta_window (old_actor);
|
2009-06-26 17:05:11 -04:00
|
|
|
|
|
|
|
if (old_window->hidden &&
|
2010-10-18 13:27:14 -04:00
|
|
|
!meta_window_actor_effect_in_progress (old_actor))
|
2011-01-26 16:35:18 -05:00
|
|
|
{
|
|
|
|
old_stack = g_list_delete_link (old_stack, old_stack);
|
|
|
|
old_actor = NULL;
|
|
|
|
}
|
2009-06-26 17:05:11 -04:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And the remaining top actor in the new stack */
|
|
|
|
while (stack)
|
|
|
|
{
|
|
|
|
stack_window = stack->data;
|
2010-10-18 13:27:14 -04:00
|
|
|
stack_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (stack_window));
|
2009-06-26 17:05:11 -04:00
|
|
|
if (!stack_actor)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_verbose ("Failed to find corresponding MetaWindowActor "
|
2009-06-26 17:05:11 -04: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 &&
|
|
|
|
(!stack_actor || old_window->hidden))
|
|
|
|
{
|
|
|
|
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.)
|
|
|
|
*/
|
|
|
|
info->windows = g_list_prepend (info->windows, actor);
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2009-06-26 17:05:11 -04:00
|
|
|
stack = g_list_remove (stack, window);
|
|
|
|
old_stack = g_list_remove (old_stack, actor);
|
2008-11-03 09:50:22 -05:00
|
|
|
}
|
2008-11-23 14:28:40 -05:00
|
|
|
|
2010-11-13 14:45:01 -05:00
|
|
|
sync_actor_stacking (info);
|
2008-11-03 09:50:22 -05:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04: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 17:10:40 -04:00
|
|
|
meta_compositor_window_mapped (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-11-03 09:50:22 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
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 17:10:40 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_window_mapped\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
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 17:10:40 -04:00
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_mapped (window_actor);
|
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 17:10:40 -04:00
|
|
|
}
|
2008-11-03 09:50:22 -05: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 17:10:40 -04:00
|
|
|
void
|
|
|
|
meta_compositor_window_unmapped (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
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 17:10:40 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_window_unmapped\n");
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
2008-11-23 14:28:40 -05:00
|
|
|
return;
|
2008-11-03 05:26:21 -05:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_unmapped (window_actor);
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_sync_window_geometry (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-11-27 08:40:52 -05:00
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_sync_window_geometry\n");
|
2008-11-27 08:40:52 -05:00
|
|
|
g_return_if_fail (info);
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!window_actor)
|
2008-11-27 08:40:52 -05:00
|
|
|
return;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_sync_actor_position (window_actor);
|
2008-11-27 08:40:52 -05:00
|
|
|
}
|
|
|
|
|
2009-06-25 16:17:27 -04:00
|
|
|
void
|
|
|
|
meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
guint width,
|
|
|
|
guint height)
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
2009-06-27 12:10:32 -04:00
|
|
|
DEBUG_TRACE ("meta_compositor_sync_screen_size\n");
|
2008-11-27 08:40:52 -05:00
|
|
|
g_return_if_fail (info);
|
|
|
|
|
|
|
|
clutter_actor_set_size (info->stage, width, height);
|
2010-11-15 16:19:28 -05:00
|
|
|
|
2011-08-28 14:09:42 -04:00
|
|
|
meta_background_actor_screen_size_changed (screen);
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
meta_verbose ("Changed size for stage on screen %d to %dx%d\n",
|
|
|
|
meta_screen_get_screen_number (screen),
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
|
2009-06-28 12:26:23 -04:00
|
|
|
static void
|
|
|
|
pre_paint_windows (MetaCompScreen *info)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = info->windows; l; l = l->next)
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_actor_pre_paint (l->data);
|
2009-06-28 12:26:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_repaint_func (gpointer data)
|
2009-06-28 12:26:23 -04:00
|
|
|
{
|
|
|
|
MetaCompositor *compositor = data;
|
|
|
|
GSList *screens = meta_display_get_screens (compositor->display);
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
for (l = screens; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaScreen *screen = l->data;
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
if (!info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pre_paint_windows (info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-11-11 16:24:43 -05:00
|
|
|
static void
|
|
|
|
on_shadow_factory_changed (MetaShadowFactory *factory,
|
|
|
|
MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
GSList *screens = meta_display_get_screens (compositor->display);
|
|
|
|
GList *l;
|
|
|
|
GSList *sl;
|
|
|
|
|
|
|
|
for (sl = screens; sl; sl = sl->next)
|
|
|
|
{
|
|
|
|
MetaScreen *screen = sl->data;
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
if (!info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (l = info->windows; l; l = l->next)
|
|
|
|
meta_window_actor_invalidate_shadow (l->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
|
|
|
* meta_compositor_new: (skip)
|
|
|
|
*
|
|
|
|
*/
|
2008-06-04 08:58:36 -04:00
|
|
|
MetaCompositor *
|
2009-06-25 16:17:27 -04:00
|
|
|
meta_compositor_new (MetaDisplay *display)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
char *atom_names[] = {
|
|
|
|
"_XROOTPMAP_ID",
|
|
|
|
"_XSETROOT_ID",
|
|
|
|
"_NET_WM_WINDOW_OPACITY",
|
|
|
|
};
|
2008-08-20 04:33:39 -04:00
|
|
|
Atom atoms[G_N_ELEMENTS(atom_names)];
|
|
|
|
MetaCompositor *compositor;
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
if (!composite_at_least_version (display, 0, 3))
|
|
|
|
return NULL;
|
|
|
|
|
2009-06-25 16:29:20 -04:00
|
|
|
compositor = g_new0 (MetaCompositor, 1);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2009-06-25 16:29:20 -04:00
|
|
|
compositor->display = display;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (g_getenv("META_DISABLE_MIPMAPS"))
|
2009-06-25 16:29:20 -04:00
|
|
|
compositor->no_mipmaps = TRUE;
|
2008-11-05 06:48:07 -05:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_verbose ("Creating %d atoms\n", (int) G_N_ELEMENTS (atom_names));
|
|
|
|
XInternAtoms (xdisplay, atom_names, G_N_ELEMENTS (atom_names),
|
|
|
|
False, atoms);
|
|
|
|
|
2010-11-11 16:24:43 -05:00
|
|
|
g_signal_connect (meta_shadow_factory_get_default (),
|
|
|
|
"changed",
|
|
|
|
G_CALLBACK (on_shadow_factory_changed),
|
|
|
|
compositor);
|
|
|
|
|
2009-06-25 16:29:20 -04:00
|
|
|
compositor->atom_x_root_pixmap = atoms[0];
|
|
|
|
compositor->atom_x_set_root = atoms[1];
|
|
|
|
compositor->atom_net_wm_window_opacity = atoms[2];
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
compositor->repaint_func_id = clutter_threads_add_repaint_func (meta_repaint_func,
|
2009-06-28 12:26:23 -04:00
|
|
|
compositor,
|
|
|
|
NULL);
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return compositor;
|
|
|
|
}
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2010-09-01 15:39:53 -04:00
|
|
|
/**
|
2010-10-18 13:27:14 -04:00
|
|
|
* meta_get_overlay_window: (skip)
|
2010-09-01 15:39:53 -04:00
|
|
|
*
|
|
|
|
*/
|
2008-10-16 02:50:49 -04:00
|
|
|
Window
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_get_overlay_window (MetaScreen *screen)
|
2008-10-16 02:50:49 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
return info->output;
|
|
|
|
}
|
2011-03-18 09:36:28 -04:00
|
|
|
|
|
|
|
#define FLASH_TIME_MS 50
|
|
|
|
|
|
|
|
static void
|
|
|
|
flash_out_completed (ClutterAnimation *animation,
|
|
|
|
ClutterActor *flash)
|
|
|
|
{
|
|
|
|
clutter_actor_destroy (flash);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
flash_in_completed (ClutterAnimation *animation,
|
|
|
|
ClutterActor *flash)
|
|
|
|
{
|
|
|
|
clutter_actor_animate (flash, CLUTTER_EASE_IN_QUAD,
|
|
|
|
FLASH_TIME_MS,
|
|
|
|
"opacity", 0,
|
|
|
|
"signal-after::completed", flash_out_completed, flash,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_compositor_flash_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
|
|
|
ClutterActor *stage;
|
|
|
|
ClutterActor *flash;
|
|
|
|
ClutterColor black = { 0, 0, 0, 255 };
|
|
|
|
gfloat width, height;
|
|
|
|
|
|
|
|
stage = meta_get_stage_for_screen (screen);
|
|
|
|
clutter_actor_get_size (stage, &width, &height);
|
|
|
|
|
|
|
|
flash = clutter_rectangle_new_with_color (&black);
|
|
|
|
clutter_actor_set_size (flash, width, height);
|
|
|
|
clutter_actor_set_opacity (flash, 0);
|
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), flash);
|
|
|
|
|
|
|
|
clutter_actor_animate (flash, CLUTTER_EASE_OUT_QUAD,
|
|
|
|
FLASH_TIME_MS,
|
|
|
|
"opacity", 192,
|
|
|
|
"signal-after::completed", flash_in_completed, flash,
|
|
|
|
NULL);
|
|
|
|
}
|