aboutsummaryrefslogtreecommitdiff
path: root/fbxkb.c
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-10-10 09:37:23 -0400
committerB. Stack <bgstack15@gmail.com>2022-10-10 09:40:10 -0400
commit05cb68aea07da213285a41c49e5e6c9c9de16f74 (patch)
tree37b6b4a19c943ff0d0bba45207a98948c4796dac /fbxkb.c
parentswap left<-->middle click on tray icon (diff)
downloadfbxkb-05cb68aea07da213285a41c49e5e6c9c9de16f74.tar.gz
fbxkb-05cb68aea07da213285a41c49e5e6c9c9de16f74.tar.bz2
fbxkb-05cb68aea07da213285a41c49e5e6c9c9de16f74.zip
allow scrolling over icon, and fix segfault
when input method does not have a parenthetical value appended
Diffstat (limited to 'fbxkb.c')
-rw-r--r--fbxkb.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/fbxkb.c b/fbxkb.c
index 651ac3c..fb5f665 100644
--- a/fbxkb.c
+++ b/fbxkb.c
@@ -205,6 +205,12 @@ static void docklet_destroyed(GtkWidget *widget, void *data)
RET();
}
+int scroll_input_method(int no) {
+ no = (cur_group + no) % ngroups;
+ DBG("no=%d\n", no);
+ XkbLockGroup(dpy, XkbUseCoreKbd, no);
+ return no;
+}
void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data)
{
@@ -214,11 +220,7 @@ void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data)
RET();
if (event->button == 2) {
- int no;
-
- no = (cur_group + 1) % ngroups;
- DBG("no=%d\n", no);
- XkbLockGroup(dpy, XkbUseCoreKbd, no);
+ scroll_input_method(1);
} else if (event->button == 1) {
gtk_menu_popup(GTK_MENU(flag_menu), NULL, NULL, NULL, NULL, event->button, event->time);
} else if (event->button == 3) {
@@ -227,6 +229,26 @@ void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data)
RET();
}
+void docklet_scrolled(GtkWidget *button, GdkEventScroll *event, void *data) {
+ char *i = NULL;
+ int no = 0;
+ switch (event->direction) {
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_LEFT:
+ i = "up";
+ no = -1;
+ break;
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_RIGHT:
+ i = "down";
+ no = 1;
+ break;
+ }
+ if (i) {
+ scroll_input_method(no);
+ }
+}
+
static int
docklet_create()
{
@@ -240,6 +262,7 @@ docklet_create()
g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL);
g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL);
g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_clicked), NULL);
+ g_signal_connect(G_OBJECT(docklet), "scroll-event", G_CALLBACK(docklet_scrolled), NULL);
gtk_container_set_border_width(GTK_CONTAINER(box), 0);
@@ -373,6 +396,7 @@ read_kbd_description()
tmp2++;
tmp2[strlen(tmp2)-1] = '\0';
}
+ DBG("tmp2=%s\n", tmp2);
for (tmp = tok; isalpha(*tmp); tmp++);
*tmp = 0;
@@ -385,13 +409,16 @@ read_kbd_description()
ERR("xkb group #%d is already defined\n", no);
}
strcpy(tmp3, tok);
- strcat(tmp3,",");
- // add variant to end of string for the png lookup
- strcat(tmp3,tmp2);
+ if (tmp2 != 0) {
+ strcat(tmp3,",");
+ // add variant to end of string for the png lookup
+ strcat(tmp3,tmp2);
+ *tmp2 = 0;
+ }
+ DBG("tmp3=%s\n",tmp3);
group2info[no].sym = g_strdup(tmp3);
group2info[no].flag = sym2flag(tmp3);
group2info[no].name = XGetAtomName(dpy, kbd_desc_ptr->names->groups[no]);
- *tmp2 = 0;
*tmp3 = 0;
}
XFree(sym_name);
bgstack15