Merge branch 'have-more-fun-developing-squeekboard' into 'master'
main: Add debug flags to always show squeekboard on start and to activate GTK inspector See merge request World/Phosh/squeekboard!485
This commit is contained in:
10
README.md
10
README.md
@ -71,6 +71,16 @@ To make the keyboard show you can use either an application that does so automat
|
||||
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
|
||||
```
|
||||
|
||||
Environment Variables
|
||||
---------------------
|
||||
|
||||
Besides the environment variables supported by GTK and [GLib](https://docs.gtk.org/glib/running.html) applications
|
||||
squeekboard honors the `SQUEEKBOARD_DEBUG` environment variable which can
|
||||
contain a comma separated list of:
|
||||
|
||||
- `force-show` : Show squeekboard on startup independent of any gsettings or compositor requests
|
||||
- `gtk-inspector`: Spawn [gtk-inspector](https://wiki.gnome.org/Projects/GTK/Inspector)
|
||||
|
||||
### What the compositor has to support
|
||||
|
||||
A compatible compositor has to support the protocols:
|
||||
|
||||
@ -38,6 +38,13 @@
|
||||
#include <gdk/gdkwayland.h>
|
||||
|
||||
|
||||
typedef enum _SqueekboardDebugFlags {
|
||||
SQUEEKBOARD_DEBUG_FLAG_NONE = 0,
|
||||
SQUEEKBOARD_DEBUG_FLAG_FORCE_SHOW = 1 << 0,
|
||||
SQUEEKBOARD_DEBUG_FLAG_GTK_INSPECTOR = 1 << 1,
|
||||
} SqueekboardDebugFlags;
|
||||
|
||||
|
||||
/// Global application state
|
||||
struct squeekboard {
|
||||
struct squeek_wayland wayland; // Just hooks.
|
||||
@ -75,13 +82,16 @@ on_name_lost (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
SqueekboardDebugFlags *flags = user_data;
|
||||
// TODO: could conceivable continue working
|
||||
// if intrnal changes stop sending dbus changes
|
||||
(void)connection;
|
||||
(void)name;
|
||||
(void)user_data;
|
||||
g_warning("DBus unavailable, unclear how to continue. Is Squeekboard already running?");
|
||||
exit (1);
|
||||
if ((*flags & SQUEEKBOARD_DEBUG_FLAG_FORCE_SHOW) == 0) {
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
// Wayland
|
||||
@ -271,9 +281,36 @@ phosh_theme_init (void)
|
||||
}
|
||||
|
||||
|
||||
static GDebugKey debug_keys[] =
|
||||
{
|
||||
{ .key = "force-show",
|
||||
.value = SQUEEKBOARD_DEBUG_FLAG_FORCE_SHOW,
|
||||
},
|
||||
{ .key = "gtk-inspector",
|
||||
.value = SQUEEKBOARD_DEBUG_FLAG_GTK_INSPECTOR,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
static SqueekboardDebugFlags
|
||||
parse_debug_env (void)
|
||||
{
|
||||
const char *debugenv;
|
||||
SqueekboardDebugFlags flags = SQUEEKBOARD_DEBUG_FLAG_NONE;
|
||||
|
||||
debugenv = g_getenv("SQUEEKBOARD_DEBUG");
|
||||
if (!debugenv) {
|
||||
return flags;
|
||||
}
|
||||
|
||||
return g_parse_debug_string(debugenv, debug_keys, G_N_ELEMENTS (debug_keys));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
SqueekboardDebugFlags debug_flags = SQUEEKBOARD_DEBUG_FLAG_NONE;
|
||||
g_autoptr (GError) err = NULL;
|
||||
g_autoptr(GOptionContext) opt_context = NULL;
|
||||
|
||||
@ -294,6 +331,7 @@ main (int argc, char **argv)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
debug_flags = parse_debug_env ();
|
||||
eek_init ();
|
||||
|
||||
phosh_theme_init ();
|
||||
@ -365,7 +403,7 @@ main (int argc, char **argv)
|
||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
on_name_acquired,
|
||||
on_name_lost,
|
||||
NULL,
|
||||
&debug_flags,
|
||||
NULL);
|
||||
if (owner_id == 0) {
|
||||
g_printerr ("Can't own the name\n");
|
||||
@ -403,6 +441,13 @@ main (int argc, char **argv)
|
||||
|
||||
session_register();
|
||||
|
||||
if (debug_flags & SQUEEKBOARD_DEBUG_FLAG_FORCE_SHOW) {
|
||||
server_context_service_force_show_keyboard (ui_context);
|
||||
}
|
||||
if (debug_flags & SQUEEKBOARD_DEBUG_FLAG_GTK_INSPECTOR) {
|
||||
gtk_window_set_interactive_debugging (TRUE);
|
||||
}
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
g_main_loop_run (loop);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user