Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to unredirect windows #86

Merged
merged 4 commits into from
Jun 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 66 additions & 19 deletions src/compositor/meta-window-actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ struct _MetaWindowActorPrivate
guint no_more_x_calls : 1;

guint unredirected : 1;

/* This is used to detect fullscreen windows that need to be unredirected */
guint full_damage_frames_count;
guint does_full_damage : 1;
};

enum
Expand Down Expand Up @@ -1192,35 +1196,60 @@ LOCAL_SYMBOL gboolean
meta_window_actor_should_unredirect (MetaWindowActor *self)
{
MetaWindow *metaWindow = meta_window_actor_get_meta_window (self);
MetaScreen *screen = meta_window_get_screen (metaWindow);
MetaWindowActorPrivate *priv = self->priv;

if (meta_window_is_override_redirect (metaWindow) && priv->opacity == 0xff && !priv->argb32)
gboolean occupies_full_monitors = FALSE;

if (meta_window_requested_dont_bypass_compositor (metaWindow))
return FALSE;

if (priv->opacity != 0xff)
return FALSE;

if (metaWindow->has_shape)
return FALSE;

if (priv->argb32 && !meta_window_requested_bypass_compositor (metaWindow))
return FALSE;

if (meta_window_is_fullscreen (metaWindow))
occupies_full_monitors = TRUE;
else if (meta_window_is_override_redirect (metaWindow))
{
int screen_width, screen_height;
MetaRectangle window_rect;
MetaScreen *screen = meta_window_get_screen (metaWindow);
MetaRectangle window_rect, monitor_rect;

int num_monitors = meta_screen_get_n_monitors (screen);
int screen_width, screen_height, i;

meta_screen_get_size (screen, &screen_width, &screen_height);
meta_window_get_outer_rect (metaWindow, &window_rect);
meta_window_get_outer_rect (priv->window, &window_rect);

if (window_rect.x == 0 && window_rect.y == 0 &&
window_rect.width == screen_width && window_rect.height == screen_height)
return TRUE;
else
{
int num_monitors = meta_screen_get_n_monitors (screen);
int i;
MetaRectangle monitor_rect;
occupies_full_monitors = TRUE;

for (i = 0; i < num_monitors; i++)
{
meta_screen_get_monitor_geometry (screen , i, &monitor_rect);
if (monitor_rect.x == window_rect.x && monitor_rect.y == window_rect.y &&
monitor_rect.width == window_rect.width && monitor_rect.height == window_rect.height)
return TRUE;
}
for (i = 0; i < num_monitors; i++)
{
meta_screen_get_monitor_geometry (screen , i, &monitor_rect);
if (monitor_rect.x == window_rect.x && monitor_rect.y == window_rect.y &&
monitor_rect.width == window_rect.width && monitor_rect.height == window_rect.height)
occupies_full_monitors = TRUE;
}
}

if (!occupies_full_monitors)
return FALSE;

if (meta_window_requested_bypass_compositor (metaWindow))
return TRUE;

if (meta_window_is_override_redirect (metaWindow))
return TRUE;

if (priv->does_full_damage)
return TRUE;

return FALSE;
}

Expand Down Expand Up @@ -1981,11 +2010,29 @@ meta_window_actor_process_damage (MetaWindowActor *self,
XDamageNotifyEvent *event)
{
MetaWindowActorPrivate *priv = self->priv;
MetaCompScreen *info = meta_screen_get_compositor_data (priv->screen);

priv->received_damage = TRUE;

if (meta_window_is_fullscreen (priv->window) && g_list_last (info->windows)->data == self && !priv->unredirected)
{
MetaRectangle window_rect;
meta_window_get_outer_rect (priv->window, &window_rect);

if (window_rect.x == event->area.x &&
window_rect.y == event->area.y &&
window_rect.width == event->area.width &&
window_rect.height == event->area.height)
priv->full_damage_frames_count++;
else
priv->full_damage_frames_count = 0;

if (priv->full_damage_frames_count >= 100)
priv->does_full_damage = TRUE;
}

/* Drop damage event for unredirected windows */
if (self->priv->unredirected)
if (priv->unredirected)
return;

if (is_frozen (self))
Expand Down
4 changes: 4 additions & 0 deletions src/core/window-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ struct _MetaWindow

/* The currently complementary tiled window, if any */
MetaWindow *tile_match;

/* Bypass compositor hints */
guint bypass_compositor : 1;
guint dont_bypass_compositor : 1;
};

struct _MetaWindowClass
Expand Down
54 changes: 54 additions & 0 deletions src/core/window-props.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,58 @@ reload_gtk_hide_titlebar_when_maximized (MetaWindow *window,
}
}

static void
reload_bypass_compositor (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
gboolean requested_value = FALSE;
gboolean current_value = window->bypass_compositor;

if (value->type != META_PROP_VALUE_INVALID)
{
requested_value = ((int) value->v.cardinal == 1);
meta_verbose ("Request to bypass compositor for window %s.\n", window->desc);
}

if (requested_value == current_value)
return;

if (requested_value && window->dont_bypass_compositor)
{
meta_verbose ("Setting bypass and dont compositor for same window (%s) makes no sense, ignoring.\n", window->desc);
return;
}

window->bypass_compositor = requested_value;
}

static void
reload_dont_bypass_compositor (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
gboolean requested_value = FALSE;
gboolean current_value = window->dont_bypass_compositor;

if (value->type != META_PROP_VALUE_INVALID)
{
requested_value = ((int) value->v.cardinal == 1);
meta_verbose ("Request to don't bypass compositor for window %s.\n", window->desc);
}

if (requested_value == current_value)
return;

if (requested_value && window->bypass_compositor)
{
meta_verbose ("Setting bypass and dont compositor for same window (%s) makes no sense, ignoring.\n", window->desc);
return;
}

window->dont_bypass_compositor = requested_value;
}

#define RELOAD_STRING(var_name, propname) \
static void \
reload_ ## var_name (MetaWindow *window, \
Expand Down Expand Up @@ -1716,6 +1768,8 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
{ display->atom__NET_WM_WINDOW_TYPE, META_PROP_VALUE_INVALID, reload_net_wm_window_type, FALSE, TRUE },
{ display->atom__NET_WM_STRUT, META_PROP_VALUE_INVALID, reload_struts, FALSE, FALSE },
{ display->atom__NET_WM_STRUT_PARTIAL, META_PROP_VALUE_INVALID, reload_struts, FALSE, FALSE },
{ display->atom__NET_WM_BYPASS_COMPOSITOR, META_PROP_VALUE_CARDINAL, reload_bypass_compositor, FALSE, FALSE },
{ display->atom__NET_WM_DONT_BYPASS_COMPOSITOR, META_PROP_VALUE_CARDINAL, reload_dont_bypass_compositor, FALSE, FALSE },
{ 0 },
};

Expand Down
22 changes: 22 additions & 0 deletions src/core/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -3632,6 +3632,28 @@ meta_window_is_on_primary_monitor (MetaWindow *window)
return window->monitor->is_primary;
}

/**
* meta_window_requested_bypass_compositor:
*
* Return value: %TRUE if the window requested to bypass the compositor
*/
gboolean
meta_window_requested_bypass_compositor (MetaWindow *window)
{
return window->bypass_compositor;
}

/**
* meta_window_requested_dont_bypass_compositor:
*
* Return value: %TRUE if the window requested to opt out of unredirecting
*/
gboolean
meta_window_requested_dont_bypass_compositor (MetaWindow *window)
{
return window->dont_bypass_compositor;
}

LOCAL_SYMBOL void
meta_window_tile (MetaWindow *window)
{
Expand Down
2 changes: 2 additions & 0 deletions src/meta/atomnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ item(_NET_WM_ACTION_BELOW)
item(_NET_WM_STATE_STICKY)
item(_NET_WM_FULLSCREEN_MONITORS)
item(_NET_WM_STATE_FOCUSED)
item(_NET_WM_BYPASS_COMPOSITOR)
item(_NET_WM_DONT_BYPASS_COMPOSITOR)

#if 0
/* We apparently never use: */
Expand Down
4 changes: 4 additions & 0 deletions src/meta/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ gboolean meta_window_is_on_primary_monitor (MetaWindow *window);

gboolean meta_window_is_demanding_attention (MetaWindow *window);
gboolean meta_window_is_urgent (MetaWindow *window);

gboolean meta_window_requested_bypass_compositor (MetaWindow *window);
gboolean meta_window_requested_dont_bypass_compositor (MetaWindow *window);

gboolean meta_window_is_mapped (MetaWindow *window);
gboolean meta_window_toplevel_is_mapped (MetaWindow *window);
gboolean meta_window_get_icon_geometry (MetaWindow *window,
Expand Down