diff --git a/showmethekey-gtk/meson.build b/showmethekey-gtk/meson.build
index ea4e45b..d143d4f 100644
--- a/showmethekey-gtk/meson.build
+++ b/showmethekey-gtk/meson.build
@@ -36,8 +36,9 @@ cairo = dependency('cairo', required: true)
pango = dependency('pango', required: true)
xkbcommon = dependency('xkbcommon', required: true)
xkbregistry = dependency('xkbregistry', required: true)
+gtk4_layer_shell = dependency('gtk4-layer-shell-0', required: true)
gtk_dependencies += [
- gtk, libadw, x11, glib, json_glib, gio, cairo, pango, xkbcommon, xkbregistry
+ gtk, libadw, x11, glib, json_glib, gio, cairo, pango, xkbcommon, xkbregistry, gtk4_layer_shell
]
# For config.h.
gtk_include_directories += include_directories('../')
diff --git a/showmethekey-gtk/smtk-app-win.ui b/showmethekey-gtk/smtk-app-win.ui
index cd5318a..94bc1eb 100644
--- a/showmethekey-gtk/smtk-app-win.ui
+++ b/showmethekey-gtk/smtk-app-win.ui
@@ -24,10 +24,10 @@
false
center
+ name="notify::active"
+ handler="smtk_app_win_on_keys_win_switch_active"
+ object="SmtkAppWin"
+ swapped="yes" />
@@ -42,7 +42,8 @@
-
@@ -117,17 +120,18 @@
true
Show _Keyboard Key
- Maybe some users don't want keyboard keys.
+ Maybe some users don't want
+ keyboard keys.
keyboard_switch
- center
- true
-
+ center
+ true
+
@@ -136,17 +140,18 @@
true
Show _Mouse Button
- Mouse buttons can be very annoying.
+ Mouse buttons can be very
+ annoying.
mouse_switch
center
true
+ name="notify::active"
+ handler="smtk_app_win_on_mouse_switch_active"
+ object="SmtkAppWin"
+ swapped="yes" />
@@ -155,44 +160,46 @@
true
Draw Keys _Border
- In case keys and key combos are hard to distinguish.
+ In case keys and key combos are
+ hard to distinguish.
border_switch
center
true
+ name="notify::active"
+ handler="smtk_app_win_on_border_switch_active"
+ object="SmtkAppWin"
+ swapped="yes" />
+
+
+
+
+
+
+ true
+ Hide _Visible Keys
+ Only show keys with modifiers.
+ hide_visible_switch
+
+
+ center
+ false
+
-
-
- true
- Hide _Visible Keys
- Only show keys with modifiers.
- hide_visible_switch
-
-
- center
- false
-
-
-
-
-
Display Mode
- Raw is Linux kernel's scancode and maybe not so useful.
+ Raw is Linux kernel's scancode
+ and maybe not so useful.
0
@@ -205,38 +212,40 @@
+ name="notify::selected"
+ handler="smtk_app_win_on_mode_selector_selected"
+ object="SmtkAppWin"
+ swapped="yes" />
+
+
+
+
+ Alignment Mode
+ Some users prefer to display
+ keys in center.
+
+ 0
+
+
+
+ - End
+ - Center
+
+
+
+
-
-
- Alignment Mode
- Some users prefer to display keys in center.
-
- 0
-
-
-
- - End
- - Center
-
-
-
-
-
-
true
Timeout (ms)
- Clear keys if no new key after how many miliscconds. Set to 0 to keep all keys.
+ Clear keys if no new key after
+ how many miliscconds. Set to 0 to keep all keys.
timeout_entry
@@ -245,10 +254,10 @@
0
0
+ name="notify::value"
+ handler="smtk_app_win_on_timeout_value"
+ object="SmtkAppWin"
+ swapped="yes" />
@@ -294,14 +303,15 @@
true
Keymap
- Choose your keyboard layout and variant.
+ Choose your keyboard layout and
+ variant.
0
+ name="notify::selected"
+ handler="smtk_app_win_on_keymap_selector_selected"
+ object="SmtkAppWin"
+ swapped="yes" />
@@ -313,4 +323,4 @@
-
+
\ No newline at end of file
diff --git a/showmethekey-gtk/smtk-keys-win.c b/showmethekey-gtk/smtk-keys-win.c
index 46eacbf..9bf3efa 100644
--- a/showmethekey-gtk/smtk-keys-win.c
+++ b/showmethekey-gtk/smtk-keys-win.c
@@ -6,6 +6,7 @@
#endif
#include "smtk.h"
+#include "gtk4-layer-shell.h"
#include "smtk-keys-win.h"
struct _SmtkKeysWin {
@@ -334,8 +335,16 @@ static void smtk_keys_win_init(SmtkKeysWin *win)
// Don't know why but realize does not work.
g_signal_connect(GTK_WIDGET(win), "map",
G_CALLBACK(smtk_keys_win_on_map), NULL);
-}
+ GtkWindow* gtk_window = GTK_WINDOW(win);
+ // Create a layer shell surface instead of a normal floating window
+ gtk_layer_init_for_window(gtk_window);
+ // Make the layer appear on top of normal windows
+ gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_TOP);
+ gtk_layer_set_anchor(gtk_window, GTK_LAYER_SHELL_EDGE_BOTTOM, true);
+ gtk_layer_set_anchor(gtk_window, GTK_LAYER_SHELL_EDGE_RIGHT, true);
+ gtk_layer_set_anchor(gtk_window, GTK_LAYER_SHELL_EDGE_LEFT, true);
+}
static void smtk_keys_win_constructed(GObject *object)
{
// Seems we can only get constructor properties here.
@@ -344,16 +353,6 @@ static void smtk_keys_win_constructed(GObject *object)
win->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
adw_window_set_content(ADW_WINDOW(win), win->box);
- // Allow user to choose position by drag this.
- win->header_bar = adw_header_bar_new();
- adw_header_bar_set_show_start_title_buttons(
- ADW_HEADER_BAR(win->header_bar), false);
- adw_header_bar_set_show_end_title_buttons(
- ADW_HEADER_BAR(win->header_bar), false);
- win->handle = adw_window_title_new(_("Clickable"), NULL);
- adw_header_bar_set_title_widget(ADW_HEADER_BAR(win->header_bar),
- win->handle);
- gtk_box_append(GTK_BOX(win->box), win->header_bar);
win->emitter = smtk_keys_emitter_new(win->show_shift,
win->show_keyboard,
@@ -381,7 +380,6 @@ static void smtk_keys_win_constructed(GObject *object)
win->area = smtk_keys_area_new(win->mode, win->alignment,
win->draw_border, win->timeout);
gtk_box_append(GTK_BOX(win->box), win->area);
-
out:
G_OBJECT_CLASS(smtk_keys_win_parent_class)->constructed(object);
}