Fixed keys handling for multilayout environments.
There is a bug in GTK+ that does not allow capturing shortcuts using letter keys on layouts other than "us". The bug is there for ages and there is probably no hope that it will get fixed. This patch switches shortcut handling method to GtkAccelGroup, which handles this case correctly. Enjoy! Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
dcb4f81ad2
commit
bccfe2a9a5
30
surf.c
30
surf.c
|
@ -80,6 +80,7 @@ static gboolean usingproxy = 0;
|
||||||
static char togglestat[6];
|
static char togglestat[6];
|
||||||
static char pagestat[3];
|
static char pagestat[3];
|
||||||
|
|
||||||
|
static void add_accels(Client *c);
|
||||||
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
|
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
|
||||||
WebKitWebResource *r, WebKitNetworkRequest *req,
|
WebKitWebResource *r, WebKitNetworkRequest *req,
|
||||||
WebKitNetworkResponse *resp, gpointer d);
|
WebKitNetworkResponse *resp, gpointer d);
|
||||||
|
@ -124,7 +125,9 @@ static gboolean inspector_show(WebKitWebInspector *i, Client *c);
|
||||||
static gboolean inspector_close(WebKitWebInspector *i, Client *c);
|
static gboolean inspector_close(WebKitWebInspector *i, Client *c);
|
||||||
static void inspector_finished(WebKitWebInspector *i, Client *c);
|
static void inspector_finished(WebKitWebInspector *i, Client *c);
|
||||||
|
|
||||||
static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
|
static gboolean keypress(GtkAccelGroup *group,
|
||||||
|
GObject *obj, guint key, GdkModifierType mods,
|
||||||
|
Client *c);
|
||||||
static void linkhover(WebKitWebView *v, const char* t, const char* l,
|
static void linkhover(WebKitWebView *v, const char* t, const char* l,
|
||||||
Client *c);
|
Client *c);
|
||||||
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec,
|
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec,
|
||||||
|
@ -165,6 +168,18 @@ static void zoom(Client *c, const Arg *arg);
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_accels(Client *c) {
|
||||||
|
int i;
|
||||||
|
GtkAccelGroup *group = gtk_accel_group_new();
|
||||||
|
for(i = 0; i < LENGTH(keys); i++) {
|
||||||
|
GClosure *closure = g_cclosure_new(G_CALLBACK(keypress), c, NULL);
|
||||||
|
gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod,
|
||||||
|
0, closure);
|
||||||
|
}
|
||||||
|
gtk_window_add_accel_group(GTK_WINDOW(c->win), group);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
|
beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
|
||||||
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
|
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
|
||||||
|
@ -514,14 +529,17 @@ inspector_finished(WebKitWebInspector *i, Client *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
|
keypress(GtkAccelGroup *group, GObject *obj,
|
||||||
|
guint key, GdkModifierType mods, Client *c) {
|
||||||
guint i;
|
guint i;
|
||||||
gboolean processed = FALSE;
|
gboolean processed = FALSE;
|
||||||
|
|
||||||
|
mods = CLEANMASK(mods);
|
||||||
|
key = gdk_keyval_to_lower(key);
|
||||||
updatewinid(c);
|
updatewinid(c);
|
||||||
for(i = 0; i < LENGTH(keys); i++) {
|
for(i = 0; i < LENGTH(keys); i++) {
|
||||||
if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
|
if(key == keys[i].keyval
|
||||||
&& CLEANMASK(ev->state) == keys[i].mod
|
&& mods == keys[i].mod
|
||||||
&& keys[i].func) {
|
&& keys[i].func) {
|
||||||
keys[i].func(c, &(keys[i].arg));
|
keys[i].func(c, &(keys[i].arg));
|
||||||
processed = TRUE;
|
processed = TRUE;
|
||||||
|
@ -646,9 +664,7 @@ newclient(void) {
|
||||||
"destroy",
|
"destroy",
|
||||||
G_CALLBACK(destroywin), c);
|
G_CALLBACK(destroywin), c);
|
||||||
if(!kioskmode) {
|
if(!kioskmode) {
|
||||||
g_signal_connect(G_OBJECT(c->win),
|
add_accels(c);
|
||||||
"key-press-event",
|
|
||||||
G_CALLBACK(keypress), c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pane */
|
/* Pane */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user