mirror of
https://github.com/brl/mutter.git
synced 2024-12-01 12:20:47 -05:00
window: Keep track of fullscreen monitors directly
Instead of keeping around array indexes, keep track of them by storing a pointer instead. This also changes from using an array (imitating the X11 behaviour) to more explicit storing. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
0a4fb008f3
commit
ecf796f82b
@ -384,31 +384,22 @@ setup_constraint_info (ConstraintInfo *info,
|
|||||||
logical_monitor->number,
|
logical_monitor->number,
|
||||||
&info->work_area_monitor);
|
&info->work_area_monitor);
|
||||||
|
|
||||||
if (!window->fullscreen || window->fullscreen_monitors[0] == -1)
|
if (!window->fullscreen || !meta_window_has_fullscreen_monitors (window))
|
||||||
{
|
{
|
||||||
info->entire_monitor = logical_monitor->rect;
|
info->entire_monitor = logical_monitor->rect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
info->entire_monitor = window->fullscreen_monitors.top->rect;
|
||||||
MetaMonitorManager *monitor_manager =
|
meta_rectangle_union (&info->entire_monitor,
|
||||||
meta_backend_get_monitor_manager (backend);
|
&window->fullscreen_monitors.bottom->rect,
|
||||||
MetaLogicalMonitor *logical_monitors;
|
&info->entire_monitor);
|
||||||
int i = 0;
|
meta_rectangle_union (&info->entire_monitor,
|
||||||
long monitor;
|
&window->fullscreen_monitors.left->rect,
|
||||||
|
&info->entire_monitor);
|
||||||
logical_monitors =
|
meta_rectangle_union (&info->entire_monitor,
|
||||||
meta_monitor_manager_get_logical_monitors (monitor_manager, NULL);
|
&window->fullscreen_monitors.right->rect,
|
||||||
|
&info->entire_monitor);
|
||||||
monitor = window->fullscreen_monitors[i];
|
|
||||||
info->entire_monitor = logical_monitors[monitor].rect;
|
|
||||||
for (i = 1; i <= 3; i++)
|
|
||||||
{
|
|
||||||
monitor = window->fullscreen_monitors[i];
|
|
||||||
meta_rectangle_union (&info->entire_monitor,
|
|
||||||
&logical_monitors[monitor].rect,
|
|
||||||
&info->entire_monitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_workspace = window->screen->active_workspace;
|
cur_workspace = window->screen->active_workspace;
|
||||||
|
@ -205,9 +205,10 @@ void meta_screen_create_guard_window (MetaScreen *screen);
|
|||||||
gboolean meta_screen_handle_xevent (MetaScreen *screen,
|
gboolean meta_screen_handle_xevent (MetaScreen *screen,
|
||||||
XEvent *xevent);
|
XEvent *xevent);
|
||||||
|
|
||||||
int meta_screen_xinerama_index_to_monitor_index (MetaScreen *screen,
|
MetaLogicalMonitor * meta_screen_xinerama_index_to_logical_monitor (MetaScreen *screen,
|
||||||
int index);
|
int index);
|
||||||
int meta_screen_monitor_index_to_xinerama_index (MetaScreen *screen,
|
|
||||||
int index);
|
int meta_screen_logical_monitor_to_xinerama_index (MetaScreen *screen,
|
||||||
|
MetaLogicalMonitor *logical_monitor);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -384,31 +384,19 @@ meta_screen_ensure_xinerama_indices (MetaScreen *screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
meta_screen_monitor_index_to_xinerama_index (MetaScreen *screen,
|
meta_screen_logical_monitor_to_xinerama_index (MetaScreen *screen,
|
||||||
int index)
|
MetaLogicalMonitor *logical_monitor)
|
||||||
{
|
{
|
||||||
#ifndef G_DISABLE_CHECKS
|
g_return_val_if_fail (logical_monitor, -1);
|
||||||
MetaBackend *backend = meta_get_backend ();
|
|
||||||
MetaMonitorManager *monitor_manager =
|
|
||||||
meta_backend_get_monitor_manager (backend);
|
|
||||||
MetaLogicalMonitor *logical_monitors;
|
|
||||||
unsigned int n_logical_monitors;
|
|
||||||
|
|
||||||
logical_monitors =
|
|
||||||
meta_monitor_manager_get_logical_monitors (monitor_manager,
|
|
||||||
&n_logical_monitors);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_val_if_fail (index >= 0 && index < (int) n_logical_monitors, -1);
|
|
||||||
|
|
||||||
meta_screen_ensure_xinerama_indices (screen);
|
meta_screen_ensure_xinerama_indices (screen);
|
||||||
|
|
||||||
return logical_monitors[index].xinerama_index;
|
return logical_monitor->xinerama_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
MetaLogicalMonitor *
|
||||||
meta_screen_xinerama_index_to_monitor_index (MetaScreen *screen,
|
meta_screen_xinerama_index_to_logical_monitor (MetaScreen *screen,
|
||||||
int index)
|
int xinerama_index)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaMonitorManager *monitor_manager =
|
MetaMonitorManager *monitor_manager =
|
||||||
@ -424,10 +412,10 @@ meta_screen_xinerama_index_to_monitor_index (MetaScreen *screen,
|
|||||||
&n_logical_monitors);
|
&n_logical_monitors);
|
||||||
|
|
||||||
for (i = 0; i < n_logical_monitors; i++)
|
for (i = 0; i < n_logical_monitors; i++)
|
||||||
if (logical_monitors[i].xinerama_index == index)
|
if (logical_monitors[i].xinerama_index == xinerama_index)
|
||||||
return i;
|
return &logical_monitors[i];
|
||||||
|
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -221,7 +221,12 @@ struct _MetaWindow
|
|||||||
* been overridden (via a client message), the window will cover the union of
|
* been overridden (via a client message), the window will cover the union of
|
||||||
* these monitors. If not, this is the single monitor which the window's
|
* these monitors. If not, this is the single monitor which the window's
|
||||||
* origin is on. */
|
* origin is on. */
|
||||||
gint fullscreen_monitors[4];
|
struct {
|
||||||
|
MetaLogicalMonitor *top;
|
||||||
|
MetaLogicalMonitor *bottom;
|
||||||
|
MetaLogicalMonitor *left;
|
||||||
|
MetaLogicalMonitor *right;
|
||||||
|
} fullscreen_monitors;
|
||||||
|
|
||||||
/* Whether we're trying to constrain the window to be fully onscreen */
|
/* Whether we're trying to constrain the window to be fully onscreen */
|
||||||
guint require_fully_onscreen : 1;
|
guint require_fully_onscreen : 1;
|
||||||
@ -574,11 +579,13 @@ void meta_window_maximize_internal (MetaWindow *window,
|
|||||||
MetaRectangle *saved_rect);
|
MetaRectangle *saved_rect);
|
||||||
|
|
||||||
void meta_window_make_fullscreen_internal (MetaWindow *window);
|
void meta_window_make_fullscreen_internal (MetaWindow *window);
|
||||||
void meta_window_update_fullscreen_monitors (MetaWindow *window,
|
void meta_window_update_fullscreen_monitors (MetaWindow *window,
|
||||||
unsigned long top,
|
MetaLogicalMonitor *top,
|
||||||
unsigned long bottom,
|
MetaLogicalMonitor *bottom,
|
||||||
unsigned long left,
|
MetaLogicalMonitor *left,
|
||||||
unsigned long right);
|
MetaLogicalMonitor *right);
|
||||||
|
|
||||||
|
gboolean meta_window_has_fullscreen_monitors (MetaWindow *window);
|
||||||
|
|
||||||
void meta_window_resize_frame_with_gravity (MetaWindow *window,
|
void meta_window_resize_frame_with_gravity (MetaWindow *window,
|
||||||
gboolean user_op,
|
gboolean user_op,
|
||||||
|
@ -927,7 +927,6 @@ _meta_window_shared_new (MetaDisplay *display,
|
|||||||
window->maximize_vertically_after_placement = FALSE;
|
window->maximize_vertically_after_placement = FALSE;
|
||||||
window->minimize_after_placement = FALSE;
|
window->minimize_after_placement = FALSE;
|
||||||
window->fullscreen = FALSE;
|
window->fullscreen = FALSE;
|
||||||
window->fullscreen_monitors[0] = -1;
|
|
||||||
window->require_fully_onscreen = TRUE;
|
window->require_fully_onscreen = TRUE;
|
||||||
window->require_on_single_monitor = TRUE;
|
window->require_on_single_monitor = TRUE;
|
||||||
window->require_titlebar_visible = TRUE;
|
window->require_titlebar_visible = TRUE;
|
||||||
@ -3279,32 +3278,32 @@ meta_window_unmake_fullscreen (MetaWindow *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
meta_window_update_fullscreen_monitors (MetaWindow *window,
|
meta_window_clear_fullscreen_monitors (MetaWindow *window)
|
||||||
unsigned long top,
|
|
||||||
unsigned long bottom,
|
|
||||||
unsigned long left,
|
|
||||||
unsigned long right)
|
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
window->fullscreen_monitors.top = NULL;
|
||||||
MetaMonitorManager *monitor_manager =
|
window->fullscreen_monitors.bottom = NULL;
|
||||||
meta_backend_get_monitor_manager (backend);
|
window->fullscreen_monitors.left = NULL;
|
||||||
int n_logical_monitors =
|
window->fullscreen_monitors.right = NULL;
|
||||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
}
|
||||||
|
|
||||||
if ((int) top < n_logical_monitors &&
|
void
|
||||||
(int) bottom < n_logical_monitors &&
|
meta_window_update_fullscreen_monitors (MetaWindow *window,
|
||||||
(int) left < n_logical_monitors &&
|
MetaLogicalMonitor *top,
|
||||||
(int) right < n_logical_monitors)
|
MetaLogicalMonitor *bottom,
|
||||||
|
MetaLogicalMonitor *left,
|
||||||
|
MetaLogicalMonitor *right)
|
||||||
|
{
|
||||||
|
if (top && bottom && left && right)
|
||||||
{
|
{
|
||||||
window->fullscreen_monitors[0] = top;
|
window->fullscreen_monitors.top = top;
|
||||||
window->fullscreen_monitors[1] = bottom;
|
window->fullscreen_monitors.bottom = bottom;
|
||||||
window->fullscreen_monitors[2] = left;
|
window->fullscreen_monitors.left = left;
|
||||||
window->fullscreen_monitors[3] = right;
|
window->fullscreen_monitors.right = right;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window->fullscreen_monitors[0] = -1;
|
meta_window_clear_fullscreen_monitors (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->fullscreen)
|
if (window->fullscreen)
|
||||||
@ -3313,6 +3312,12 @@ meta_window_update_fullscreen_monitors (MetaWindow *window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_window_has_fullscreen_monitors (MetaWindow *window)
|
||||||
|
{
|
||||||
|
return window->fullscreen_monitors.top != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_shade (MetaWindow *window,
|
meta_window_shade (MetaWindow *window,
|
||||||
guint32 timestamp)
|
guint32 timestamp)
|
||||||
@ -3567,8 +3572,8 @@ meta_window_update_for_monitors_changed (MetaWindow *window)
|
|||||||
meta_backend_get_monitor_manager (backend);
|
meta_backend_get_monitor_manager (backend);
|
||||||
const MetaLogicalMonitor *old, *new;
|
const MetaLogicalMonitor *old, *new;
|
||||||
|
|
||||||
if (window->fullscreen_monitors[0] != -1)
|
if (meta_window_has_fullscreen_monitors (window))
|
||||||
window->fullscreen_monitors[0] = -1;
|
meta_window_clear_fullscreen_monitors (window);
|
||||||
|
|
||||||
if (window->override_redirect || window->type == META_WINDOW_DESKTOP)
|
if (window->override_redirect || window->type == META_WINDOW_DESKTOP)
|
||||||
{
|
{
|
||||||
|
@ -1612,16 +1612,20 @@ meta_window_x11_set_net_wm_state (MetaWindow *window)
|
|||||||
|
|
||||||
if (window->fullscreen)
|
if (window->fullscreen)
|
||||||
{
|
{
|
||||||
if (window->fullscreen_monitors[0] >= 0)
|
if (meta_window_has_fullscreen_monitors (window))
|
||||||
{
|
{
|
||||||
data[0] = meta_screen_monitor_index_to_xinerama_index (window->screen,
|
data[0] =
|
||||||
window->fullscreen_monitors[0]);
|
meta_screen_logical_monitor_to_xinerama_index (window->screen,
|
||||||
data[1] = meta_screen_monitor_index_to_xinerama_index (window->screen,
|
window->fullscreen_monitors.top);
|
||||||
window->fullscreen_monitors[1]);
|
data[1] =
|
||||||
data[2] = meta_screen_monitor_index_to_xinerama_index (window->screen,
|
meta_screen_logical_monitor_to_xinerama_index (window->screen,
|
||||||
window->fullscreen_monitors[2]);
|
window->fullscreen_monitors.bottom);
|
||||||
data[3] = meta_screen_monitor_index_to_xinerama_index (window->screen,
|
data[2] =
|
||||||
window->fullscreen_monitors[3]);
|
meta_screen_logical_monitor_to_xinerama_index (window->screen,
|
||||||
|
window->fullscreen_monitors.left);
|
||||||
|
data[3] =
|
||||||
|
meta_screen_logical_monitor_to_xinerama_index (window->screen,
|
||||||
|
window->fullscreen_monitors.right);
|
||||||
|
|
||||||
meta_verbose ("Setting _NET_WM_FULLSCREEN_MONITORS\n");
|
meta_verbose ("Setting _NET_WM_FULLSCREEN_MONITORS\n");
|
||||||
meta_error_trap_push (window->display);
|
meta_error_trap_push (window->display);
|
||||||
@ -2668,19 +2672,23 @@ meta_window_x11_client_message (MetaWindow *window,
|
|||||||
else if (event->xclient.message_type ==
|
else if (event->xclient.message_type ==
|
||||||
display->atom__NET_WM_FULLSCREEN_MONITORS)
|
display->atom__NET_WM_FULLSCREEN_MONITORS)
|
||||||
{
|
{
|
||||||
gulong top, bottom, left, right;
|
MetaLogicalMonitor *top, *bottom, *left, *right;
|
||||||
|
|
||||||
meta_verbose ("_NET_WM_FULLSCREEN_MONITORS request for window '%s'\n",
|
meta_verbose ("_NET_WM_FULLSCREEN_MONITORS request for window '%s'\n",
|
||||||
window->desc);
|
window->desc);
|
||||||
|
|
||||||
top = meta_screen_xinerama_index_to_monitor_index (window->screen,
|
top =
|
||||||
event->xclient.data.l[0]);
|
meta_screen_xinerama_index_to_logical_monitor (window->screen,
|
||||||
bottom = meta_screen_xinerama_index_to_monitor_index (window->screen,
|
event->xclient.data.l[0]);
|
||||||
event->xclient.data.l[1]);
|
bottom =
|
||||||
left = meta_screen_xinerama_index_to_monitor_index (window->screen,
|
meta_screen_xinerama_index_to_logical_monitor (window->screen,
|
||||||
event->xclient.data.l[2]);
|
event->xclient.data.l[1]);
|
||||||
right = meta_screen_xinerama_index_to_monitor_index (window->screen,
|
left =
|
||||||
event->xclient.data.l[3]);
|
meta_screen_xinerama_index_to_logical_monitor (window->screen,
|
||||||
|
event->xclient.data.l[2]);
|
||||||
|
right =
|
||||||
|
meta_screen_xinerama_index_to_logical_monitor (window->screen,
|
||||||
|
event->xclient.data.l[3]);
|
||||||
/* source_indication = event->xclient.data.l[4]; */
|
/* source_indication = event->xclient.data.l[4]; */
|
||||||
|
|
||||||
meta_window_update_fullscreen_monitors (window, top, bottom, left, right);
|
meta_window_update_fullscreen_monitors (window, top, bottom, left, right);
|
||||||
|
Loading…
Reference in New Issue
Block a user