diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-21 17:05:53 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-21 17:06:46 -0400 |
| commit | d14aed4f47a3604cdc36431760dd8a33e10e4e45 (patch) | |
| tree | 1cd0ffcf8653048a4f0fada6ae3328cc6bc71808 /area_unix.go | |
| parent | bf3a692b2184500efa785253759440128ed3a059 (diff) | |
Added code to the GTK+ Area to print the GdkKeymapKeys for a given key value. For GTK+/X11 it appears that we can just use the keyval field... that just leaves GTK+/Wayland (see previous commit). If the same applies, we'll need to see if I can feed artificial keycodes in and it'll still work as expected...
Diffstat (limited to 'area_unix.go')
| -rw-r--r-- | area_unix.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/area_unix.go b/area_unix.go index f5df5b4..54a4e76 100644 --- a/area_unix.go +++ b/area_unix.go @@ -161,6 +161,7 @@ var area_motion_notify_event_callback = C.GCallback(C.our_area_motion_notify_eve func our_area_key_press_event_callback(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer) C.gboolean { e := (*C.GdkEventKey)(unsafe.Pointer(event)) fmt.Printf("PRESS %#v\n", e) + pk(e.keyval, e.window) return C.FALSE // TODO really false? } @@ -170,7 +171,28 @@ var area_key_press_event_callback = C.GCallback(C.our_area_key_press_event_callb func our_area_key_release_event_callback(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer) C.gboolean { e := (*C.GdkEventKey)(unsafe.Pointer(event)) fmt.Printf("RELEASE %#v\n", e) + pk(e.keyval, e.window) return C.FALSE // TODO really false? } var area_key_release_event_callback = C.GCallback(C.our_area_key_release_event_callback) + +func pk(keyval C.guint, window *C.GdkWindow) { + var kk *C.GdkKeymapKey + var nk C.gint + + km := C.gdk_keymap_get_for_display(C.gdk_window_get_display(window)) + b := C.gdk_keymap_get_entries_for_keyval(km, keyval, &kk, &nk) + if b == C.FALSE { + fmt.Println("(no key equivalent)") + return + } + ok := kk + for i := C.gint(0); i < nk; i++ { + fmt.Println("equiv %d/%d: %#v\n", i + 1, nk, kk) + xkk := uintptr(unsafe.Pointer(kk)) + xkk += unsafe.Sizeof(kk) + kk = (*C.GdkKeymapKey)(unsafe.Pointer(xkk)) + } + C.g_free(C.gpointer(unsafe.Pointer(ok))) +} |
