Add an OSD for sticky modifiers

This commit adds an OSD that displays which modifiers are
currently latched or locked. This is commonly used together
with sticky keys.
https://bugzilla.gnome.org/show_bug.cgi?id=647711
This commit is contained in:
Matthias Clasen
2013-04-14 00:05:39 -04:00
parent f358bb1a96
commit 96994721ef
6 changed files with 149 additions and 0 deletions

View File

@ -35,6 +35,7 @@
#include <gjs/gjs.h>
#include <meta/display.h>
#include <meta/meta-plugin.h>
#include <X11/XKBlib.h>
#include "shell-global-private.h"
#include "shell-perf-log.h"
@ -101,6 +102,9 @@ struct _GnomeShellPlugin
guint have_swap_event : 1;
CoglContext *cogl_context;
int xkb_event_base;
XkbDescPtr xkb;
ShellGlobal *global;
};
@ -187,6 +191,10 @@ gnome_shell_plugin_start (MetaPlugin *plugin)
int status;
GjsContext *gjs_context;
ClutterBackend *backend;
MetaScreen *screen;
MetaDisplay *display;
Display *xdisplay;
int xkb_base_error_type, xkb_opcode;
backend = clutter_get_default_backend ();
shell_plugin->cogl_context = clutter_backend_get_cogl_context (backend);
@ -199,6 +207,26 @@ gnome_shell_plugin_start (MetaPlugin *plugin)
"GL buffer swap complete event received (with timestamp of completion)",
"x");
screen = meta_plugin_get_screen (META_PLUGIN (shell_plugin));
display = meta_screen_get_display (screen);
xdisplay = meta_display_get_xdisplay (display);
if (!XkbQueryExtension (xdisplay, &xkb_opcode,
&shell_plugin->xkb_event_base,
&xkb_base_error_type,
NULL, NULL))
{
shell_plugin->xkb_event_base = -1;
g_message ("could not find XKB extension.");
}
else
{
shell_plugin->xkb = XkbGetMap (xdisplay,
XkbAllComponentsMask,
XkbUseCoreKbd);
XkbSelectEvents (xdisplay, XkbUseCoreKbd,
XkbAllEventsMask, XkbAllEventsMask);
}
shell_plugin->global = shell_global_get ();
_shell_global_set_plugin (shell_plugin->global, META_PLUGIN (shell_plugin));
@ -389,6 +417,10 @@ gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
if (_shell_global_check_xdnd_event (shell_plugin->global, xev))
return TRUE;
if (xev->type == shell_plugin->xkb_event_base &&
_shell_global_check_xkb_event (shell_plugin->global, xev))
return TRUE;
return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
}