debug-control: Add InhibitHwCursor property
Inhibits the hardware cursor globally when true. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
This commit is contained in:
parent
b97516edb9
commit
ea9e8bff2d
@ -11,6 +11,7 @@
|
||||
<property name="ForceLinearBlending" type="b" access="readwrite" />
|
||||
<property name="LuminancePercentage" type="u" access="readwrite" />
|
||||
<property name="SessionManagementProtocol" type="b" access="readwrite" />
|
||||
<property name="InhibitHwCursor" type="b" access="readwrite" />
|
||||
|
||||
</interface>
|
||||
|
||||
|
@ -220,6 +220,7 @@ void meta_backend_inhibit_hw_cursor (MetaBackend *backend);
|
||||
|
||||
void meta_backend_uninhibit_hw_cursor (MetaBackend *backend);
|
||||
|
||||
META_EXPORT_TEST
|
||||
gboolean meta_backend_is_hw_cursors_inhibited (MetaBackend *backend);
|
||||
|
||||
void meta_backend_update_from_event (MetaBackend *backend,
|
||||
|
@ -72,6 +72,7 @@
|
||||
#include "clutter/clutter-seat-private.h"
|
||||
#include "compositor/meta-dnd-private.h"
|
||||
#include "core/meta-context-private.h"
|
||||
#include "core/meta-debug-control-private.h"
|
||||
#include "meta/main.h"
|
||||
#include "meta/meta-backend.h"
|
||||
#include "meta/meta-context.h"
|
||||
@ -169,6 +170,7 @@ struct _MetaBackendPrivate
|
||||
GList *gpus;
|
||||
GList *hw_cursor_inhibitors;
|
||||
int global_hw_cursor_inhibitors;
|
||||
gboolean debug_inhibit_hw_cursor;
|
||||
|
||||
gboolean in_init;
|
||||
|
||||
@ -1186,6 +1188,27 @@ init_stage (MetaBackend *backend)
|
||||
META_BACKEND_GET_CLASS (backend)->select_stage_events (backend);
|
||||
}
|
||||
|
||||
static void
|
||||
on_debug_control_inhibit_hw_cursor_changed (MetaDebugControl *debug_control,
|
||||
GParamSpec *pspec,
|
||||
MetaBackend *backend)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
gboolean should_inhibit_hw_cursor;
|
||||
|
||||
should_inhibit_hw_cursor =
|
||||
meta_debug_control_is_hw_cursor_inhibited (debug_control);
|
||||
if (should_inhibit_hw_cursor == priv->debug_inhibit_hw_cursor)
|
||||
return;
|
||||
|
||||
priv->debug_inhibit_hw_cursor = should_inhibit_hw_cursor;
|
||||
|
||||
if (should_inhibit_hw_cursor)
|
||||
meta_backend_inhibit_hw_cursor (backend);
|
||||
else
|
||||
meta_backend_uninhibit_hw_cursor (backend);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_backend_initable_init (GInitable *initable,
|
||||
GCancellable *cancellable,
|
||||
@ -1193,6 +1216,7 @@ meta_backend_initable_init (GInitable *initable,
|
||||
{
|
||||
MetaBackend *backend = META_BACKEND (initable);
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
MetaDebugControl *debug_control;
|
||||
|
||||
priv->in_init = TRUE;
|
||||
|
||||
@ -1215,6 +1239,11 @@ meta_backend_initable_init (GInitable *initable,
|
||||
|
||||
priv->cursor_tracker = meta_backend_create_cursor_tracker (backend);
|
||||
|
||||
debug_control = meta_context_get_debug_control (priv->context);
|
||||
g_signal_connect (debug_control, "notify::inhibit-hw-cursor",
|
||||
G_CALLBACK (on_debug_control_inhibit_hw_cursor_changed),
|
||||
backend);
|
||||
|
||||
if (META_BACKEND_GET_CLASS (backend)->is_lid_closed ==
|
||||
meta_backend_real_is_lid_closed)
|
||||
{
|
||||
|
@ -31,3 +31,5 @@ gboolean meta_debug_control_is_hdr_forced (MetaDebugControl *debug_control);
|
||||
unsigned int meta_debug_control_get_luminance_percentage (MetaDebugControl *debug_control);
|
||||
|
||||
gboolean meta_debug_control_is_session_management_protocol_enabled (MetaDebugControl *debug_control);
|
||||
|
||||
gboolean meta_debug_control_is_hw_cursor_inhibited (MetaDebugControl *debug_control);
|
||||
|
@ -171,6 +171,7 @@ meta_debug_control_init (MetaDebugControl *debug_control)
|
||||
gboolean enable_hdr, force_hdr, force_linear_blending,
|
||||
color_management_protocol;
|
||||
gboolean session_management_protocol;
|
||||
gboolean inhibit_hw_cursor;
|
||||
|
||||
color_management_protocol =
|
||||
g_strcmp0 (getenv ("MUTTER_DEBUG_COLOR_MANAGEMENT_PROTOCOL"), "1") == 0;
|
||||
@ -194,6 +195,11 @@ meta_debug_control_init (MetaDebugControl *debug_control)
|
||||
g_strcmp0 (getenv ("MUTTER_DEBUG_SESSION_MANAGEMENT_PROTOCOL"), "1") == 0;
|
||||
meta_dbus_debug_control_set_session_management_protocol (dbus_debug_control,
|
||||
session_management_protocol);
|
||||
|
||||
inhibit_hw_cursor =
|
||||
g_strcmp0 (getenv ("MUTTER_DEBUG_INHIBIT_HW_CURSOR"), "1") == 0;
|
||||
meta_dbus_debug_control_set_inhibit_hw_cursor (dbus_debug_control,
|
||||
inhibit_hw_cursor);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -278,3 +284,12 @@ meta_debug_control_set_exported (MetaDebugControl *debug_control,
|
||||
debug_control->exported = exported;
|
||||
g_object_notify_by_pspec (G_OBJECT (debug_control), obj_props[PROP_EXPORTED]);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_debug_control_is_hw_cursor_inhibited (MetaDebugControl *debug_control)
|
||||
{
|
||||
MetaDBusDebugControl *dbus_debug_control =
|
||||
META_DBUS_DEBUG_CONTROL (debug_control);
|
||||
|
||||
return meta_dbus_debug_control_get_inhibit_hw_cursor (dbus_debug_control);
|
||||
}
|
||||
|
112
src/tests/debug-control-tests.c
Normal file
112
src/tests/debug-control-tests.c
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "meta-test/meta-context-test.h"
|
||||
|
||||
static MetaContext *test_context;
|
||||
|
||||
static void
|
||||
call_cb (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (GVariant) ret = NULL;
|
||||
gboolean *done = user_data;
|
||||
|
||||
ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
|
||||
res,
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
*done = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
set_inhibit_hw_curor_via_dbus (GDBusProxy *proxy,
|
||||
gboolean inhibit)
|
||||
{
|
||||
gboolean done = FALSE;
|
||||
|
||||
g_dbus_proxy_call (proxy,
|
||||
"Set",
|
||||
g_variant_new ("(ssv)",
|
||||
"org.gnome.Mutter.DebugControl",
|
||||
"InhibitHwCursor",
|
||||
g_variant_new_boolean (inhibit)),
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||
-1,
|
||||
NULL,
|
||||
&call_cb,
|
||||
&done);
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_debug_control_inhibit_hw_cursor (void)
|
||||
{
|
||||
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (GDBusProxy) proxy = NULL;
|
||||
g_autoptr (GVariant) ret = NULL;
|
||||
|
||||
g_assert_false (meta_backend_is_hw_cursors_inhibited (backend));
|
||||
|
||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
NULL,
|
||||
"org.gnome.Mutter.DebugControl",
|
||||
"/org/gnome/Mutter/DebugControl",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
NULL,
|
||||
&error);
|
||||
g_assert_nonnull (proxy);
|
||||
g_assert_no_error (error);
|
||||
|
||||
set_inhibit_hw_curor_via_dbus (proxy, TRUE);
|
||||
g_assert_true (meta_backend_is_hw_cursors_inhibited (backend));
|
||||
set_inhibit_hw_curor_via_dbus (proxy, FALSE);
|
||||
g_assert_false (meta_backend_is_hw_cursors_inhibited (backend));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (MetaContext) context = NULL;
|
||||
MetaDebugControl *debug_control;
|
||||
|
||||
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_TEST,
|
||||
META_CONTEXT_TEST_FLAG_NO_X11);
|
||||
g_assert_true (meta_context_configure (context, &argc, &argv, NULL));
|
||||
|
||||
debug_control = meta_context_get_debug_control (context);
|
||||
meta_debug_control_set_exported (debug_control, TRUE);
|
||||
|
||||
test_context = context;
|
||||
|
||||
g_test_add_func ("/debug-control/inhibit-hw-cursor",
|
||||
meta_test_debug_control_inhibit_hw_cursor);
|
||||
|
||||
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
|
||||
META_TEST_RUN_FLAG_NONE);
|
||||
}
|
@ -318,6 +318,11 @@ test_cases += [
|
||||
'suite': 'backend',
|
||||
'sources': [ 'stage-tests.c', ],
|
||||
},
|
||||
{
|
||||
'name': 'debug-control',
|
||||
'suite': 'core',
|
||||
'sources': [ 'debug-control-tests.c', ],
|
||||
},
|
||||
]
|
||||
|
||||
screen_cast_client = executable('mutter-screen-cast-client',
|
||||
|
Loading…
x
Reference in New Issue
Block a user