mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 05:12:15 +00:00
Add api to get the primary monitor of the screen
We don't actually use the full xrandr to get the primary monitor, we just rely on the xrandr xinerama compat code to return the primary monitor first. This lets us avoid adding unnecessary xrandr code and avoids issues with _NET_WM_FULLSCREEN_MONITORS monitor indexes being defined wrt xinerama monitor index order. https://bugzilla.gnome.org/show_bug.cgi?id=609258
This commit is contained in:
parent
de8eb1f8ee
commit
f9b5cdfeb1
@ -99,6 +99,7 @@ struct _MetaScreen
|
||||
guint32 wm_sn_timestamp;
|
||||
|
||||
MetaMonitorInfo *monitor_infos;
|
||||
int primary_monitor_index;
|
||||
int n_monitor_infos;
|
||||
|
||||
/* Cache the current monitor */
|
||||
|
@ -352,6 +352,18 @@ reload_monitor_infos (MetaScreen *screen)
|
||||
screen->n_monitor_infos = 0;
|
||||
screen->last_monitor_index = 0;
|
||||
|
||||
/* Xinerama doesn't have a concept of primary monitor, however XRandR
|
||||
* does. However, the XRandR xinerama compat code always sorts the
|
||||
* primary output first, so we rely on that here. We could use the
|
||||
* native XRandR calls instead of xinerama, but that would be
|
||||
* slightly problematic for _NET_WM_FULLSCREEN_MONITORS support, as
|
||||
* that is defined in terms of xinerama monitor indexes.
|
||||
* So, since we don't need anything in xrandr except the primary
|
||||
* we can keep using xinerama and use the first monitor as the
|
||||
* primary.
|
||||
*/
|
||||
screen->primary_monitor_index = 0;
|
||||
|
||||
screen->display->monitor_cache_invalidated = TRUE;
|
||||
|
||||
if (g_getenv ("MUTTER_DEBUG_XINERAMA"))
|
||||
@ -2140,6 +2152,22 @@ meta_screen_get_n_monitors (MetaScreen *screen)
|
||||
return screen->n_monitor_infos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
g_return_val_if_fail (META_IS_SCREEN (screen), 0);
|
||||
|
||||
return screen->primary_monitor_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_screen_get_monitor_geometry:
|
||||
* @screen: a #MetaScreen
|
||||
|
@ -76,6 +76,7 @@ int meta_screen_get_active_workspace_index (MetaScreen *screen);
|
||||
MetaWorkspace * meta_screen_get_active_workspace (MetaScreen *screen);
|
||||
|
||||
int meta_screen_get_n_monitors (MetaScreen *screen);
|
||||
int meta_screen_get_primary_monitor (MetaScreen *screen);
|
||||
void meta_screen_get_monitor_geometry (MetaScreen *screen,
|
||||
int monitor,
|
||||
MetaRectangle *geometry);
|
||||
|
Loading…
Reference in New Issue
Block a user