2013-07-18 07:09:16 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file screen-private.h Handling of monitor configuration
|
|
|
|
*
|
|
|
|
* Managing multiple monitors
|
|
|
|
* This file contains structures and functions that handle
|
|
|
|
* multiple monitors, including reading the current configuration
|
|
|
|
* and available hardware, and applying it.
|
|
|
|
*
|
|
|
|
* This interface is private to mutter, API users should look
|
|
|
|
* at MetaScreen instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
|
|
|
* Copyright (C) 2003 Rob Adams
|
|
|
|
* Copyright (C) 2004-2006 Elijah Newren
|
|
|
|
* Copyright (C) 2013 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef META_MONITOR_PRIVATE_H
|
|
|
|
#define META_MONITOR_PRIVATE_H
|
|
|
|
|
2013-07-19 08:39:28 -04:00
|
|
|
#include <cogl/cogl.h>
|
2013-08-16 11:32:50 -04:00
|
|
|
#include <libgnome-desktop/gnome-pnp-ids.h>
|
2013-07-19 08:39:28 -04:00
|
|
|
|
2013-07-18 07:09:16 -04:00
|
|
|
#include "display-private.h"
|
|
|
|
#include <meta/screen.h>
|
|
|
|
#include "stack-tracker.h"
|
|
|
|
#include "ui.h"
|
2013-07-24 04:01:57 -04:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
#include <wayland-server.h>
|
|
|
|
#endif
|
2013-07-24 04:39:06 -04:00
|
|
|
#include "meta-xrandr-shared.h"
|
2013-07-24 04:01:57 -04:00
|
|
|
|
2013-07-29 07:00:15 -04:00
|
|
|
#include "meta-dbus-xrandr.h"
|
|
|
|
|
|
|
|
typedef struct _MetaMonitorManagerClass MetaMonitorManagerClass;
|
|
|
|
typedef struct _MetaMonitorManager MetaMonitorManager;
|
|
|
|
typedef struct _MetaMonitorConfigClass MetaMonitorConfigClass;
|
|
|
|
typedef struct _MetaMonitorConfig MetaMonitorConfig;
|
|
|
|
|
2013-07-24 04:01:57 -04:00
|
|
|
#ifndef HAVE_WAYLAND
|
|
|
|
enum wl_output_transform {
|
|
|
|
WL_OUTPUT_TRANSFORM_NORMAL,
|
|
|
|
WL_OUTPUT_TRANSFORM_90,
|
|
|
|
WL_OUTPUT_TRANSFORM_180,
|
|
|
|
WL_OUTPUT_TRANSFORM_270,
|
|
|
|
WL_OUTPUT_TRANSFORM_FLIPPED,
|
|
|
|
WL_OUTPUT_TRANSFORM_FLIPPED_90,
|
|
|
|
WL_OUTPUT_TRANSFORM_FLIPPED_180,
|
|
|
|
WL_OUTPUT_TRANSFORM_FLIPPED_270
|
|
|
|
};
|
|
|
|
#endif
|
2013-07-18 07:09:16 -04:00
|
|
|
|
|
|
|
typedef struct _MetaOutput MetaOutput;
|
2013-07-19 08:39:28 -04:00
|
|
|
typedef struct _MetaCRTC MetaCRTC;
|
|
|
|
typedef struct _MetaMonitorMode MetaMonitorMode;
|
2013-07-18 07:09:16 -04:00
|
|
|
typedef struct _MetaMonitorInfo MetaMonitorInfo;
|
2013-07-24 12:01:31 -04:00
|
|
|
typedef struct _MetaCRTCInfo MetaCRTCInfo;
|
|
|
|
typedef struct _MetaOutputInfo MetaOutputInfo;
|
2013-07-18 07:09:16 -04:00
|
|
|
|
|
|
|
struct _MetaOutput
|
|
|
|
{
|
2013-07-19 08:39:28 -04:00
|
|
|
/* The CRTC driving this output, NULL if the output is not enabled */
|
|
|
|
MetaCRTC *crtc;
|
|
|
|
/* The low-level ID of this output, used to apply back configuration */
|
|
|
|
glong output_id;
|
2013-07-18 07:09:16 -04:00
|
|
|
char *name;
|
2013-07-19 08:39:28 -04:00
|
|
|
char *vendor;
|
|
|
|
char *product;
|
|
|
|
char *serial;
|
2013-07-18 07:09:16 -04:00
|
|
|
int width_mm;
|
|
|
|
int height_mm;
|
|
|
|
CoglSubpixelOrder subpixel_order;
|
2013-07-19 08:39:28 -04:00
|
|
|
|
|
|
|
MetaMonitorMode *preferred_mode;
|
|
|
|
MetaMonitorMode **modes;
|
|
|
|
unsigned int n_modes;
|
|
|
|
|
|
|
|
MetaCRTC **possible_crtcs;
|
|
|
|
unsigned int n_possible_crtcs;
|
|
|
|
|
2013-07-19 12:47:01 -04:00
|
|
|
MetaOutput **possible_clones;
|
|
|
|
unsigned int n_possible_clones;
|
|
|
|
|
2013-07-25 09:06:09 -04:00
|
|
|
int backlight;
|
|
|
|
int backlight_min;
|
|
|
|
int backlight_max;
|
|
|
|
|
2013-07-23 04:07:52 -04:00
|
|
|
/* Used when changing configuration */
|
|
|
|
gboolean is_dirty;
|
|
|
|
|
2013-07-19 08:39:28 -04:00
|
|
|
/* The low-level bits used to build the high-level info
|
|
|
|
in MetaMonitorInfo
|
|
|
|
|
|
|
|
XXX: flags maybe?
|
|
|
|
There is a lot of code that uses MonitorInfo->is_primary,
|
|
|
|
but nobody uses MetaOutput yet
|
|
|
|
*/
|
|
|
|
gboolean is_primary;
|
|
|
|
gboolean is_presentation;
|
2013-07-18 07:09:16 -04:00
|
|
|
};
|
|
|
|
|
2013-07-19 08:39:28 -04:00
|
|
|
struct _MetaCRTC
|
|
|
|
{
|
|
|
|
glong crtc_id;
|
|
|
|
MetaRectangle rect;
|
|
|
|
MetaMonitorMode *current_mode;
|
2013-07-24 04:01:57 -04:00
|
|
|
enum wl_output_transform transform;
|
|
|
|
unsigned int all_transforms;
|
2013-07-19 08:39:28 -04:00
|
|
|
|
|
|
|
/* Only used to build the logical configuration
|
|
|
|
from the HW one
|
|
|
|
*/
|
|
|
|
MetaMonitorInfo *logical_monitor;
|
2013-07-22 07:31:10 -04:00
|
|
|
|
|
|
|
/* Used when changing configuration */
|
|
|
|
gboolean is_dirty;
|
2013-07-19 08:39:28 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaMonitorMode
|
|
|
|
{
|
|
|
|
/* The low-level ID of this mode, used to apply back configuration */
|
|
|
|
glong mode_id;
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
float refresh_rate;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MetaMonitorInfo:
|
|
|
|
*
|
|
|
|
* A structure with high-level information about monitors.
|
|
|
|
* This corresponds to a subset of the compositor coordinate space.
|
|
|
|
* Clones are only reported once, irrespective of the way
|
|
|
|
* they're implemented (two CRTCs configured for the same
|
|
|
|
* coordinates or one CRTCs driving two outputs). Inactive CRTCs
|
|
|
|
* are ignored, and so are disabled outputs.
|
|
|
|
*/
|
2013-07-18 07:09:16 -04:00
|
|
|
struct _MetaMonitorInfo
|
|
|
|
{
|
|
|
|
int number;
|
|
|
|
int xinerama_index;
|
|
|
|
MetaRectangle rect;
|
|
|
|
gboolean is_primary;
|
2013-07-19 08:39:28 -04:00
|
|
|
gboolean is_presentation; /* XXX: not yet used */
|
2013-07-18 07:09:16 -04:00
|
|
|
gboolean in_fullscreen;
|
|
|
|
|
2013-07-19 08:39:28 -04:00
|
|
|
/* The primary or first output for this monitor, 0 if we can't figure out.
|
|
|
|
It can be matched to an output_id of a MetaOutput.
|
|
|
|
|
|
|
|
This is used as an opaque token on reconfiguration when switching from
|
|
|
|
clone to extened, to decide on what output the windows should go next
|
|
|
|
(it's an attempt to keep windows on the same monitor, and preferably on
|
|
|
|
the primary one).
|
|
|
|
*/
|
2013-07-18 07:09:16 -04:00
|
|
|
glong output_id;
|
|
|
|
};
|
|
|
|
|
2013-07-24 12:01:31 -04:00
|
|
|
/*
|
|
|
|
* MetaCRTCInfo:
|
|
|
|
* This represents the writable part of a CRTC, as deserialized from DBus
|
|
|
|
* or built by MetaMonitorConfig
|
|
|
|
*
|
|
|
|
* Note: differently from the other structures in this file, MetaCRTCInfo
|
|
|
|
* is handled by pointer. This is to accomodate the usage in MetaMonitorConfig
|
|
|
|
*/
|
|
|
|
struct _MetaCRTCInfo {
|
|
|
|
MetaCRTC *crtc;
|
|
|
|
MetaMonitorMode *mode;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
enum wl_output_transform transform;
|
|
|
|
GPtrArray *outputs;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MetaOutputInfo:
|
|
|
|
* this is the same as MetaOutputInfo, but for CRTCs
|
|
|
|
*/
|
|
|
|
struct _MetaOutputInfo {
|
|
|
|
MetaOutput *output;
|
|
|
|
gboolean is_primary;
|
|
|
|
gboolean is_presentation;
|
|
|
|
};
|
|
|
|
|
2013-07-18 07:09:16 -04:00
|
|
|
#define META_TYPE_MONITOR_MANAGER (meta_monitor_manager_get_type ())
|
|
|
|
#define META_MONITOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER, MetaMonitorManager))
|
|
|
|
#define META_MONITOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER, MetaMonitorManagerClass))
|
|
|
|
#define META_IS_MONITOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER))
|
|
|
|
#define META_IS_MONITOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER))
|
|
|
|
#define META_MONITOR_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER, MetaMonitorManagerClass))
|
|
|
|
|
2013-07-29 07:00:15 -04:00
|
|
|
struct _MetaMonitorManager
|
|
|
|
{
|
|
|
|
MetaDBusDisplayConfigSkeleton parent_instance;
|
|
|
|
|
|
|
|
/* XXX: this structure is very badly
|
|
|
|
packed, but I like the logical organization
|
|
|
|
of fields */
|
|
|
|
|
|
|
|
gboolean in_init;
|
|
|
|
unsigned int serial;
|
|
|
|
|
|
|
|
MetaPowerSave power_save_mode;
|
|
|
|
|
|
|
|
int max_screen_width;
|
|
|
|
int max_screen_height;
|
|
|
|
int screen_width;
|
|
|
|
int screen_height;
|
|
|
|
|
|
|
|
/* Outputs refer to physical screens,
|
|
|
|
CRTCs refer to stuff that can drive outputs
|
|
|
|
(like encoders, but less tied to the HW),
|
|
|
|
while monitor_infos refer to logical ones.
|
|
|
|
|
|
|
|
See also the comment in monitor-private.h
|
|
|
|
*/
|
|
|
|
MetaOutput *outputs;
|
|
|
|
unsigned int n_outputs;
|
|
|
|
|
|
|
|
MetaMonitorMode *modes;
|
|
|
|
unsigned int n_modes;
|
|
|
|
|
|
|
|
MetaCRTC *crtcs;
|
|
|
|
unsigned int n_crtcs;
|
|
|
|
|
|
|
|
MetaMonitorInfo *monitor_infos;
|
|
|
|
unsigned int n_monitor_infos;
|
|
|
|
int primary_monitor_index;
|
|
|
|
|
|
|
|
int dbus_name_id;
|
|
|
|
|
|
|
|
int persistent_timeout_id;
|
|
|
|
MetaMonitorConfig *config;
|
2013-08-16 11:32:50 -04:00
|
|
|
|
|
|
|
GnomePnpIds *pnp_ids;
|
2013-07-29 07:00:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaMonitorManagerClass
|
|
|
|
{
|
|
|
|
MetaDBusDisplayConfigSkeletonClass parent_class;
|
|
|
|
|
|
|
|
void (*read_current) (MetaMonitorManager *);
|
2013-08-08 07:32:05 -04:00
|
|
|
|
|
|
|
char* (*get_edid_file) (MetaMonitorManager *,
|
|
|
|
MetaOutput *);
|
|
|
|
GBytes* (*read_edid) (MetaMonitorManager *,
|
|
|
|
MetaOutput *);
|
|
|
|
|
2013-07-29 07:00:15 -04:00
|
|
|
void (*apply_configuration) (MetaMonitorManager *,
|
|
|
|
MetaCRTCInfo **,
|
|
|
|
unsigned int ,
|
|
|
|
MetaOutputInfo **,
|
|
|
|
unsigned int);
|
|
|
|
|
|
|
|
void (*set_power_save_mode) (MetaMonitorManager *,
|
|
|
|
MetaPowerSave);
|
|
|
|
|
|
|
|
void (*change_backlight) (MetaMonitorManager *,
|
|
|
|
MetaOutput *,
|
|
|
|
int);
|
|
|
|
|
|
|
|
void (*get_crtc_gamma) (MetaMonitorManager *,
|
|
|
|
MetaCRTC *,
|
|
|
|
gsize *,
|
|
|
|
unsigned short **,
|
|
|
|
unsigned short **,
|
|
|
|
unsigned short **);
|
|
|
|
void (*set_crtc_gamma) (MetaMonitorManager *,
|
|
|
|
MetaCRTC *,
|
|
|
|
gsize ,
|
|
|
|
unsigned short *,
|
|
|
|
unsigned short *,
|
|
|
|
unsigned short *);
|
|
|
|
|
|
|
|
gboolean (*handle_xevent) (MetaMonitorManager *,
|
|
|
|
XEvent *);
|
|
|
|
};
|
2013-07-18 07:09:16 -04:00
|
|
|
|
|
|
|
GType meta_monitor_manager_get_type (void);
|
|
|
|
|
2013-07-29 07:00:15 -04:00
|
|
|
void meta_monitor_manager_initialize (void);
|
2013-07-18 07:09:16 -04:00
|
|
|
MetaMonitorManager *meta_monitor_manager_get (void);
|
|
|
|
|
2013-09-02 09:04:05 -04:00
|
|
|
void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager);
|
|
|
|
|
2013-07-18 07:09:16 -04:00
|
|
|
MetaMonitorInfo *meta_monitor_manager_get_monitor_infos (MetaMonitorManager *manager,
|
2013-07-24 09:35:47 -04:00
|
|
|
unsigned int *n_infos);
|
2013-07-18 07:09:16 -04:00
|
|
|
|
|
|
|
MetaOutput *meta_monitor_manager_get_outputs (MetaMonitorManager *manager,
|
2013-07-24 09:35:47 -04:00
|
|
|
unsigned int *n_outputs);
|
2013-07-18 07:09:16 -04:00
|
|
|
|
2013-07-24 12:01:31 -04:00
|
|
|
void meta_monitor_manager_get_resources (MetaMonitorManager *manager,
|
|
|
|
MetaMonitorMode **modes,
|
|
|
|
unsigned int *n_modes,
|
|
|
|
MetaCRTC **crtcs,
|
|
|
|
unsigned int *n_crtcs,
|
|
|
|
MetaOutput **outputs,
|
|
|
|
unsigned int *n_outputs);
|
|
|
|
|
2013-07-18 07:09:16 -04:00
|
|
|
int meta_monitor_manager_get_primary_index (MetaMonitorManager *manager);
|
|
|
|
|
2013-07-22 12:57:12 -04:00
|
|
|
gboolean meta_monitor_manager_handle_xevent (MetaMonitorManager *manager,
|
|
|
|
XEvent *event);
|
|
|
|
|
|
|
|
void meta_monitor_manager_get_screen_size (MetaMonitorManager *manager,
|
|
|
|
int *width,
|
|
|
|
int *height);
|
2013-07-18 07:09:16 -04:00
|
|
|
|
2013-07-25 04:57:59 -04:00
|
|
|
void meta_monitor_manager_get_screen_limits (MetaMonitorManager *manager,
|
|
|
|
int *width,
|
|
|
|
int *height);
|
|
|
|
|
2013-07-24 12:01:31 -04:00
|
|
|
void meta_monitor_manager_apply_configuration (MetaMonitorManager *manager,
|
|
|
|
MetaCRTCInfo **crtcs,
|
|
|
|
unsigned int n_crtcs,
|
|
|
|
MetaOutputInfo **outputs,
|
|
|
|
unsigned int n_outputs);
|
2013-07-24 09:35:47 -04:00
|
|
|
|
2013-07-29 04:12:24 -04:00
|
|
|
void meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager,
|
|
|
|
gboolean ok);
|
|
|
|
|
2013-07-29 07:00:15 -04:00
|
|
|
#define META_TYPE_MONITOR_MANAGER_XRANDR (meta_monitor_manager_xrandr_get_type ())
|
|
|
|
#define META_MONITOR_MANAGER_XRANDR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandr))
|
|
|
|
#define META_MONITOR_MANAGER_XRANDR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandrClass))
|
|
|
|
#define META_IS_MONITOR_MANAGER_XRANDR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_MANAGER_XRANDR))
|
|
|
|
#define META_IS_MONITOR_MANAGER_XRANDR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_MANAGER_XRANDR))
|
|
|
|
#define META_MONITOR_MANAGER_XRANDR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_MANAGER_XRANDR, MetaMonitorManagerXrandrClass))
|
|
|
|
|
|
|
|
typedef struct _MetaMonitorManagerXrandrClass MetaMonitorManagerXrandrClass;
|
|
|
|
typedef struct _MetaMonitorManagerXrandr MetaMonitorManagerXrandr;
|
|
|
|
|
|
|
|
GType meta_monitor_manager_xrandr_get_type (void);
|
|
|
|
|
2013-07-24 09:35:47 -04:00
|
|
|
#define META_TYPE_MONITOR_CONFIG (meta_monitor_config_get_type ())
|
|
|
|
#define META_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfig))
|
|
|
|
#define META_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass))
|
|
|
|
#define META_IS_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_MONITOR_CONFIG))
|
|
|
|
#define META_IS_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_MONITOR_CONFIG))
|
|
|
|
#define META_MONITOR_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass))
|
|
|
|
|
|
|
|
GType meta_monitor_config_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
MetaMonitorConfig *meta_monitor_config_new (void);
|
|
|
|
|
|
|
|
gboolean meta_monitor_config_match_current (MetaMonitorConfig *config,
|
|
|
|
MetaMonitorManager *manager);
|
|
|
|
|
|
|
|
gboolean meta_monitor_config_apply_stored (MetaMonitorConfig *config,
|
|
|
|
MetaMonitorManager *manager);
|
|
|
|
|
|
|
|
void meta_monitor_config_make_default (MetaMonitorConfig *config,
|
|
|
|
MetaMonitorManager *manager);
|
|
|
|
|
|
|
|
void meta_monitor_config_update_current (MetaMonitorConfig *config,
|
|
|
|
MetaMonitorManager *manager);
|
|
|
|
void meta_monitor_config_make_persistent (MetaMonitorConfig *config);
|
|
|
|
|
2013-07-26 12:22:59 -04:00
|
|
|
void meta_monitor_config_restore_previous (MetaMonitorConfig *config,
|
|
|
|
MetaMonitorManager *manager);
|
|
|
|
|
2013-07-24 12:01:31 -04:00
|
|
|
void meta_crtc_info_free (MetaCRTCInfo *info);
|
|
|
|
void meta_output_info_free (MetaOutputInfo *info);
|
|
|
|
|
2013-09-02 09:04:05 -04:00
|
|
|
void meta_monitor_manager_free_output_array (MetaOutput *old_outputs,
|
|
|
|
int n_old_outputs);
|
|
|
|
|
2013-07-24 04:01:57 -04:00
|
|
|
/* Returns true if transform causes width and height to be inverted
|
|
|
|
This is true for the odd transforms in the enum */
|
|
|
|
static inline gboolean
|
|
|
|
meta_monitor_transform_is_rotated (enum wl_output_transform transform)
|
|
|
|
{
|
|
|
|
return (transform % 2);
|
|
|
|
}
|
|
|
|
|
2013-07-18 07:09:16 -04:00
|
|
|
#endif
|