Skip to content

Commit 6d0a894

Browse files
committed
ShellClients: Introduce an OSKWindow
1 parent 9789a1d commit 6d0a894

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-5
lines changed

src/ShellClients/OSKWindow.vala

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2026 elementary, Inc. (https://elementary.io)
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*
5+
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
6+
*/
7+
8+
public class Gala.OSKWindow : ShellWindow, RootTarget {
9+
public OSKManager manager { private get; construct; }
10+
11+
public Clutter.Actor? actor { get { return (Clutter.Actor) window.get_compositor_private (); } }
12+
13+
private GestureController gesture_controller;
14+
15+
public OSKWindow (OSKManager manager, Meta.Window window) {
16+
Object (manager: manager, window: window);
17+
}
18+
19+
construct {
20+
gesture_controller = new GestureController (CUSTOM) {
21+
progress = 1
22+
};
23+
add_gesture_controller (gesture_controller);
24+
25+
window.size_changed.connect (update_target);
26+
update_target ();
27+
28+
manager.notify["visible"].connect (sync_visible);
29+
sync_visible ();
30+
}
31+
32+
private void update_target () {
33+
var actor = (Clutter.Actor) window.get_compositor_private ();
34+
hide_target = new PropertyTarget (CUSTOM, actor, "translation-y", typeof (float), 0f, actor.height);
35+
}
36+
37+
private void sync_visible () {
38+
if (manager.visible) {
39+
gesture_controller.goto (0);
40+
} else {
41+
gesture_controller.goto (1);
42+
}
43+
}
44+
45+
protected override double get_hidden_progress () {
46+
return gesture_controller.progress;
47+
}
48+
49+
protected override void get_window_position (Mtk.Rectangle window_rect, out int x, out int y) {
50+
var monitor_geom = window.display.get_monitor_geometry (manager.monitor);
51+
x = monitor_geom.x + (monitor_geom.width - window_rect.width) / 2;
52+
y = monitor_geom.y + monitor_geom.height - window_rect.height;
53+
}
54+
}

src/ShellClients/ShellClientsManager.vala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
public class Gala.ShellClientsManager : Object, GestureTarget {
99
private static ShellClientsManager instance;
1010

11-
public static void init (WindowManager wm, InputMethod im) {
11+
public static void init (WindowManager wm, InputMethod im, OSKManager osk_manager) {
1212
if (instance != null) {
1313
return;
1414
}
1515

16-
instance = new ShellClientsManager (wm, im);
16+
instance = new ShellClientsManager (wm, im, osk_manager);
1717
}
1818

1919
public static unowned ShellClientsManager? get_instance () {
@@ -22,6 +22,7 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
2222

2323
public WindowManager wm { get; construct; }
2424
public InputMethod im { get; construct; }
25+
public OSKManager osk_manager { get; construct; }
2526

2627
private NotificationsClient notifications_client;
2728
private ManagedClient[] protocol_clients = {};
@@ -31,9 +32,10 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
3132
private GLib.HashTable<Meta.Window, PanelWindow> panel_windows = new GLib.HashTable<Meta.Window, PanelWindow> (null, null);
3233
private GLib.HashTable<Meta.Window, ExtendedBehaviorWindow> positioned_windows = new GLib.HashTable<Meta.Window, ExtendedBehaviorWindow> (null, null);
3334
private IBusCandidateWindow? ibus_candidate_window = null;
35+
private OSKWindow? osk_window = null;
3436

35-
private ShellClientsManager (WindowManager wm, InputMethod im) {
36-
Object (wm: wm, im: im);
37+
private ShellClientsManager (WindowManager wm, InputMethod im, OSKManager osk_manager) {
38+
Object (wm: wm, im: im, osk_manager: osk_manager);
3739
}
3840

3941
construct {
@@ -252,6 +254,12 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
252254
window.unmanaged.connect_after (() => ibus_candidate_window = null);
253255
}
254256

257+
public void make_osk_window (Meta.Window window) requires (osk_window == null) {
258+
osk_window = new OSKWindow (osk_manager, window);
259+
260+
window.unmanaged.connect_after (() => osk_window = null);
261+
}
262+
255263
public void propagate (UpdateType update_type, GestureAction action, double progress) {
256264
foreach (var window in positioned_windows.get_values ()) {
257265
window.propagate (update_type, action, progress);

src/WindowManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace Gala {
142142

143143
osk_manager = new OSKManager (get_display (), input_method);
144144

145-
ShellClientsManager.init (this, input_method);
145+
ShellClientsManager.init (this, input_method, osk_manager);
146146
BlurManager.init (this);
147147
daemon_manager = new DaemonManager (get_display ());
148148

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ gala_bin_sources = files(
5252
'ShellClients/IBusCandidateWindow.vala',
5353
'ShellClients/ManagedClient.vala',
5454
'ShellClients/NotificationsClient.vala',
55+
'ShellClients/OSKWindow.vala',
5556
'ShellClients/PanelWindow.vala',
5657
'ShellClients/PositionedWindow.vala',
5758
'ShellClients/ShellClientsManager.vala',

0 commit comments

Comments
 (0)