Skip to content

Commit 6392241

Browse files
committed
Merge pull request #104959 from bruvzg/kde_swap
Linux: Detect KDE/LXQt and swap OK/Cancel buttons to Windows style.
2 parents b6c8155 + 52009b5 commit 6392241

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

platform/linuxbsd/wayland/display_server_wayland.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,10 @@ void DisplayServerWayland::cursor_set_custom_image(const Ref<Resource> &p_cursor
11421142
}
11431143
}
11441144

1145+
bool DisplayServerWayland::get_swap_cancel_ok() {
1146+
return swap_cancel_ok;
1147+
}
1148+
11451149
int DisplayServerWayland::keyboard_get_layout_count() const {
11461150
MutexLock mutex_lock(wayland_thread.mutex);
11471151

@@ -1450,6 +1454,10 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
14501454
r_error = ERR_UNAVAILABLE;
14511455
context = p_context;
14521456

1457+
String current_desk = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower();
1458+
String session_desk = OS::get_singleton()->get_environment("XDG_SESSION_DESKTOP").to_lower();
1459+
swap_cancel_ok = (current_desk.contains("kde") || session_desk.contains("kde") || current_desk.contains("lxqt") || session_desk.contains("lxqt"));
1460+
14531461
Error thread_err = wayland_thread.init();
14541462

14551463
if (thread_err != OK) {

platform/linuxbsd/wayland/display_server_wayland.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class DisplayServerWayland : public DisplayServer {
123123
WaylandThread wayland_thread;
124124

125125
Context context;
126+
bool swap_cancel_ok = false;
126127

127128
String ime_text;
128129
Vector2i ime_selection;
@@ -295,6 +296,8 @@ class DisplayServerWayland : public DisplayServer {
295296
virtual CursorShape cursor_get_shape() const override;
296297
virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) override;
297298

299+
virtual bool get_swap_cancel_ok() override;
300+
298301
virtual int keyboard_get_layout_count() const override;
299302
virtual int keyboard_get_current_layout() const override;
300303
virtual void keyboard_set_current_layout(int p_index) override;

platform/linuxbsd/x11/display_server_x11.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3395,6 +3395,10 @@ void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
33953395
}
33963396
}
33973397

3398+
bool DisplayServerX11::get_swap_cancel_ok() {
3399+
return swap_cancel_ok;
3400+
}
3401+
33983402
int DisplayServerX11::keyboard_get_layout_count() const {
33993403
int _group_count = 0;
34003404
XkbDescRec *kbd = XkbAllocKeyboard();
@@ -6515,8 +6519,12 @@ static ::XIMStyle _get_best_xim_style(const ::XIMStyle &p_style_a, const ::XIMSt
65156519
DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error) {
65166520
KeyMappingX11::initialize();
65176521

6522+
String current_desk = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower();
6523+
String session_desk = OS::get_singleton()->get_environment("XDG_SESSION_DESKTOP").to_lower();
6524+
swap_cancel_ok = (current_desk.contains("kde") || session_desk.contains("kde") || current_desk.contains("lxqt") || session_desk.contains("lxqt"));
6525+
65186526
xwayland = OS::get_singleton()->get_environment("XDG_SESSION_TYPE").to_lower() == "wayland";
6519-
kde5_embed_workaround = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower() == "kde" && OS::get_singleton()->get_environment("KDE_SESSION_VERSION") == "5";
6527+
kde5_embed_workaround = current_desk == "kde" && OS::get_singleton()->get_environment("KDE_SESSION_VERSION") == "5";
65206528

65216529
native_menu = memnew(NativeMenu);
65226530
context = p_context;

platform/linuxbsd/x11/display_server_x11.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ class DisplayServerX11 : public DisplayServer {
359359
void _update_context(WindowData &wd);
360360

361361
Context context = CONTEXT_ENGINE;
362+
bool swap_cancel_ok = false;
362363

363364
WindowID _get_focused_window_or_popup() const;
364365
bool _window_focus_check();
@@ -550,6 +551,8 @@ class DisplayServerX11 : public DisplayServer {
550551
virtual CursorShape cursor_get_shape() const override;
551552
virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) override;
552553

554+
virtual bool get_swap_cancel_ok() override;
555+
553556
virtual int keyboard_get_layout_count() const override;
554557
virtual int keyboard_get_current_layout() const override;
555558
virtual void keyboard_set_current_layout(int p_index) override;

0 commit comments

Comments
 (0)