Move monitor management API to MetaDisplay
This includes changing various users to use MetaDisplay directly, who used MetaScreen only for this before. https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
parent
68f261e8e2
commit
e1c67a1824
@ -279,34 +279,34 @@ meta_logical_monitor_class_init (MetaLogicalMonitorClass *klass)
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitor *neighbor,
|
||||
MetaScreenDirection neighbor_direction)
|
||||
meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitor *neighbor,
|
||||
MetaDisplayDirection neighbor_direction)
|
||||
{
|
||||
switch (neighbor_direction)
|
||||
{
|
||||
case META_SCREEN_RIGHT:
|
||||
case META_DISPLAY_RIGHT:
|
||||
if (neighbor->rect.x == (logical_monitor->rect.x +
|
||||
logical_monitor->rect.width) &&
|
||||
meta_rectangle_vert_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
case META_SCREEN_LEFT:
|
||||
case META_DISPLAY_LEFT:
|
||||
if (logical_monitor->rect.x == (neighbor->rect.x +
|
||||
neighbor->rect.width) &&
|
||||
meta_rectangle_vert_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
case META_SCREEN_UP:
|
||||
case META_DISPLAY_UP:
|
||||
if (logical_monitor->rect.y == (neighbor->rect.y +
|
||||
neighbor->rect.height) &&
|
||||
meta_rectangle_horiz_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
case META_SCREEN_DOWN:
|
||||
case META_DISPLAY_DOWN:
|
||||
if (neighbor->rect.y == (logical_monitor->rect.y +
|
||||
logical_monitor->rect.height) &&
|
||||
meta_rectangle_horiz_overlap (&neighbor->rect,
|
||||
|
@ -90,9 +90,9 @@ MetaRectangle meta_logical_monitor_get_layout (MetaLogicalMonitor *logical_monit
|
||||
|
||||
GList * meta_logical_monitor_get_monitors (MetaLogicalMonitor *logical_monitor);
|
||||
|
||||
gboolean meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitor *neighbor,
|
||||
MetaScreenDirection neighbor_dir);
|
||||
gboolean meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitor *neighbor,
|
||||
MetaDisplayDirection neighbor_dir);
|
||||
|
||||
void meta_logical_monitor_foreach_crtc (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitorCrtcFunc func,
|
||||
|
@ -279,9 +279,9 @@ MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_at (MetaMonitorMana
|
||||
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager,
|
||||
MetaRectangle *rect);
|
||||
|
||||
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitor *logical_monitor,
|
||||
MetaScreenDirection direction);
|
||||
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitor *logical_monitor,
|
||||
MetaDisplayDirection direction);
|
||||
|
||||
MetaMonitor * meta_monitor_manager_get_primary_monitor (MetaMonitorManager *manager);
|
||||
|
||||
|
@ -2492,9 +2492,9 @@ meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager,
|
||||
}
|
||||
|
||||
MetaLogicalMonitor *
|
||||
meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitor *logical_monitor,
|
||||
MetaScreenDirection direction)
|
||||
meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitor *logical_monitor,
|
||||
MetaDisplayDirection direction)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
|
@ -212,7 +212,7 @@ relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
||||
MetaLogicalMonitor *cur = current;
|
||||
float x = cur_x, y = cur_y;
|
||||
float dx = *dx_inout, dy = *dy_inout;
|
||||
MetaScreenDirection direction = -1;
|
||||
MetaDisplayDirection direction = -1;
|
||||
|
||||
while (cur)
|
||||
{
|
||||
@ -240,18 +240,18 @@ relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
||||
{ cur->rect.x + cur->rect.width, cur->rect.y + cur->rect.height }
|
||||
};
|
||||
|
||||
if (direction != META_SCREEN_RIGHT &&
|
||||
if (direction != META_DISPLAY_RIGHT &&
|
||||
meta_line2_intersects_with (&motion, &left, &intersection))
|
||||
direction = META_SCREEN_LEFT;
|
||||
else if (direction != META_SCREEN_LEFT &&
|
||||
direction = META_DISPLAY_LEFT;
|
||||
else if (direction != META_DISPLAY_LEFT &&
|
||||
meta_line2_intersects_with (&motion, &right, &intersection))
|
||||
direction = META_SCREEN_RIGHT;
|
||||
else if (direction != META_SCREEN_DOWN &&
|
||||
direction = META_DISPLAY_RIGHT;
|
||||
else if (direction != META_DISPLAY_DOWN &&
|
||||
meta_line2_intersects_with (&motion, &top, &intersection))
|
||||
direction = META_SCREEN_UP;
|
||||
else if (direction != META_SCREEN_UP &&
|
||||
direction = META_DISPLAY_UP;
|
||||
else if (direction != META_DISPLAY_UP &&
|
||||
meta_line2_intersects_with (&motion, &bottom, &intersection))
|
||||
direction = META_SCREEN_DOWN;
|
||||
direction = META_DISPLAY_DOWN;
|
||||
else
|
||||
{
|
||||
/* We reached the dest logical monitor */
|
||||
|
@ -82,6 +82,7 @@
|
||||
#include "meta-background-actor-private.h"
|
||||
#include "meta-background-private.h"
|
||||
#include "meta-cullable.h"
|
||||
#include "meta/display.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -213,7 +214,9 @@ get_preferred_size (MetaBackgroundActor *self,
|
||||
MetaBackgroundActorPrivate *priv = META_BACKGROUND_ACTOR (self)->priv;
|
||||
MetaRectangle monitor_geometry;
|
||||
|
||||
meta_screen_get_monitor_geometry (priv->screen, priv->monitor, &monitor_geometry);
|
||||
meta_display_get_monitor_geometry (meta_screen_get_display (priv->screen),
|
||||
priv->monitor,
|
||||
&monitor_geometry);
|
||||
|
||||
if (width != NULL)
|
||||
*width = monitor_geometry.width;
|
||||
@ -381,7 +384,8 @@ setup_pipeline (MetaBackgroundActor *self,
|
||||
MetaRectangle monitor_geometry;
|
||||
float gradient_height_perc;
|
||||
|
||||
meta_screen_get_monitor_geometry (priv->screen, priv->monitor, &monitor_geometry);
|
||||
meta_display_get_monitor_geometry (meta_screen_get_display (priv->screen),
|
||||
priv->monitor, &monitor_geometry);
|
||||
gradient_height_perc = MAX (0.0001, priv->gradient_height / (float)monitor_geometry.height);
|
||||
cogl_pipeline_set_uniform_1f (priv->pipeline,
|
||||
cogl_pipeline_get_uniform_location (priv->pipeline,
|
||||
@ -923,12 +927,13 @@ meta_background_actor_set_monitor (MetaBackgroundActor *self,
|
||||
MetaBackgroundActorPrivate *priv = self->priv;
|
||||
MetaRectangle old_monitor_geometry;
|
||||
MetaRectangle new_monitor_geometry;
|
||||
MetaDisplay *display = meta_screen_get_display (priv->screen);
|
||||
|
||||
if(priv->monitor == monitor)
|
||||
return;
|
||||
|
||||
meta_screen_get_monitor_geometry (priv->screen, priv->monitor, &old_monitor_geometry);
|
||||
meta_screen_get_monitor_geometry (priv->screen, monitor, &new_monitor_geometry);
|
||||
meta_display_get_monitor_geometry (display, priv->monitor, &old_monitor_geometry);
|
||||
meta_display_get_monitor_geometry (display, monitor, &new_monitor_geometry);
|
||||
if(old_monitor_geometry.height != new_monitor_geometry.height)
|
||||
invalidate_pipeline (self, CHANGED_GRADIENT_PARAMETERS);
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
// XXX: Remove this once transition to MetaDisplay has been completed
|
||||
#include "core/display-private.h"
|
||||
#include "core/screen-private.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -49,7 +48,7 @@ struct _MetaBackgroundMonitor
|
||||
|
||||
struct _MetaBackgroundPrivate
|
||||
{
|
||||
MetaScreen *screen;
|
||||
MetaDisplay *display;
|
||||
MetaBackgroundMonitor *monitors;
|
||||
int n_monitors;
|
||||
|
||||
@ -73,7 +72,7 @@ struct _MetaBackgroundPrivate
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_META_SCREEN = 1,
|
||||
PROP_META_DISPLAY = 1,
|
||||
PROP_MONITOR,
|
||||
};
|
||||
|
||||
@ -142,11 +141,11 @@ invalidate_monitor_backgrounds (MetaBackground *self)
|
||||
priv->monitors = NULL;
|
||||
priv->n_monitors = 0;
|
||||
|
||||
if (priv->screen)
|
||||
if (priv->display)
|
||||
{
|
||||
int i;
|
||||
|
||||
priv->n_monitors = meta_screen_get_n_monitors (priv->screen);
|
||||
priv->n_monitors = meta_display_get_n_monitors (priv->display);
|
||||
priv->monitors = g_new0 (MetaBackgroundMonitor, priv->n_monitors);
|
||||
|
||||
for (i = 0; i < priv->n_monitors; i++)
|
||||
@ -162,23 +161,23 @@ on_monitors_changed (MetaDisplay *display,
|
||||
}
|
||||
|
||||
static void
|
||||
set_screen (MetaBackground *self,
|
||||
MetaScreen *screen)
|
||||
set_display (MetaBackground *self,
|
||||
MetaDisplay *display)
|
||||
{
|
||||
MetaBackgroundPrivate *priv = self->priv;
|
||||
|
||||
if (priv->screen != NULL && priv->screen->display != NULL)
|
||||
if (priv->display)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->screen->display,
|
||||
g_signal_handlers_disconnect_by_func (priv->display,
|
||||
(gpointer)on_monitors_changed,
|
||||
self);
|
||||
}
|
||||
|
||||
g_set_object (&priv->screen, screen);
|
||||
g_set_object (&priv->display, display);
|
||||
|
||||
if (priv->screen != NULL && priv->screen->display != NULL)
|
||||
if (priv->display)
|
||||
{
|
||||
g_signal_connect (priv->screen->display, "monitors-changed",
|
||||
g_signal_connect (priv->display, "monitors-changed",
|
||||
G_CALLBACK (on_monitors_changed), self);
|
||||
}
|
||||
|
||||
@ -193,8 +192,8 @@ meta_background_set_property (GObject *object,
|
||||
{
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_META_SCREEN:
|
||||
set_screen (META_BACKGROUND (object), g_value_get_object (value));
|
||||
case PROP_META_DISPLAY:
|
||||
set_display (META_BACKGROUND (object), g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -212,8 +211,8 @@ meta_background_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_META_SCREEN:
|
||||
g_value_set_object (value, priv->screen);
|
||||
case PROP_META_DISPLAY:
|
||||
g_value_set_object (value, priv->display);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -315,7 +314,7 @@ meta_background_dispose (GObject *object)
|
||||
set_file (self, &priv->file1, &priv->background_image1, NULL);
|
||||
set_file (self, &priv->file2, &priv->background_image2, NULL);
|
||||
|
||||
set_screen (self, NULL);
|
||||
set_display (self, NULL);
|
||||
|
||||
G_OBJECT_CLASS (meta_background_parent_class)->dispose (object);
|
||||
}
|
||||
@ -336,7 +335,7 @@ meta_background_constructed (GObject *object)
|
||||
|
||||
G_OBJECT_CLASS (meta_background_parent_class)->constructed (object);
|
||||
|
||||
g_signal_connect_object (meta_screen_get_display (priv->screen), "gl-video-memory-purged",
|
||||
g_signal_connect_object (priv->display, "gl-video-memory-purged",
|
||||
G_CALLBACK (mark_changed), object, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
@ -362,14 +361,14 @@ meta_background_class_init (MetaBackgroundClass *klass)
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
param_spec = g_param_spec_object ("meta-screen",
|
||||
"MetaScreen",
|
||||
"MetaScreen",
|
||||
META_TYPE_SCREEN,
|
||||
param_spec = g_param_spec_object ("meta-display",
|
||||
"MetaDisplay",
|
||||
"MetaDisplay",
|
||||
META_TYPE_DISPLAY,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_META_SCREEN,
|
||||
PROP_META_DISPLAY,
|
||||
param_spec);
|
||||
|
||||
}
|
||||
@ -399,7 +398,6 @@ get_texture_area (MetaBackground *self,
|
||||
CoglTexture *texture,
|
||||
cairo_rectangle_int_t *texture_area)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaBackgroundPrivate *priv = self->priv;
|
||||
cairo_rectangle_int_t image_area;
|
||||
int screen_width, screen_height;
|
||||
@ -408,7 +406,6 @@ get_texture_area (MetaBackground *self,
|
||||
|
||||
texture_width = cogl_texture_get_width (texture);
|
||||
texture_height = cogl_texture_get_height (texture);
|
||||
display = meta_screen_get_display (priv->screen);
|
||||
|
||||
switch (priv->style)
|
||||
{
|
||||
@ -420,7 +417,7 @@ get_texture_area (MetaBackground *self,
|
||||
set_texture_area_from_monitor_area (monitor_rect, texture_area);
|
||||
break;
|
||||
case G_DESKTOP_BACKGROUND_STYLE_WALLPAPER:
|
||||
meta_display_get_size (display, &screen_width, &screen_height);
|
||||
meta_display_get_size (priv->display, &screen_width, &screen_height);
|
||||
|
||||
/* Start off by centering a tile in the middle of the
|
||||
* total screen area.
|
||||
@ -489,7 +486,7 @@ get_texture_area (MetaBackground *self,
|
||||
/* paint region is the union of all monitors, with the origin
|
||||
* of the region set to align with monitor associated with the background.
|
||||
*/
|
||||
meta_display_get_size (display, &screen_width, &screen_height);
|
||||
meta_display_get_size (priv->display, &screen_width, &screen_height);
|
||||
|
||||
/* unclipped texture area is whole screen */
|
||||
image_area.width = screen_width;
|
||||
@ -763,7 +760,7 @@ meta_background_get_texture (MetaBackground *self,
|
||||
|
||||
monitor = &priv->monitors[monitor_index];
|
||||
|
||||
meta_screen_get_monitor_geometry (priv->screen, monitor_index, &geometry);
|
||||
meta_display_get_monitor_geometry (priv->display, monitor_index, &geometry);
|
||||
monitor_area.x = geometry.x;
|
||||
monitor_area.y = geometry.y;
|
||||
monitor_area.width = geometry.width;
|
||||
@ -892,10 +889,10 @@ meta_background_get_texture (MetaBackground *self,
|
||||
}
|
||||
|
||||
MetaBackground *
|
||||
meta_background_new (MetaScreen *screen)
|
||||
meta_background_new (MetaDisplay *display)
|
||||
{
|
||||
return g_object_new (META_TYPE_BACKGROUND,
|
||||
"meta-screen", screen,
|
||||
"meta-display", display,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ on_monitors_changed (MetaDisplay *display,
|
||||
|
||||
clutter_actor_destroy_all_children (self->priv->background_group);
|
||||
|
||||
n = meta_screen_get_n_monitors (screen);
|
||||
n = meta_display_get_n_monitors (meta_screen_get_display (screen));
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
MetaRectangle rect;
|
||||
@ -340,7 +340,8 @@ on_monitors_changed (MetaDisplay *display,
|
||||
MetaBackground *background;
|
||||
ClutterColor color;
|
||||
|
||||
meta_screen_get_monitor_geometry (screen, i, &rect);
|
||||
meta_display_get_monitor_geometry (meta_screen_get_display (screen),
|
||||
i, &rect);
|
||||
|
||||
background_actor = meta_background_actor_new (screen, i);
|
||||
|
||||
@ -357,7 +358,7 @@ on_monitors_changed (MetaDisplay *display,
|
||||
g_rand_int_range (rand, 0, 255),
|
||||
255);
|
||||
|
||||
background = meta_background_new (screen);
|
||||
background = meta_background_new (display);
|
||||
meta_background_set_color (background, &color);
|
||||
meta_background_actor_set_background (META_BACKGROUND_ACTOR (background_actor), background);
|
||||
g_object_unref (background);
|
||||
|
@ -2908,8 +2908,8 @@ lookup_tablet_monitor (MetaDisplay *display,
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
monitor_idx = meta_screen_get_monitor_index_for_rect (display->screen,
|
||||
&monitor->rect);
|
||||
monitor_idx = meta_display_get_monitor_index_for_rect (display,
|
||||
&monitor->rect);
|
||||
}
|
||||
|
||||
return monitor_idx;
|
||||
@ -3445,3 +3445,180 @@ meta_display_queue_check_fullscreen (MetaDisplay *display)
|
||||
check_fullscreen_func,
|
||||
display, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
meta_display_get_monitor_index_for_rect (MetaDisplay *display,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, rect);
|
||||
if (!logical_monitor)
|
||||
return -1;
|
||||
|
||||
return logical_monitor->number;
|
||||
}
|
||||
|
||||
int
|
||||
meta_display_get_monitor_neighbor_index (MetaDisplay *display,
|
||||
int which_monitor,
|
||||
MetaDisplayDirection direction)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
MetaLogicalMonitor *neighbor;
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
|
||||
which_monitor);
|
||||
neighbor = meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
||||
logical_monitor,
|
||||
direction);
|
||||
return neighbor ? neighbor->number : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_get_current_monitor:
|
||||
* @display: a #MetaDisplay
|
||||
*
|
||||
* Gets the index of the monitor that currently has the mouse pointer.
|
||||
*
|
||||
* Return value: a monitor index
|
||||
*/
|
||||
int
|
||||
meta_display_get_current_monitor (MetaDisplay *display)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
logical_monitor = meta_backend_get_current_logical_monitor (backend);
|
||||
|
||||
/* Pretend its the first when there is no actual current monitor. */
|
||||
if (!logical_monitor)
|
||||
return 0;
|
||||
|
||||
return logical_monitor->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_get_n_monitors:
|
||||
* @display: a #MetaDisplay
|
||||
*
|
||||
* Gets the number of monitors that are joined together to form @display.
|
||||
*
|
||||
* Return value: the number of monitors
|
||||
*/
|
||||
int
|
||||
meta_display_get_n_monitors (MetaDisplay *display)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
|
||||
g_return_val_if_fail (META_IS_DISPLAY (display), 0);
|
||||
|
||||
return meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_get_primary_monitor:
|
||||
* @display: a #MetaDisplay
|
||||
*
|
||||
* Gets the index of the primary monitor on this @display.
|
||||
*
|
||||
* Return value: a monitor index
|
||||
*/
|
||||
int
|
||||
meta_display_get_primary_monitor (MetaDisplay *display)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
g_return_val_if_fail (META_IS_DISPLAY (display), 0);
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
||||
if (logical_monitor)
|
||||
return logical_monitor->number;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_get_monitor_geometry:
|
||||
* @display: a #MetaDisplay
|
||||
* @monitor: the monitor number
|
||||
* @geometry: (out): location to store the monitor geometry
|
||||
*
|
||||
* Stores the location and size of the indicated monitor in @geometry.
|
||||
*/
|
||||
void
|
||||
meta_display_get_monitor_geometry (MetaDisplay *display,
|
||||
int monitor,
|
||||
MetaRectangle *geometry)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
int n_logical_monitors =
|
||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
#endif
|
||||
|
||||
g_return_if_fail (META_IS_DISPLAY (display));
|
||||
g_return_if_fail (monitor >= 0 && monitor < n_logical_monitors);
|
||||
g_return_if_fail (geometry != NULL);
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
|
||||
monitor);
|
||||
*geometry = logical_monitor->rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_display_get_monitor_in_fullscreen:
|
||||
* @display: a #MetaDisplay
|
||||
* @monitor: the monitor number
|
||||
*
|
||||
* Determines whether there is a fullscreen window obscuring the specified
|
||||
* monitor. If there is a fullscreen window, the desktop environment will
|
||||
* typically hide any controls that might obscure the fullscreen window.
|
||||
*
|
||||
* You can get notification when this changes by connecting to
|
||||
* MetaDisplay::in-fullscreen-changed.
|
||||
*
|
||||
* Returns: %TRUE if there is a fullscreen window covering the specified monitor.
|
||||
*/
|
||||
gboolean
|
||||
meta_display_get_monitor_in_fullscreen (MetaDisplay *display,
|
||||
int monitor)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
int n_logical_monitors =
|
||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (META_IS_DISPLAY (display), FALSE);
|
||||
g_return_val_if_fail (monitor >= 0 &&
|
||||
monitor < n_logical_monitors, FALSE);
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
|
||||
monitor);
|
||||
|
||||
/* We use -1 as a flag to mean "not known yet" for notification
|
||||
purposes */ return logical_monitor->in_fullscreen == TRUE;
|
||||
}
|
||||
|
@ -4222,28 +4222,28 @@ init_builtin_key_bindings (MetaDisplay *display)
|
||||
common_keybindings,
|
||||
META_KEY_BINDING_PER_WINDOW,
|
||||
META_KEYBINDING_ACTION_MOVE_TO_MONITOR_LEFT,
|
||||
handle_move_to_monitor, META_SCREEN_LEFT);
|
||||
handle_move_to_monitor, META_DISPLAY_LEFT);
|
||||
|
||||
add_builtin_keybinding (display,
|
||||
"move-to-monitor-right",
|
||||
common_keybindings,
|
||||
META_KEY_BINDING_PER_WINDOW,
|
||||
META_KEYBINDING_ACTION_MOVE_TO_MONITOR_RIGHT,
|
||||
handle_move_to_monitor, META_SCREEN_RIGHT);
|
||||
handle_move_to_monitor, META_DISPLAY_RIGHT);
|
||||
|
||||
add_builtin_keybinding (display,
|
||||
"move-to-monitor-down",
|
||||
common_keybindings,
|
||||
META_KEY_BINDING_PER_WINDOW,
|
||||
META_KEYBINDING_ACTION_MOVE_TO_MONITOR_DOWN,
|
||||
handle_move_to_monitor, META_SCREEN_DOWN);
|
||||
handle_move_to_monitor, META_DISPLAY_DOWN);
|
||||
|
||||
add_builtin_keybinding (display,
|
||||
"move-to-monitor-up",
|
||||
common_keybindings,
|
||||
META_KEY_BINDING_PER_WINDOW,
|
||||
META_KEYBINDING_ACTION_MOVE_TO_MONITOR_UP,
|
||||
handle_move_to_monitor, META_SCREEN_UP);
|
||||
handle_move_to_monitor, META_DISPLAY_UP);
|
||||
|
||||
add_builtin_keybinding (display,
|
||||
"raise-or-lower",
|
||||
|
@ -744,144 +744,6 @@ meta_screen_get_mouse_window (MetaScreen *screen,
|
||||
return window;
|
||||
}
|
||||
|
||||
int
|
||||
meta_screen_get_monitor_index_for_rect (MetaScreen *screen,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, rect);
|
||||
if (!logical_monitor)
|
||||
return -1;
|
||||
|
||||
return logical_monitor->number;
|
||||
}
|
||||
|
||||
int
|
||||
meta_screen_get_monitor_neighbor_index (MetaScreen *screen,
|
||||
int which_monitor,
|
||||
MetaScreenDirection direction)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
MetaLogicalMonitor *neighbor;
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
|
||||
which_monitor);
|
||||
neighbor = meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
||||
logical_monitor,
|
||||
direction);
|
||||
return neighbor ? neighbor->number : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_current_monitor:
|
||||
* @screen: a #MetaScreen
|
||||
*
|
||||
* Gets the index of the monitor that currently has the mouse pointer.
|
||||
*
|
||||
* Return value: a monitor index
|
||||
*/
|
||||
int
|
||||
meta_screen_get_current_monitor (MetaScreen *screen)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
logical_monitor = meta_backend_get_current_logical_monitor (backend);
|
||||
|
||||
/* Pretend its the first when there is no actual current monitor. */
|
||||
if (!logical_monitor)
|
||||
return 0;
|
||||
|
||||
return logical_monitor->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_n_monitors:
|
||||
* @screen: a #MetaScreen
|
||||
*
|
||||
* Gets the number of monitors that are joined together to form @screen.
|
||||
*
|
||||
* Return value: the number of monitors
|
||||
*/
|
||||
int
|
||||
meta_screen_get_n_monitors (MetaScreen *screen)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
|
||||
g_return_val_if_fail (META_IS_SCREEN (screen), 0);
|
||||
|
||||
return meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_primary_monitor:
|
||||
* @screen: a #MetaScreen
|
||||
*
|
||||
* Gets the index of the primary monitor on this @screen.
|
||||
*
|
||||
* Return value: a monitor index
|
||||
*/
|
||||
int
|
||||
meta_screen_get_primary_monitor (MetaScreen *screen)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
g_return_val_if_fail (META_IS_SCREEN (screen), 0);
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
||||
if (logical_monitor)
|
||||
return logical_monitor->number;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_monitor_geometry:
|
||||
* @screen: a #MetaScreen
|
||||
* @monitor: the monitor number
|
||||
* @geometry: (out): location to store the monitor geometry
|
||||
*
|
||||
* Stores the location and size of the indicated monitor in @geometry.
|
||||
*/
|
||||
void
|
||||
meta_screen_get_monitor_geometry (MetaScreen *screen,
|
||||
int monitor,
|
||||
MetaRectangle *geometry)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
int n_logical_monitors =
|
||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
#endif
|
||||
|
||||
g_return_if_fail (META_IS_SCREEN (screen));
|
||||
g_return_if_fail (monitor >= 0 && monitor < n_logical_monitors);
|
||||
g_return_if_fail (geometry != NULL);
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
|
||||
monitor);
|
||||
*geometry = logical_monitor->rect;
|
||||
}
|
||||
|
||||
#define _NET_WM_ORIENTATION_HORZ 0
|
||||
#define _NET_WM_ORIENTATION_VERT 1
|
||||
|
||||
@ -1594,42 +1456,3 @@ meta_screen_set_active_workspace_hint (MetaScreen *screen)
|
||||
32, PropModeReplace, (guchar*) data, 1);
|
||||
meta_error_trap_pop (x11_display);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_monitor_in_fullscreen:
|
||||
* @screen: a #MetaScreen
|
||||
* @monitor: the monitor number
|
||||
*
|
||||
* Determines whether there is a fullscreen window obscuring the specified
|
||||
* monitor. If there is a fullscreen window, the desktop environment will
|
||||
* typically hide any controls that might obscure the fullscreen window.
|
||||
*
|
||||
* You can get notification when this changes by connecting to
|
||||
* MetaScreen::in-fullscreen-changed.
|
||||
*
|
||||
* Returns: %TRUE if there is a fullscreen window covering the specified monitor.
|
||||
*/
|
||||
gboolean
|
||||
meta_screen_get_monitor_in_fullscreen (MetaScreen *screen,
|
||||
int monitor)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
int n_logical_monitors =
|
||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (META_IS_SCREEN (screen), FALSE);
|
||||
g_return_val_if_fail (monitor >= 0 &&
|
||||
monitor < n_logical_monitors, FALSE);
|
||||
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
|
||||
monitor);
|
||||
|
||||
/* We use -1 as a flag to mean "not known yet" for notification purposes */
|
||||
return logical_monitor->in_fullscreen == TRUE;
|
||||
}
|
||||
|
@ -2948,7 +2948,7 @@ meta_window_is_monitor_sized (MetaWindow *window)
|
||||
MetaRectangle window_rect, monitor_rect;
|
||||
|
||||
meta_window_get_frame_rect (window, &window_rect);
|
||||
meta_screen_get_monitor_geometry (window->screen, window->monitor->number, &monitor_rect);
|
||||
meta_display_get_monitor_geometry (window->display, window->monitor->number, &monitor_rect);
|
||||
|
||||
if (meta_rectangle_equal (&window_rect, &monitor_rect))
|
||||
return TRUE;
|
||||
@ -3170,7 +3170,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
|
||||
if (!meta_window_can_tile_maximized (window))
|
||||
return FALSE;
|
||||
|
||||
monitor = meta_screen_get_current_monitor (window->screen);
|
||||
monitor = meta_display_get_current_monitor (window->display);
|
||||
meta_window_get_work_area_for_monitor (window, monitor, &tile_area);
|
||||
|
||||
/* Do not allow tiling in portrait orientation */
|
||||
|
@ -1024,7 +1024,7 @@ meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
|
||||
case META_SIDE_TOP:
|
||||
if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
||||
logical_monitor,
|
||||
META_SCREEN_UP))
|
||||
META_DISPLAY_UP))
|
||||
continue;
|
||||
|
||||
strut->rect.height += strut->rect.y;
|
||||
@ -1033,7 +1033,7 @@ meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
|
||||
case META_SIDE_BOTTOM:
|
||||
if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
||||
logical_monitor,
|
||||
META_SCREEN_DOWN))
|
||||
META_DISPLAY_DOWN))
|
||||
continue;
|
||||
|
||||
strut->rect.height = screen->display->rect.height - strut->rect.y;
|
||||
@ -1041,7 +1041,7 @@ meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
|
||||
case META_SIDE_LEFT:
|
||||
if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
||||
logical_monitor,
|
||||
META_SCREEN_LEFT))
|
||||
META_DISPLAY_LEFT))
|
||||
continue;
|
||||
|
||||
strut->rect.width += strut->rect.x;
|
||||
@ -1050,7 +1050,7 @@ meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
|
||||
case META_SIDE_RIGHT:
|
||||
if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
||||
logical_monitor,
|
||||
META_SCREEN_RIGHT))
|
||||
META_DISPLAY_RIGHT))
|
||||
continue;
|
||||
|
||||
strut->rect.width = screen->display->rect.width - strut->rect.x;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <meta/types.h>
|
||||
#include <meta/prefs.h>
|
||||
#include <meta/common.h>
|
||||
#include <meta/workspace.h>
|
||||
|
||||
/**
|
||||
* MetaTabList:
|
||||
@ -175,4 +176,36 @@ void meta_display_set_cursor (MetaDisplay *display,
|
||||
|
||||
GSList *meta_display_get_startup_sequences (MetaDisplay *display);
|
||||
|
||||
/**
|
||||
* MetaDisplayDirection:
|
||||
* @META_DISPLAY_UP: up
|
||||
* @META_DISPLAY_DOWN: down
|
||||
* @META_DISPLAY_LEFT: left
|
||||
* @META_DISPLAY_RIGHT: right
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
META_DISPLAY_UP,
|
||||
META_DISPLAY_DOWN,
|
||||
META_DISPLAY_LEFT,
|
||||
META_DISPLAY_RIGHT
|
||||
} MetaDisplayDirection;
|
||||
|
||||
int meta_display_get_n_monitors (MetaDisplay *display);
|
||||
int meta_display_get_primary_monitor (MetaDisplay *display);
|
||||
int meta_display_get_current_monitor (MetaDisplay *display);
|
||||
void meta_display_get_monitor_geometry (MetaDisplay *display,
|
||||
int monitor,
|
||||
MetaRectangle *geometry);
|
||||
|
||||
gboolean meta_display_get_monitor_in_fullscreen (MetaDisplay *display,
|
||||
int monitor);
|
||||
|
||||
int meta_display_get_monitor_index_for_rect (MetaDisplay *display,
|
||||
MetaRectangle *rect);
|
||||
|
||||
int meta_display_get_monitor_neighbor_index (MetaDisplay *display,
|
||||
int which_monitor,
|
||||
MetaDisplayDirection dir);
|
||||
|
||||
#endif
|
||||
|
@ -61,7 +61,7 @@ void meta_background_refresh_all (void);
|
||||
|
||||
GType meta_background_get_type (void);
|
||||
|
||||
MetaBackground *meta_background_new (MetaScreen *screen);
|
||||
MetaBackground *meta_background_new (MetaDisplay *display);
|
||||
|
||||
void meta_background_set_color (MetaBackground *self,
|
||||
ClutterColor *color);
|
||||
|
@ -56,38 +56,6 @@ int meta_screen_get_active_workspace_index (MetaScreen *screen);
|
||||
|
||||
MetaWorkspace * meta_screen_get_active_workspace (MetaScreen *screen);
|
||||
|
||||
/**
|
||||
* MetaScreenDirection:
|
||||
* @META_SCREEN_UP: up
|
||||
* @META_SCREEN_DOWN: down
|
||||
* @META_SCREEN_LEFT: left
|
||||
* @META_SCREEN_RIGHT: right
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
META_SCREEN_UP,
|
||||
META_SCREEN_DOWN,
|
||||
META_SCREEN_LEFT,
|
||||
META_SCREEN_RIGHT
|
||||
} MetaScreenDirection;
|
||||
|
||||
int meta_screen_get_n_monitors (MetaScreen *screen);
|
||||
int meta_screen_get_primary_monitor (MetaScreen *screen);
|
||||
int meta_screen_get_current_monitor (MetaScreen *screen);
|
||||
void meta_screen_get_monitor_geometry (MetaScreen *screen,
|
||||
int monitor,
|
||||
MetaRectangle *geometry);
|
||||
|
||||
gboolean meta_screen_get_monitor_in_fullscreen (MetaScreen *screen,
|
||||
int monitor);
|
||||
|
||||
int meta_screen_get_monitor_index_for_rect (MetaScreen *screen,
|
||||
MetaRectangle *rect);
|
||||
|
||||
int meta_screen_get_monitor_neighbor_index (MetaScreen *screen,
|
||||
int which_monitor,
|
||||
MetaScreenDirection dir);
|
||||
|
||||
void meta_screen_focus_default_window (MetaScreen *screen,
|
||||
guint32 timestamp);
|
||||
|
||||
|
@ -82,14 +82,12 @@ static void
|
||||
meta_test_headless_monitor_getters (void)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaScreen *screen;
|
||||
int index;
|
||||
|
||||
display = meta_get_display ();
|
||||
screen = display->screen;
|
||||
|
||||
index = meta_screen_get_monitor_index_for_rect (screen,
|
||||
&(MetaRectangle) { 0 });
|
||||
index = meta_display_get_monitor_index_for_rect (display,
|
||||
&(MetaRectangle) { 0 });
|
||||
g_assert_cmpint (index, ==, -1);
|
||||
}
|
||||
|
||||
|
@ -2117,7 +2117,9 @@ meta_window_move_resize_request (MetaWindow *window,
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
meta_screen_get_monitor_geometry (window->screen, window->monitor->number, &monitor_rect);
|
||||
meta_display_get_monitor_geometry (window->display,
|
||||
window->monitor->number,
|
||||
&monitor_rect);
|
||||
|
||||
/* Workaround braindead legacy apps that don't know how to
|
||||
* fullscreen themselves properly - don't get fooled by
|
||||
|
Loading…
Reference in New Issue
Block a user