mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
monitor-manager: Move UpClient signal listening into monitor manager
Move the UpClients notify::lid-is-closed signal handling into MetaMonitorManager, and put the getter behind a vfunc. This means Placing it behind a vfunc allows custom backends to implement it differently; for example the test backend can mock the state. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
8d1be7ffc0
commit
f7b6271d86
@ -39,7 +39,6 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include <libupower-glib/upower.h>
|
||||
|
||||
#include <meta/main.h>
|
||||
#include <meta/errors.h>
|
||||
@ -87,7 +86,6 @@ struct _MetaMonitorConfig {
|
||||
GFile *system_file;
|
||||
GCancellable *save_cancellable;
|
||||
|
||||
UpClient *up_client;
|
||||
gboolean lid_is_closed;
|
||||
};
|
||||
|
||||
@ -98,8 +96,7 @@ static gboolean meta_monitor_config_assign_crtcs (MetaConfiguration *config,
|
||||
GPtrArray *crtcs,
|
||||
GPtrArray *outputs);
|
||||
|
||||
static void power_client_changed_cb (UpClient *client,
|
||||
GParamSpec *pspec,
|
||||
static void power_client_changed_cb (MetaMonitorManager *manager,
|
||||
gpointer user_data);
|
||||
|
||||
static void
|
||||
@ -255,12 +252,6 @@ meta_monitor_config_init (MetaMonitorConfig *self)
|
||||
self->system_file = g_file_new_for_path (path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
self->up_client = up_client_new ();
|
||||
self->lid_is_closed = up_client_get_lid_is_closed (self->up_client);
|
||||
|
||||
g_signal_connect_object (self->up_client, "notify::lid-is-closed",
|
||||
G_CALLBACK (power_client_changed_cb), self, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -796,11 +787,16 @@ meta_monitor_config_load (MetaMonitorConfig *self)
|
||||
}
|
||||
|
||||
MetaMonitorConfig *
|
||||
meta_monitor_config_new (void)
|
||||
meta_monitor_config_new (MetaMonitorManager *manager)
|
||||
{
|
||||
MetaMonitorConfig *self;
|
||||
|
||||
self = g_object_new (META_TYPE_MONITOR_CONFIG, NULL);
|
||||
|
||||
self->lid_is_closed = meta_monitor_manager_is_lid_closed (manager);
|
||||
g_signal_connect_object (manager, "lid-is-closed-changed",
|
||||
G_CALLBACK (power_client_changed_cb), self, 0);
|
||||
|
||||
meta_monitor_config_load (self);
|
||||
|
||||
return self;
|
||||
@ -1568,15 +1564,13 @@ turn_off_laptop_display (MetaMonitorConfig *self,
|
||||
}
|
||||
|
||||
static void
|
||||
power_client_changed_cb (UpClient *client,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
power_client_changed_cb (MetaMonitorManager *manager,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaMonitorManager *manager = meta_monitor_manager_get ();
|
||||
MetaMonitorConfig *self = user_data;
|
||||
gboolean is_closed;
|
||||
|
||||
is_closed = up_client_get_lid_is_closed (self->up_client);
|
||||
is_closed = meta_monitor_manager_is_lid_closed (manager);
|
||||
|
||||
if (is_closed != self->lid_is_closed)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
G_DECLARE_FINAL_TYPE (MetaMonitorConfig, meta_monitor_config,
|
||||
META, MONITOR_CONFIG, GObject)
|
||||
|
||||
MetaMonitorConfig *meta_monitor_config_new (void);
|
||||
MetaMonitorConfig *meta_monitor_config_new (MetaMonitorManager *manager);
|
||||
|
||||
gboolean meta_monitor_config_apply_stored (MetaMonitorConfig *config,
|
||||
MetaMonitorManager *manager);
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <cogl/cogl.h>
|
||||
#include <libgnome-desktop/gnome-pnp-ids.h>
|
||||
#include <libupower-glib/upower.h>
|
||||
|
||||
#include "display-private.h"
|
||||
#include <meta/screen.h>
|
||||
@ -289,6 +290,7 @@ struct _MetaMonitorManager
|
||||
MetaMonitorConfigManager *config_manager;
|
||||
|
||||
GnomePnpIds *pnp_ids;
|
||||
UpClient *up_client;
|
||||
};
|
||||
|
||||
struct _MetaMonitorManagerClass
|
||||
@ -302,6 +304,8 @@ struct _MetaMonitorManagerClass
|
||||
GBytes* (*read_edid) (MetaMonitorManager *,
|
||||
MetaOutput *);
|
||||
|
||||
gboolean (*is_lid_closed) (MetaMonitorManager *);
|
||||
|
||||
void (*ensure_initial_config) (MetaMonitorManager *);
|
||||
|
||||
gboolean (*apply_monitors_config) (MetaMonitorManager *,
|
||||
@ -429,6 +433,10 @@ void meta_monitor_manager_update_logical_state (MetaMonitorManager
|
||||
MetaMonitorsConfig *config);
|
||||
void meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager);
|
||||
|
||||
gboolean meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_manager_lid_is_closed_changed (MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_manager_clear_output (MetaOutput *output);
|
||||
void meta_monitor_manager_clear_mode (MetaCrtcMode *mode);
|
||||
void meta_monitor_manager_clear_crtc (MetaCrtc *crtc);
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
enum {
|
||||
CONFIRM_DISPLAY_CHANGE,
|
||||
LID_IS_CLOSED_CHANGED,
|
||||
SIGNALS_LAST
|
||||
};
|
||||
|
||||
@ -280,6 +281,34 @@ power_save_mode_changed (MetaMonitorManager *manager,
|
||||
manager->power_save_mode = mode;
|
||||
}
|
||||
|
||||
void
|
||||
meta_monitor_manager_lid_is_closed_changed (MetaMonitorManager *manager)
|
||||
{
|
||||
g_signal_emit (manager, signals[LID_IS_CLOSED_CHANGED], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
lid_is_closed_changed (UpClient *client,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaMonitorManager *manager = user_data;
|
||||
|
||||
meta_monitor_manager_lid_is_closed_changed (manager);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_monitor_manager_real_is_lid_closed (MetaMonitorManager *manager)
|
||||
{
|
||||
return up_client_get_lid_is_closed (manager->up_client);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager)
|
||||
{
|
||||
return META_MONITOR_MANAGER_GET_CLASS (manager)->is_lid_closed (manager);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_ensure_initial_config (MetaMonitorManager *manager)
|
||||
{
|
||||
@ -388,6 +417,15 @@ static void
|
||||
meta_monitor_manager_constructed (GObject *object)
|
||||
{
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (object);
|
||||
MetaMonitorManagerClass *manager_class =
|
||||
META_MONITOR_MANAGER_GET_CLASS (manager);
|
||||
|
||||
if (manager_class->is_lid_closed == meta_monitor_manager_real_is_lid_closed)
|
||||
{
|
||||
manager->up_client = up_client_new ();
|
||||
g_signal_connect_object (manager->up_client, "notify::lid-is-closed",
|
||||
G_CALLBACK (lid_is_closed_changed), manager, 0);
|
||||
}
|
||||
|
||||
g_signal_connect_object (manager, "notify::power-save-mode",
|
||||
G_CALLBACK (power_save_mode_changed), manager, 0);
|
||||
@ -397,7 +435,7 @@ meta_monitor_manager_constructed (GObject *object)
|
||||
if (g_strcmp0 (g_getenv ("MUTTER_USE_CONFIG_MANAGER"), "1") == 0)
|
||||
manager->config_manager = meta_monitor_config_manager_new (manager);
|
||||
else
|
||||
manager->legacy_config = meta_monitor_config_new ();
|
||||
manager->legacy_config = meta_monitor_config_new (manager);
|
||||
|
||||
meta_monitor_manager_read_current_state (manager);
|
||||
|
||||
@ -506,6 +544,7 @@ meta_monitor_manager_dispose (GObject *object)
|
||||
}
|
||||
|
||||
g_clear_object (&manager->config_manager);
|
||||
g_clear_object (&manager->up_client);
|
||||
|
||||
G_OBJECT_CLASS (meta_monitor_manager_parent_class)->dispose (object);
|
||||
}
|
||||
@ -535,6 +574,7 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
|
||||
klass->get_edid_file = meta_monitor_manager_real_get_edid_file;
|
||||
klass->read_edid = meta_monitor_manager_real_read_edid;
|
||||
klass->is_lid_closed = meta_monitor_manager_real_is_lid_closed;
|
||||
|
||||
signals[CONFIRM_DISPLAY_CHANGE] =
|
||||
g_signal_new ("confirm-display-change",
|
||||
@ -543,6 +583,14 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[LID_IS_CLOSED_CHANGED] =
|
||||
g_signal_new ("lid-is-closed-changed",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static const double known_diagonals[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user