Move rest of non-X11 specific objects from MetaScreen

This moves following objects from MetaScreen to MetaDisplay

- workareas_later and in_fullscreen_later signals and functions
- startup_sequences signals and functions
- tile_preview functions

https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
Armin Krezović 2017-08-26 21:10:38 +02:00 committed by Jonas Ådahl
parent 1530f27513
commit 68f261e8e2
12 changed files with 534 additions and 543 deletions

View File

@ -237,6 +237,14 @@ struct _MetaDisplay
MetaStack *stack;
MetaStackTracker *stack_tracker;
guint tile_preview_timeout_id;
guint preview_tile_mode : 2;
GSList *startup_sequences;
guint work_area_later;
guint check_fullscreen_later;
};
struct _MetaDisplayClass
@ -412,4 +420,15 @@ void meta_display_foreach_window (MetaDisplay *display,
void meta_display_restacked (MetaDisplay *display);
void meta_display_update_tile_preview (MetaDisplay *display,
gboolean delay);
void meta_display_hide_tile_preview (MetaDisplay *display);
gboolean meta_display_apply_startup_properties (MetaDisplay *display,
MetaWindow *window);
void meta_display_queue_workarea_recalc (MetaDisplay *display);
void meta_display_queue_check_fullscreen (MetaDisplay *display);
#endif

View File

@ -136,8 +136,13 @@ enum
SHOW_PAD_OSD,
SHOW_OSD,
PAD_MODE_SWITCH,
WINDOW_ENTERED_MONITOR,
WINDOW_LEFT_MONITOR,
IN_FULLSCREEN_CHANGED,
STARTUP_SEQUENCE_CHANGED,
MONITORS_CHANGED,
RESTACKED,
WORKAREAS_CHANGED,
LAST_SIGNAL
};
@ -423,6 +428,38 @@ meta_display_class_init (MetaDisplayClass *klass)
G_TYPE_NONE, 3, CLUTTER_TYPE_INPUT_DEVICE,
G_TYPE_UINT, G_TYPE_UINT);
display_signals[WINDOW_ENTERED_MONITOR] =
g_signal_new ("window-entered-monitor",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_INT,
META_TYPE_WINDOW);
display_signals[WINDOW_LEFT_MONITOR] =
g_signal_new ("window-left-monitor",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_INT,
META_TYPE_WINDOW);
display_signals[IN_FULLSCREEN_CHANGED] =
g_signal_new ("in-fullscreen-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
display_signals[STARTUP_SEQUENCE_CHANGED] =
g_signal_new ("startup-sequence-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_POINTER);
display_signals[MONITORS_CHANGED] =
g_signal_new ("monitors-changed",
G_TYPE_FROM_CLASS (klass),
@ -437,6 +474,13 @@ meta_display_class_init (MetaDisplayClass *klass)
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
display_signals[WORKAREAS_CHANGED] =
g_signal_new ("workareas-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
g_object_class_install_property (object_class,
PROP_FOCUS_WINDOW,
g_param_spec_object ("focus-window",
@ -579,13 +623,10 @@ on_startup_notification_changed (MetaStartupNotification *sn,
gpointer sequence,
MetaDisplay *display)
{
if (!display->screen)
return;
g_slist_free (display->screen->startup_sequences);
display->screen->startup_sequences =
g_slist_free (display->startup_sequences);
display->startup_sequences =
meta_startup_notification_get_sequences (display->startup_notification);
g_signal_emit_by_name (display->screen, "startup-sequence-changed", sequence);
g_signal_emit_by_name (display, "startup-sequence-changed", sequence);
}
/**
@ -626,6 +667,9 @@ meta_display_open (void)
display->rect.x = display->rect.y = 0;
display->current_cursor = -1; /* invalid/unset */
display->tile_preview_timeout_id = 0;
display->check_fullscreen_later = 0;
display->work_area_later = 0;
display->mouse_mode = TRUE; /* Only relevant for mouse or sloppy focus */
display->allow_terminal_deactivation = TRUE; /* Only relevant for when a
@ -895,6 +939,15 @@ meta_display_close (MetaDisplay *display,
g_source_remove (display->focus_timeout_id);
display->focus_timeout_id = 0;
if (display->tile_preview_timeout_id)
g_source_remove (display->tile_preview_timeout_id);
display->tile_preview_timeout_id = 0;
if (display->work_area_later != 0)
meta_later_remove (display->work_area_later);
if (display->check_fullscreen_later != 0)
meta_later_remove (display->check_fullscreen_later);
/* Stop caring about events */
meta_display_free_events (display);
@ -2955,6 +3008,8 @@ on_monitors_changed_internal (MetaMonitorManager *monitor_manager,
meta_display_foreach_window (display, META_LIST_DEFAULT,
meta_display_resize_func, 0);
meta_display_queue_check_fullscreen (display);
backend = meta_get_backend ();
cursor_renderer = meta_backend_get_cursor_renderer (backend);
meta_cursor_renderer_force_update (cursor_renderer);
@ -2972,3 +3027,421 @@ meta_display_restacked (MetaDisplay *display)
{
g_signal_emit (display, display_signals[RESTACKED], 0);
}
static gboolean
meta_display_update_tile_preview_timeout (gpointer data)
{
MetaDisplay *display = data;
MetaWindow *window = display->grab_window;
gboolean needs_preview = FALSE;
display->tile_preview_timeout_id = 0;
if (window)
{
switch (display->preview_tile_mode)
{
case META_TILE_LEFT:
case META_TILE_RIGHT:
if (!META_WINDOW_TILED_SIDE_BY_SIDE (window))
needs_preview = TRUE;
break;
case META_TILE_MAXIMIZED:
if (!META_WINDOW_MAXIMIZED (window))
needs_preview = TRUE;
break;
default:
needs_preview = FALSE;
break;
}
}
if (needs_preview)
{
MetaRectangle tile_rect;
int monitor;
monitor = meta_window_get_current_tile_monitor_number (window);
meta_window_get_tile_area (window, display->preview_tile_mode,
&tile_rect);
meta_compositor_show_tile_preview (display->compositor,
window, &tile_rect, monitor);
}
else
meta_compositor_hide_tile_preview (display->compositor);
return FALSE;
}
#define TILE_PREVIEW_TIMEOUT_MS 200
void
meta_display_update_tile_preview (MetaDisplay *display,
gboolean delay)
{
if (delay)
{
if (display->tile_preview_timeout_id > 0)
return;
display->tile_preview_timeout_id =
g_timeout_add (TILE_PREVIEW_TIMEOUT_MS,
meta_display_update_tile_preview_timeout,
display);
g_source_set_name_by_id (display->tile_preview_timeout_id,
"[mutter] meta_display_update_tile_preview_timeout");
}
else
{
if (display->tile_preview_timeout_id > 0)
g_source_remove (display->tile_preview_timeout_id);
meta_display_update_tile_preview_timeout ((gpointer)display);
}
}
void
meta_display_hide_tile_preview (MetaDisplay *display)
{
if (display->tile_preview_timeout_id > 0)
g_source_remove (display->tile_preview_timeout_id);
display->preview_tile_mode = META_TILE_NONE;
meta_compositor_hide_tile_preview (display->compositor);
}
/**
* meta_display_get_startup_sequences: (skip)
* @display:
*
* Return value: (transfer none): Currently active #SnStartupSequence items
*/
GSList *
meta_display_get_startup_sequences (MetaDisplay *display)
{
return display->startup_sequences;
}
/* Sets the initial_timestamp and initial_workspace properties
* of a window according to information given us by the
* startup-notification library.
*
* Returns TRUE if startup properties have been applied, and
* FALSE if they have not (for example, if they had already
* been applied.)
*/
gboolean
meta_display_apply_startup_properties (MetaDisplay *display,
MetaWindow *window)
{
#ifdef HAVE_STARTUP_NOTIFICATION
const char *startup_id;
GSList *l;
SnStartupSequence *sequence;
/* Does the window have a startup ID stored? */
startup_id = meta_window_get_startup_id (window);
meta_topic (META_DEBUG_STARTUP,
"Applying startup props to %s id \"%s\"\n",
window->desc,
startup_id ? startup_id : "(none)");
sequence = NULL;
if (!startup_id)
{
/* No startup ID stored for the window. Let's ask the
* startup-notification library whether there's anything
* stored for the resource name or resource class hints.
*/
for (l = display->startup_sequences; l; l = l->next)
{
const char *wmclass;
SnStartupSequence *seq = l->data;
wmclass = sn_startup_sequence_get_wmclass (seq);
if (wmclass != NULL &&
((window->res_class &&
strcmp (wmclass, window->res_class) == 0) ||
(window->res_name &&
strcmp (wmclass, window->res_name) == 0)))
{
sequence = seq;
g_assert (window->startup_id == NULL);
window->startup_id = g_strdup (sn_startup_sequence_get_id (sequence));
startup_id = window->startup_id;
meta_topic (META_DEBUG_STARTUP,
"Ending legacy sequence %s due to window %s\n",
sn_startup_sequence_get_id (sequence),
window->desc);
sn_startup_sequence_complete (sequence);
break;
}
}
}
/* Still no startup ID? Bail. */
if (!startup_id)
return FALSE;
/* We might get this far and not know the sequence ID (if the window
* already had a startup ID stored), so let's look for one if we don't
* already know it.
*/
if (sequence == NULL)
{
for (l = display->startup_sequences; l != NULL; l = l->next)
{
SnStartupSequence *seq = l->data;
const char *id;
id = sn_startup_sequence_get_id (seq);
if (strcmp (id, startup_id) == 0)
{
sequence = seq;
break;
}
}
}
if (sequence != NULL)
{
gboolean changed_something = FALSE;
meta_topic (META_DEBUG_STARTUP,
"Found startup sequence for window %s ID \"%s\"\n",
window->desc, startup_id);
if (!window->initial_workspace_set)
{
int space = sn_startup_sequence_get_workspace (sequence);
if (space >= 0)
{
meta_topic (META_DEBUG_STARTUP,
"Setting initial window workspace to %d based on startup info\n",
space);
window->initial_workspace_set = TRUE;
window->initial_workspace = space;
changed_something = TRUE;
}
}
if (!window->initial_timestamp_set)
{
guint32 timestamp = sn_startup_sequence_get_timestamp (sequence);
meta_topic (META_DEBUG_STARTUP,
"Setting initial window timestamp to %u based on startup info\n",
timestamp);
window->initial_timestamp_set = TRUE;
window->initial_timestamp = timestamp;
changed_something = TRUE;
}
return changed_something;
}
else
{
meta_topic (META_DEBUG_STARTUP,
"Did not find startup sequence for window %s ID \"%s\"\n",
window->desc, startup_id);
}
#endif /* HAVE_STARTUP_NOTIFICATION */
return FALSE;
}
static void
set_work_area_hint (MetaDisplay *display)
{
MetaX11Display *x11_display = display->x11_display;
MetaScreen *screen = display->screen;
int num_workspaces;
GList *l;
unsigned long *data, *tmp;
MetaRectangle area;
num_workspaces = meta_screen_get_n_workspaces (screen);
data = g_new (unsigned long, num_workspaces * 4);
tmp = data;
for (l = screen->workspaces; l; l = l->next)
{
MetaWorkspace *workspace = l->data;
meta_workspace_get_work_area_all_monitors (workspace, &area);
tmp[0] = area.x;
tmp[1] = area.y;
tmp[2] = area.width;
tmp[3] = area.height;
tmp += 4;
}
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_WORKAREA,
XA_CARDINAL, 32, PropModeReplace,
(guchar*) data, num_workspaces*4);
meta_error_trap_pop (x11_display);
g_free (data);
g_signal_emit (display, display_signals[WORKAREAS_CHANGED], 0);
}
static gboolean
set_work_area_later_func (MetaDisplay *display)
{
meta_topic (META_DEBUG_WORKAREA,
"Running work area hint computation function\n");
display->work_area_later = 0;
set_work_area_hint (display);
return FALSE;
}
void
meta_display_queue_workarea_recalc (MetaDisplay *display)
{
/* Recompute work area later before redrawing */
if (display->work_area_later == 0)
{
meta_topic (META_DEBUG_WORKAREA,
"Adding work area hint computation function\n");
display->work_area_later =
meta_later_add (META_LATER_BEFORE_REDRAW,
(GSourceFunc) set_work_area_later_func,
display,
NULL);
}
}
static gboolean
check_fullscreen_func (gpointer data)
{
MetaDisplay *display = data;
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
GList *logical_monitors, *l;
MetaWindow *window;
GSList *fullscreen_monitors = NULL;
GSList *obscured_monitors = NULL;
gboolean in_fullscreen_changed = FALSE;
display->check_fullscreen_later = 0;
logical_monitors =
meta_monitor_manager_get_logical_monitors (monitor_manager);
/* We consider a monitor in fullscreen if it contains a fullscreen window;
* however we make an exception for maximized windows above the fullscreen
* one, as in that case window+chrome fully obscure the fullscreen window.
*/
for (window = meta_stack_get_top (display->stack);
window;
window = meta_stack_get_below (display->stack, window, FALSE))
{
gboolean covers_monitors = FALSE;
if (window->hidden)
continue;
if (window->fullscreen)
{
covers_monitors = TRUE;
}
else if (window->override_redirect)
{
/* We want to handle the case where an application is creating an
* override-redirect window the size of the screen (monitor) and treat
* it similarly to a fullscreen window, though it doesn't have fullscreen
* window management behavior. (Being O-R, it's not managed at all.)
*/
if (meta_window_is_monitor_sized (window))
covers_monitors = TRUE;
}
else if (window->maximized_horizontally &&
window->maximized_vertically)
{
MetaLogicalMonitor *logical_monitor;
logical_monitor = meta_window_get_main_logical_monitor (window);
if (!g_slist_find (obscured_monitors, logical_monitor))
obscured_monitors = g_slist_prepend (obscured_monitors,
logical_monitor);
}
if (covers_monitors)
{
MetaRectangle window_rect;
meta_window_get_frame_rect (window, &window_rect);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
if (meta_rectangle_overlap (&window_rect,
&logical_monitor->rect) &&
!g_slist_find (fullscreen_monitors, logical_monitor) &&
!g_slist_find (obscured_monitors, logical_monitor))
fullscreen_monitors = g_slist_prepend (fullscreen_monitors,
logical_monitor);
}
}
}
g_slist_free (obscured_monitors);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
gboolean in_fullscreen;
in_fullscreen = g_slist_find (fullscreen_monitors,
logical_monitor) != NULL;
if (in_fullscreen != logical_monitor->in_fullscreen)
{
logical_monitor->in_fullscreen = in_fullscreen;
in_fullscreen_changed = TRUE;
}
}
g_slist_free (fullscreen_monitors);
if (in_fullscreen_changed)
{
/* DOCK window stacking depends on the monitor's fullscreen
status so we need to trigger a re-layering. */
MetaWindow *window = meta_stack_get_top (display->stack);
if (window)
meta_stack_update_layer (display->stack, window);
g_signal_emit (display, display_signals[IN_FULLSCREEN_CHANGED], 0, NULL);
}
return FALSE;
}
void
meta_display_queue_check_fullscreen (MetaDisplay *display)
{
if (!display->check_fullscreen_later)
display->check_fullscreen_later = meta_later_add (META_LATER_CHECK_FULLSCREEN,
check_fullscreen_func,
display, NULL);
}

View File

@ -2241,8 +2241,8 @@ process_mouse_move_resize_grab (MetaDisplay *display,
MetaTileMode tile_mode;
/* Hide the tiling preview if necessary */
if (screen->preview_tile_mode != META_TILE_NONE)
meta_screen_hide_tile_preview (screen);
if (display->preview_tile_mode != META_TILE_NONE)
meta_display_hide_tile_preview (display);
/* Restore the original tile mode */
tile_mode = display->grab_tile_mode;

View File

@ -47,20 +47,12 @@ struct _MetaScreen
MetaDisplay *display;
MetaUI *ui;
guint tile_preview_timeout_id;
guint preview_tile_mode : 2;
MetaWorkspace *active_workspace;
GList *workspaces;
gboolean has_xinerama_indices;
GSList *startup_sequences;
guint work_area_later;
guint check_fullscreen_later;
int rows_of_workspaces;
int columns_of_workspaces;
MetaScreenCorner starting_corner;
@ -75,8 +67,6 @@ struct _MetaScreen
struct _MetaScreenClass
{
GObjectClass parent_class;
void (*workareas_changed) (MetaScreen *);
};
MetaScreen* meta_screen_new (MetaDisplay *display,
@ -86,17 +76,11 @@ void meta_screen_free (MetaScreen *scree
void meta_screen_init_workspaces (MetaScreen *screen);
void meta_screen_manage_all_windows (MetaScreen *screen);
void meta_screen_update_tile_preview (MetaScreen *screen,
gboolean delay);
void meta_screen_hide_tile_preview (MetaScreen *screen);
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one);
void meta_screen_update_workspace_layout (MetaScreen *screen);
void meta_screen_update_workspace_names (MetaScreen *screen);
void meta_screen_queue_workarea_recalc (MetaScreen *screen);
void meta_screen_queue_check_fullscreen (MetaScreen *screen);
typedef struct MetaWorkspaceLayout MetaWorkspaceLayout;
@ -127,9 +111,6 @@ void meta_screen_unshow_desktop (MetaScreen *screen);
/* Update whether the destkop is being shown for the current active_workspace */
void meta_screen_update_showing_desktop_hint (MetaScreen *screen);
gboolean meta_screen_apply_startup_properties (MetaScreen *screen,
MetaWindow *window);
void meta_screen_workspace_switched (MetaScreen *screen,
int from,
int to,

View File

@ -79,11 +79,6 @@ enum
WORKSPACE_ADDED,
WORKSPACE_REMOVED,
WORKSPACE_SWITCHED,
WINDOW_ENTERED_MONITOR,
WINDOW_LEFT_MONITOR,
STARTUP_SEQUENCE_CHANGED,
WORKAREAS_CHANGED,
IN_FULLSCREEN_CHANGED,
LAST_SIGNAL
};
@ -190,50 +185,6 @@ meta_screen_class_init (MetaScreenClass *klass)
G_TYPE_INT,
META_TYPE_MOTION_DIRECTION);
screen_signals[WINDOW_ENTERED_MONITOR] =
g_signal_new ("window-entered-monitor",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_INT,
META_TYPE_WINDOW);
screen_signals[WINDOW_LEFT_MONITOR] =
g_signal_new ("window-left-monitor",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_INT,
META_TYPE_WINDOW);
screen_signals[STARTUP_SEQUENCE_CHANGED] =
g_signal_new ("startup-sequence-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_POINTER);
screen_signals[WORKAREAS_CHANGED] =
g_signal_new ("workareas-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (MetaScreenClass, workareas_changed),
NULL, NULL, NULL,
G_TYPE_NONE, 0);
screen_signals[IN_FULLSCREEN_CHANGED] =
g_signal_new ("in-fullscreen-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
g_object_class_install_property (object_class,
PROP_N_WORKSPACES,
pspec);
@ -401,9 +352,6 @@ meta_screen_new (MetaDisplay *display,
screen->display = display;
screen->work_area_later = 0;
screen->check_fullscreen_later = 0;
screen->active_workspace = NULL;
screen->workspaces = NULL;
screen->rows_of_workspaces = 1;
@ -425,8 +373,6 @@ meta_screen_new (MetaDisplay *display,
screen->ui = meta_ui_new (xdisplay);
screen->tile_preview_timeout_id = 0;
meta_prefs_add_listener (prefs_changed_callback, screen);
meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
@ -484,14 +430,6 @@ meta_screen_free (MetaScreen *screen,
meta_ui_free (screen->ui);
if (screen->work_area_later != 0)
meta_later_remove (screen->work_area_later);
if (screen->check_fullscreen_later != 0)
meta_later_remove (screen->check_fullscreen_later);
if (screen->tile_preview_timeout_id)
g_source_remove (screen->tile_preview_timeout_id);
g_object_unref (screen);
}
@ -545,7 +483,7 @@ meta_screen_get_workspace_by_index (MetaScreen *screen,
static void
set_number_of_spaces_hint (MetaScreen *screen,
int n_spaces)
int n_spaces)
{
MetaX11Display *x11_display = screen->display->x11_display;
unsigned long data[1];
@ -623,7 +561,7 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
meta_workspace_index_changed (w);
}
meta_screen_queue_workarea_recalc (screen);
meta_display_queue_workarea_recalc (screen->display);
g_signal_emit (screen, screen_signals[WORKSPACE_REMOVED], 0, index);
g_object_notify (G_OBJECT (screen), "n-workspaces");
@ -665,7 +603,7 @@ meta_screen_append_new_workspace (MetaScreen *screen, gboolean activate,
if (!meta_prefs_get_dynamic_workspaces ())
meta_prefs_set_num_workspaces (new_num);
meta_screen_queue_workarea_recalc (screen);
meta_display_queue_workarea_recalc (screen->display);
g_signal_emit (screen, screen_signals[WORKSPACE_ADDED],
0, meta_workspace_index (w));
@ -775,7 +713,7 @@ update_num_workspaces (MetaScreen *screen,
set_number_of_spaces_hint (screen, new_num);
meta_screen_queue_workarea_recalc (screen);
meta_display_queue_workarea_recalc (display);
for (i = old_num; i < new_num; i++)
g_signal_emit (screen, screen_signals[WORKSPACE_ADDED], 0, i);
@ -783,90 +721,6 @@ update_num_workspaces (MetaScreen *screen,
g_object_notify (G_OBJECT (screen), "n-workspaces");
}
static gboolean
meta_screen_update_tile_preview_timeout (gpointer data)
{
MetaScreen *screen = data;
MetaWindow *window = screen->display->grab_window;
gboolean needs_preview = FALSE;
screen->tile_preview_timeout_id = 0;
if (window)
{
switch (screen->preview_tile_mode)
{
case META_TILE_LEFT:
case META_TILE_RIGHT:
if (!META_WINDOW_TILED_SIDE_BY_SIDE (window))
needs_preview = TRUE;
break;
case META_TILE_MAXIMIZED:
if (!META_WINDOW_MAXIMIZED (window))
needs_preview = TRUE;
break;
default:
needs_preview = FALSE;
break;
}
}
if (needs_preview)
{
MetaRectangle tile_rect;
int monitor;
monitor = meta_window_get_current_tile_monitor_number (window);
meta_window_get_tile_area (window, screen->preview_tile_mode, &tile_rect);
meta_compositor_show_tile_preview (screen->display->compositor,
window, &tile_rect, monitor);
}
else
meta_compositor_hide_tile_preview (screen->display->compositor);
return FALSE;
}
#define TILE_PREVIEW_TIMEOUT_MS 200
void
meta_screen_update_tile_preview (MetaScreen *screen,
gboolean delay)
{
if (delay)
{
if (screen->tile_preview_timeout_id > 0)
return;
screen->tile_preview_timeout_id =
g_timeout_add (TILE_PREVIEW_TIMEOUT_MS,
meta_screen_update_tile_preview_timeout,
screen);
g_source_set_name_by_id (screen->tile_preview_timeout_id,
"[mutter] meta_screen_update_tile_preview_timeout");
}
else
{
if (screen->tile_preview_timeout_id > 0)
g_source_remove (screen->tile_preview_timeout_id);
meta_screen_update_tile_preview_timeout ((gpointer)screen);
}
}
void
meta_screen_hide_tile_preview (MetaScreen *screen)
{
if (screen->tile_preview_timeout_id > 0)
g_source_remove (screen->tile_preview_timeout_id);
screen->tile_preview_timeout_id = 0;
screen->preview_tile_mode = META_TILE_NONE;
meta_compositor_hide_tile_preview (screen->display->compositor);
}
MetaWindow*
meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one)
@ -1248,74 +1102,6 @@ meta_screen_update_workspace_names (MetaScreen *screen)
g_strfreev (names);
}
static void
set_work_area_hint (MetaScreen *screen)
{
MetaX11Display *x11_display = screen->display->x11_display;
int num_workspaces;
GList *l;
unsigned long *data, *tmp;
MetaRectangle area;
num_workspaces = meta_screen_get_n_workspaces (screen);
data = g_new (unsigned long, num_workspaces * 4);
tmp = data;
for (l = screen->workspaces; l != NULL; l = l->next)
{
MetaWorkspace *workspace = l->data;
meta_workspace_get_work_area_all_monitors (workspace, &area);
tmp[0] = area.x;
tmp[1] = area.y;
tmp[2] = area.width;
tmp[3] = area.height;
tmp += 4;
}
meta_error_trap_push (x11_display);
XChangeProperty (x11_display->xdisplay,
x11_display->xroot,
x11_display->atom__NET_WORKAREA,
XA_CARDINAL, 32, PropModeReplace,
(guchar*) data, num_workspaces*4);
g_free (data);
meta_error_trap_pop (x11_display);
g_signal_emit (screen, screen_signals[WORKAREAS_CHANGED], 0);
}
static gboolean
set_work_area_later_func (MetaScreen *screen)
{
meta_topic (META_DEBUG_WORKAREA,
"Running work area hint computation function\n");
screen->work_area_later = 0;
set_work_area_hint (screen);
return FALSE;
}
void
meta_screen_queue_workarea_recalc (MetaScreen *screen)
{
/* Recompute work area later before redrawing */
if (screen->work_area_later == 0)
{
meta_topic (META_DEBUG_WORKAREA,
"Adding work area hint computation function\n");
screen->work_area_later =
meta_later_add (META_LATER_BEFORE_REDRAW,
(GSourceFunc) set_work_area_later_func,
screen,
NULL);
}
}
#ifdef WITH_VERBOSE_MODE
static const char *
meta_screen_corner_to_string (MetaScreenCorner corner)
@ -1615,8 +1401,6 @@ void
meta_screen_on_monitors_changed (MetaScreen *screen)
{
reload_logical_monitors (screen);
meta_screen_queue_check_fullscreen (screen);
}
void
@ -1714,154 +1498,6 @@ meta_screen_unshow_desktop (MetaScreen *screen)
meta_screen_update_showing_desktop_hint (screen);
}
/**
* meta_screen_get_startup_sequences: (skip)
* @screen:
*
* Return value: (transfer none): Currently active #SnStartupSequence items
*/
GSList *
meta_screen_get_startup_sequences (MetaScreen *screen)
{
return screen->startup_sequences;
}
/* Sets the initial_timestamp and initial_workspace properties
* of a window according to information given us by the
* startup-notification library.
*
* Returns TRUE if startup properties have been applied, and
* FALSE if they have not (for example, if they had already
* been applied.)
*/
gboolean
meta_screen_apply_startup_properties (MetaScreen *screen,
MetaWindow *window)
{
#ifdef HAVE_STARTUP_NOTIFICATION
const char *startup_id;
GSList *l;
SnStartupSequence *sequence;
/* Does the window have a startup ID stored? */
startup_id = meta_window_get_startup_id (window);
meta_topic (META_DEBUG_STARTUP,
"Applying startup props to %s id \"%s\"\n",
window->desc,
startup_id ? startup_id : "(none)");
sequence = NULL;
if (startup_id == NULL)
{
/* No startup ID stored for the window. Let's ask the
* startup-notification library whether there's anything
* stored for the resource name or resource class hints.
*/
for (l = screen->startup_sequences; l != NULL; l = l->next)
{
const char *wmclass;
SnStartupSequence *seq = l->data;
wmclass = sn_startup_sequence_get_wmclass (seq);
if (wmclass != NULL &&
((window->res_class &&
strcmp (wmclass, window->res_class) == 0) ||
(window->res_name &&
strcmp (wmclass, window->res_name) == 0)))
{
sequence = seq;
g_assert (window->startup_id == NULL);
window->startup_id = g_strdup (sn_startup_sequence_get_id (sequence));
startup_id = window->startup_id;
meta_topic (META_DEBUG_STARTUP,
"Ending legacy sequence %s due to window %s\n",
sn_startup_sequence_get_id (sequence),
window->desc);
sn_startup_sequence_complete (sequence);
break;
}
}
}
/* Still no startup ID? Bail. */
if (startup_id == NULL)
return FALSE;
/* We might get this far and not know the sequence ID (if the window
* already had a startup ID stored), so let's look for one if we don't
* already know it.
*/
if (sequence == NULL)
{
for (l = screen->startup_sequences; l != NULL; l = l->next)
{
SnStartupSequence *seq = l->data;
const char *id;
id = sn_startup_sequence_get_id (seq);
if (strcmp (id, startup_id) == 0)
{
sequence = seq;
break;
}
}
}
if (sequence != NULL)
{
gboolean changed_something = FALSE;
meta_topic (META_DEBUG_STARTUP,
"Found startup sequence for window %s ID \"%s\"\n",
window->desc, startup_id);
if (!window->initial_workspace_set)
{
int space = sn_startup_sequence_get_workspace (sequence);
if (space >= 0)
{
meta_topic (META_DEBUG_STARTUP,
"Setting initial window workspace to %d based on startup info\n",
space);
window->initial_workspace_set = TRUE;
window->initial_workspace = space;
changed_something = TRUE;
}
}
if (!window->initial_timestamp_set)
{
guint32 timestamp = sn_startup_sequence_get_timestamp (sequence);
meta_topic (META_DEBUG_STARTUP,
"Setting initial window timestamp to %u based on startup info\n",
timestamp);
window->initial_timestamp_set = TRUE;
window->initial_timestamp = timestamp;
changed_something = TRUE;
}
return changed_something;
}
else
{
meta_topic (META_DEBUG_STARTUP,
"Did not find startup sequence for window %s ID \"%s\"\n",
window->desc, startup_id);
}
#endif /* HAVE_STARTUP_NOTIFICATION */
return FALSE;
}
/**
* meta_screen_get_display:
* @screen: A #MetaScreen
@ -1959,123 +1595,6 @@ meta_screen_set_active_workspace_hint (MetaScreen *screen)
meta_error_trap_pop (x11_display);
}
static gboolean
check_fullscreen_func (gpointer data)
{
MetaScreen *screen = data;
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
GList *logical_monitors, *l;
MetaWindow *window;
GSList *fullscreen_monitors = NULL;
GSList *obscured_monitors = NULL;
gboolean in_fullscreen_changed = FALSE;
screen->check_fullscreen_later = 0;
logical_monitors =
meta_monitor_manager_get_logical_monitors (monitor_manager);
/* We consider a monitor in fullscreen if it contains a fullscreen window;
* however we make an exception for maximized windows above the fullscreen
* one, as in that case window+chrome fully obscure the fullscreen window.
*/
for (window = meta_stack_get_top (screen->display->stack);
window;
window = meta_stack_get_below (screen->display->stack, window, FALSE))
{
gboolean covers_monitors = FALSE;
if (window->screen != screen || window->hidden)
continue;
if (window->fullscreen)
{
covers_monitors = TRUE;
}
else if (window->override_redirect)
{
/* We want to handle the case where an application is creating an
* override-redirect window the size of the screen (monitor) and treat
* it similarly to a fullscreen window, though it doesn't have fullscreen
* window management behavior. (Being O-R, it's not managed at all.)
*/
if (meta_window_is_monitor_sized (window))
covers_monitors = TRUE;
}
else if (window->maximized_horizontally &&
window->maximized_vertically)
{
MetaLogicalMonitor *logical_monitor;
logical_monitor = meta_window_get_main_logical_monitor (window);
if (!g_slist_find (obscured_monitors, logical_monitor))
obscured_monitors = g_slist_prepend (obscured_monitors,
logical_monitor);
}
if (covers_monitors)
{
MetaRectangle window_rect;
meta_window_get_frame_rect (window, &window_rect);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
if (meta_rectangle_overlap (&window_rect,
&logical_monitor->rect) &&
!g_slist_find (fullscreen_monitors, logical_monitor) &&
!g_slist_find (obscured_monitors, logical_monitor))
fullscreen_monitors = g_slist_prepend (fullscreen_monitors,
logical_monitor);
}
}
}
g_slist_free (obscured_monitors);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
gboolean in_fullscreen;
in_fullscreen = g_slist_find (fullscreen_monitors,
logical_monitor) != NULL;
if (in_fullscreen != logical_monitor->in_fullscreen)
{
logical_monitor->in_fullscreen = in_fullscreen;
in_fullscreen_changed = TRUE;
}
}
g_slist_free (fullscreen_monitors);
if (in_fullscreen_changed)
{
/* DOCK window stacking depends on the monitor's fullscreen
status so we need to trigger a re-layering. */
MetaWindow *window = meta_stack_get_top (screen->display->stack);
if (window)
meta_stack_update_layer (screen->display->stack, window);
g_signal_emit (screen, screen_signals[IN_FULLSCREEN_CHANGED], 0, NULL);
}
return FALSE;
}
void
meta_screen_queue_check_fullscreen (MetaScreen *screen)
{
if (!screen->check_fullscreen_later)
screen->check_fullscreen_later = meta_later_add (META_LATER_CHECK_FULLSCREEN,
check_fullscreen_func,
screen, NULL);
}
/**
* meta_screen_get_monitor_in_fullscreen:
* @screen: a #MetaScreen

View File

@ -945,7 +945,7 @@ stack_do_resort (MetaStack *stack)
stack->sorted = g_list_sort (stack->sorted,
(GCompareFunc) compare_window_position);
meta_screen_queue_check_fullscreen (stack->display->screen);
meta_display_queue_check_fullscreen (stack->display);
stack->need_resort = FALSE;
}

View File

@ -900,10 +900,10 @@ meta_window_main_monitor_changed (MetaWindow *window,
META_WINDOW_GET_CLASS (window)->main_monitor_changed (window, old);
if (old)
g_signal_emit_by_name (window->screen, "window-left-monitor",
g_signal_emit_by_name (window->display, "window-left-monitor",
old->number, window);
if (window->monitor)
g_signal_emit_by_name (window->screen, "window-entered-monitor",
g_signal_emit_by_name (window->display, "window-entered-monitor",
window->monitor->number, window);
}
@ -1171,7 +1171,7 @@ _meta_window_shared_new (MetaDisplay *display,
/* Apply any window attributes such as initial workspace
* based on startup notification
*/
meta_screen_apply_startup_properties (window->screen, window);
meta_display_apply_startup_properties (window->display, window);
/* Try to get a "launch timestamp" for the window. If the window is
* a transient, we'd like to be able to get a last-usage timestamp
@ -1551,7 +1551,7 @@ meta_window_unmanage (MetaWindow *window,
META_WINDOW_GET_CLASS (window)->unmanage (window);
meta_prefs_remove_listener (prefs_changed_callback, window);
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
g_signal_emit (window, window_signals[UNMANAGED], 0);
@ -2533,7 +2533,7 @@ meta_window_show (MetaWindow *window)
}
if (did_show)
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
#ifdef HAVE_WAYLAND
if (did_show && window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
@ -2640,7 +2640,7 @@ meta_window_hide (MetaWindow *window)
}
if (did_hide)
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
}
static gboolean
@ -2792,7 +2792,7 @@ meta_window_maximize_internal (MetaWindow *window,
set_net_wm_state (window);
if (window->monitor->in_fullscreen)
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
g_object_freeze_notify (G_OBJECT (window));
g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_MAXIMIZED_HORIZONTALLY]);
@ -3121,7 +3121,7 @@ meta_window_tile (MetaWindow *window,
directions = META_MAXIMIZE_VERTICAL;
meta_window_maximize_internal (window, directions, NULL);
meta_screen_update_tile_preview (window->screen, FALSE);
meta_display_update_tile_preview (window->display, FALSE);
/* Setup the edge constraints */
update_edge_constraints (window);
@ -3348,7 +3348,7 @@ meta_window_unmaximize (MetaWindow *window,
meta_window_recalc_features (window);
set_net_wm_state (window);
if (!window->monitor->in_fullscreen)
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
}
g_object_freeze_notify (G_OBJECT (window));
@ -3421,7 +3421,7 @@ meta_window_make_fullscreen_internal (MetaWindow *window)
set_net_wm_state (window);
/* For the auto-minimize feature, if we fail to get focus */
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_FULLSCREEN]);
}
@ -3495,7 +3495,7 @@ meta_window_unmake_fullscreen (MetaWindow *window)
NorthWestGravity,
target_rect);
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_FULLSCREEN]);
}
@ -4165,7 +4165,7 @@ meta_window_move_to_monitor (MetaWindow *window,
window->preferred_output_winsys_id = window->monitor->winsys_id;
if (window->fullscreen || window->override_redirect)
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
}
static void
@ -5914,7 +5914,7 @@ update_move_maybe_tile (MetaWindow *window,
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaLogicalMonitor *logical_monitor;
MetaScreen *screen = window->screen;
MetaDisplay *display = window->display;
MetaRectangle work_area;
/* For side-by-side tiling we are interested in the inside vertical
@ -5944,18 +5944,18 @@ update_move_maybe_tile (MetaWindow *window,
*/
if (meta_window_can_tile_side_by_side (window) &&
x >= logical_monitor->rect.x && x < (work_area.x + shake_threshold))
screen->preview_tile_mode = META_TILE_LEFT;
display->preview_tile_mode = META_TILE_LEFT;
else if (meta_window_can_tile_side_by_side (window) &&
x >= work_area.x + work_area.width - shake_threshold &&
x < (logical_monitor->rect.x + logical_monitor->rect.width))
screen->preview_tile_mode = META_TILE_RIGHT;
display->preview_tile_mode = META_TILE_RIGHT;
else if (meta_window_can_tile_maximized (window) &&
y >= logical_monitor->rect.y && y <= work_area.y)
screen->preview_tile_mode = META_TILE_MAXIMIZED;
display->preview_tile_mode = META_TILE_MAXIMIZED;
else
screen->preview_tile_mode = META_TILE_NONE;
display->preview_tile_mode = META_TILE_NONE;
if (screen->preview_tile_mode != META_TILE_NONE)
if (display->preview_tile_mode != META_TILE_NONE)
window->tile_monitor_number = logical_monitor->number;
}
@ -5970,7 +5970,6 @@ update_move (MetaWindow *window,
MetaRectangle old;
int shake_threshold;
MetaDisplay *display = window->display;
MetaScreen *screen = window->screen;
display->grab_latest_motion_x = x;
display->grab_latest_motion_y = y;
@ -6008,7 +6007,7 @@ update_move (MetaWindow *window,
{
/* We don't want to tile while snapping. Also, clear any previous tile
request. */
screen->preview_tile_mode = META_TILE_NONE;
display->preview_tile_mode = META_TILE_NONE;
window->tile_monitor_number = -1;
}
else if (meta_prefs_get_edge_tiling () &&
@ -6124,8 +6123,8 @@ update_move (MetaWindow *window,
* trigger it unwittingly, e.g. when shaking loose the window or moving
* it to another monitor.
*/
meta_screen_update_tile_preview (screen,
screen->preview_tile_mode != META_TILE_NONE);
meta_display_update_tile_preview (window->display,
window->tile_mode != META_TILE_NONE);
meta_window_get_frame_rect (window, &old);
@ -6339,8 +6338,8 @@ end_grab_op (MetaWindow *window,
{
if (meta_grab_op_is_moving (window->display->grab_op))
{
if (window->screen->preview_tile_mode != META_TILE_NONE)
meta_window_tile (window, window->screen->preview_tile_mode);
if (window->display->preview_tile_mode != META_TILE_NONE)
meta_window_tile (window, window->display->preview_tile_mode);
else
update_move (window,
modifiers & CLUTTER_SHIFT_MASK,
@ -6355,7 +6354,7 @@ end_grab_op (MetaWindow *window,
maybe_maximize_tiled_window (window);
}
}
window->screen->preview_tile_mode = META_TILE_NONE;
window->display->preview_tile_mode = META_TILE_NONE;
meta_display_end_grab_op (window->display, clutter_event_get_time (event));
}

View File

@ -768,7 +768,7 @@ meta_workspace_invalidate_work_area (MetaWorkspace *workspace)
g_list_free (windows);
meta_screen_queue_workarea_recalc (workspace->screen);
meta_display_queue_workarea_recalc (workspace->screen->display);
}
static MetaStrut *

View File

@ -173,4 +173,6 @@ void meta_display_get_size (MetaDisplay *display,
void meta_display_set_cursor (MetaDisplay *display,
MetaCursor cursor);
GSList *meta_display_get_startup_sequences (MetaDisplay *display);
#endif

View File

@ -38,8 +38,6 @@ GType meta_screen_get_type (void);
MetaDisplay *meta_screen_get_display (MetaScreen *screen);
GSList *meta_screen_get_startup_sequences (MetaScreen *screen);
GList *meta_screen_get_workspaces (MetaScreen *screen);
int meta_screen_get_n_workspaces (MetaScreen *screen);

View File

@ -1043,7 +1043,7 @@ reload_net_startup_id (MetaWindow *window,
window->initial_timestamp_set = 0;
window->initial_workspace_set = 0;
if (meta_screen_apply_startup_properties (window->screen, window))
if (meta_display_apply_startup_properties (window->display, window))
{
if (window->initial_timestamp_set)

View File

@ -3341,7 +3341,7 @@ meta_window_x11_configure_notify (MetaWindow *window,
* on its geometry.
*/
if (window->override_redirect)
meta_screen_queue_check_fullscreen (window->screen);
meta_display_queue_check_fullscreen (window->display);
if (!event->override_redirect && !event->send_event)
meta_warning ("Unhandled change of windows override redirect status\n");