mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
backend: Reset idle when lid is opened or resuming from suspend
There's no particular reason for this code to only ever be triggered on Wayland, and allows removing X11-specific work-arounds from gnome-settings-daemon. See https://bugs.freedesktop.org/show_bug.cgi?id=59576 https://bugzilla.gnome.org/show_bug.cgi?id=705942
This commit is contained in:
parent
4af00ae296
commit
657417a578
@ -110,6 +110,11 @@ struct _MetaBackendPrivate
|
|||||||
|
|
||||||
MetaPointerConstraint *client_pointer_constraint;
|
MetaPointerConstraint *client_pointer_constraint;
|
||||||
MetaDnd *dnd;
|
MetaDnd *dnd;
|
||||||
|
|
||||||
|
UpClient *up_client;
|
||||||
|
guint sleep_signal_id;
|
||||||
|
GCancellable *cancellable;
|
||||||
|
GDBusConnection *system_bus;
|
||||||
};
|
};
|
||||||
typedef struct _MetaBackendPrivate MetaBackendPrivate;
|
typedef struct _MetaBackendPrivate MetaBackendPrivate;
|
||||||
|
|
||||||
@ -136,6 +141,13 @@ meta_backend_finalize (GObject *object)
|
|||||||
g_clear_object (&priv->dbus_session_watcher);
|
g_clear_object (&priv->dbus_session_watcher);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
g_object_unref (priv->up_client);
|
||||||
|
if (priv->sleep_signal_id)
|
||||||
|
g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
|
||||||
|
g_cancellable_cancel (priv->cancellable);
|
||||||
|
g_clear_object (&priv->cancellable);
|
||||||
|
g_clear_object (&priv->system_bus);
|
||||||
|
|
||||||
if (priv->device_update_idle_id)
|
if (priv->device_update_idle_id)
|
||||||
g_source_remove (priv->device_update_idle_id);
|
g_source_remove (priv->device_update_idle_id);
|
||||||
|
|
||||||
@ -592,6 +604,61 @@ meta_backend_create_renderer (MetaBackend *backend,
|
|||||||
return META_BACKEND_GET_CLASS (backend)->create_renderer (backend, error);
|
return META_BACKEND_GET_CLASS (backend)->create_renderer (backend, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lid_is_closed_changed_cb (UpClient *client,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
if (up_client_get_lid_is_closed (client))
|
||||||
|
return;
|
||||||
|
|
||||||
|
meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
prepare_for_sleep_cb (GDBusConnection *connection,
|
||||||
|
const gchar *sender_name,
|
||||||
|
const gchar *object_path,
|
||||||
|
const gchar *interface_name,
|
||||||
|
const gchar *signal_name,
|
||||||
|
GVariant *parameters,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gboolean suspending;
|
||||||
|
|
||||||
|
g_variant_get (parameters, "(b)", &suspending);
|
||||||
|
if (suspending)
|
||||||
|
return;
|
||||||
|
meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
system_bus_gotten_cb (GObject *object,
|
||||||
|
GAsyncResult *res,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MetaBackendPrivate *priv;
|
||||||
|
GDBusConnection *bus;
|
||||||
|
|
||||||
|
bus = g_bus_get_finish (res, NULL);
|
||||||
|
if (!bus)
|
||||||
|
return;
|
||||||
|
|
||||||
|
priv = meta_backend_get_instance_private (user_data);
|
||||||
|
priv->system_bus = bus;
|
||||||
|
priv->sleep_signal_id =
|
||||||
|
g_dbus_connection_signal_subscribe (priv->system_bus,
|
||||||
|
"org.freedesktop.login1",
|
||||||
|
"org.freedesktop.login1.Manager",
|
||||||
|
"PrepareForSleep",
|
||||||
|
"/org/freedesktop/login1",
|
||||||
|
NULL,
|
||||||
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
|
prepare_for_sleep_cb,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_backend_initable_init (GInitable *initable,
|
meta_backend_initable_init (GInitable *initable,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
@ -621,6 +688,16 @@ meta_backend_initable_init (GInitable *initable,
|
|||||||
|
|
||||||
priv->dnd = g_object_new (META_TYPE_DND, NULL);
|
priv->dnd = g_object_new (META_TYPE_DND, NULL);
|
||||||
|
|
||||||
|
priv->up_client = up_client_new ();
|
||||||
|
g_signal_connect (priv->up_client, "notify::lid-is-closed",
|
||||||
|
G_CALLBACK (lid_is_closed_changed_cb), NULL);
|
||||||
|
|
||||||
|
priv->cancellable = g_cancellable_new ();
|
||||||
|
g_bus_get (G_BUS_TYPE_SYSTEM,
|
||||||
|
priv->cancellable,
|
||||||
|
system_bus_gotten_cb,
|
||||||
|
backend);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +60,6 @@ struct _MetaBackendNativePrivate
|
|||||||
{
|
{
|
||||||
MetaLauncher *launcher;
|
MetaLauncher *launcher;
|
||||||
MetaBarrierManagerNative *barrier_manager;
|
MetaBarrierManagerNative *barrier_manager;
|
||||||
UpClient *up_client;
|
|
||||||
guint sleep_signal_id;
|
|
||||||
GCancellable *cancellable;
|
|
||||||
GDBusConnection *system_bus;
|
|
||||||
};
|
};
|
||||||
typedef struct _MetaBackendNativePrivate MetaBackendNativePrivate;
|
typedef struct _MetaBackendNativePrivate MetaBackendNativePrivate;
|
||||||
|
|
||||||
@ -85,69 +81,9 @@ meta_backend_native_finalize (GObject *object)
|
|||||||
|
|
||||||
meta_launcher_free (priv->launcher);
|
meta_launcher_free (priv->launcher);
|
||||||
|
|
||||||
g_object_unref (priv->up_client);
|
|
||||||
if (priv->sleep_signal_id)
|
|
||||||
g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
|
|
||||||
g_cancellable_cancel (priv->cancellable);
|
|
||||||
g_clear_object (&priv->cancellable);
|
|
||||||
g_clear_object (&priv->system_bus);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
prepare_for_sleep_cb (GDBusConnection *connection,
|
|
||||||
const gchar *sender_name,
|
|
||||||
const gchar *object_path,
|
|
||||||
const gchar *interface_name,
|
|
||||||
const gchar *signal_name,
|
|
||||||
GVariant *parameters,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
gboolean suspending;
|
|
||||||
g_variant_get (parameters, "(b)", &suspending);
|
|
||||||
if (suspending)
|
|
||||||
return;
|
|
||||||
meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
system_bus_gotten_cb (GObject *object,
|
|
||||||
GAsyncResult *res,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
MetaBackendNativePrivate *priv;
|
|
||||||
GDBusConnection *bus;
|
|
||||||
|
|
||||||
bus = g_bus_get_finish (res, NULL);
|
|
||||||
if (!bus)
|
|
||||||
return;
|
|
||||||
|
|
||||||
priv = meta_backend_native_get_instance_private (META_BACKEND_NATIVE (user_data));
|
|
||||||
priv->system_bus = bus;
|
|
||||||
priv->sleep_signal_id = g_dbus_connection_signal_subscribe (priv->system_bus,
|
|
||||||
"org.freedesktop.login1",
|
|
||||||
"org.freedesktop.login1.Manager",
|
|
||||||
"PrepareForSleep",
|
|
||||||
"/org/freedesktop/login1",
|
|
||||||
NULL,
|
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
|
||||||
prepare_for_sleep_cb,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
lid_is_closed_changed_cb (UpClient *client,
|
|
||||||
GParamSpec *pspec,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
if (up_client_get_lid_is_closed (client))
|
|
||||||
return;
|
|
||||||
|
|
||||||
meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
constrain_to_barriers (ClutterInputDevice *device,
|
constrain_to_barriers (ClutterInputDevice *device,
|
||||||
guint32 time,
|
guint32 time,
|
||||||
@ -627,16 +563,6 @@ meta_backend_native_init (MetaBackendNative *native)
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv->barrier_manager = meta_barrier_manager_native_new ();
|
priv->barrier_manager = meta_barrier_manager_native_new ();
|
||||||
|
|
||||||
priv->up_client = up_client_new ();
|
|
||||||
g_signal_connect (priv->up_client, "notify::lid-is-closed",
|
|
||||||
G_CALLBACK (lid_is_closed_changed_cb), NULL);
|
|
||||||
|
|
||||||
priv->cancellable = g_cancellable_new ();
|
|
||||||
g_bus_get (G_BUS_TYPE_SYSTEM,
|
|
||||||
priv->cancellable,
|
|
||||||
system_bus_gotten_cb,
|
|
||||||
native);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaLauncher *
|
MetaLauncher *
|
||||||
|
Loading…
Reference in New Issue
Block a user