Detect KDE/LXQt and swap OK/Cancel buttons to Windows style.

This commit is contained in:
Pāvels Nadtočajevs 2025-04-03 12:15:27 +03:00
parent 1f56d96cf2
commit 52009b52d2
No known key found for this signature in database
GPG Key ID: 8413210218EF35D2
4 changed files with 23 additions and 1 deletions

View File

@ -1142,6 +1142,10 @@ void DisplayServerWayland::cursor_set_custom_image(const Ref<Resource> &p_cursor
}
}
bool DisplayServerWayland::get_swap_cancel_ok() {
return swap_cancel_ok;
}
int DisplayServerWayland::keyboard_get_layout_count() const {
MutexLock mutex_lock(wayland_thread.mutex);
@ -1450,6 +1454,10 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
r_error = ERR_UNAVAILABLE;
context = p_context;
String current_desk = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower();
String session_desk = OS::get_singleton()->get_environment("XDG_SESSION_DESKTOP").to_lower();
swap_cancel_ok = (current_desk.contains("kde") || session_desk.contains("kde") || current_desk.contains("lxqt") || session_desk.contains("lxqt"));
Error thread_err = wayland_thread.init();
if (thread_err != OK) {

View File

@ -123,6 +123,7 @@ class DisplayServerWayland : public DisplayServer {
WaylandThread wayland_thread;
Context context;
bool swap_cancel_ok = false;
String ime_text;
Vector2i ime_selection;
@ -295,6 +296,8 @@ public:
virtual CursorShape cursor_get_shape() const override;
virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) override;
virtual bool get_swap_cancel_ok() override;
virtual int keyboard_get_layout_count() const override;
virtual int keyboard_get_current_layout() const override;
virtual void keyboard_set_current_layout(int p_index) override;

View File

@ -3395,6 +3395,10 @@ void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
}
}
bool DisplayServerX11::get_swap_cancel_ok() {
return swap_cancel_ok;
}
int DisplayServerX11::keyboard_get_layout_count() const {
int _group_count = 0;
XkbDescRec *kbd = XkbAllocKeyboard();
@ -6515,8 +6519,12 @@ static ::XIMStyle _get_best_xim_style(const ::XIMStyle &p_style_a, const ::XIMSt
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) {
KeyMappingX11::initialize();
String current_desk = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower();
String session_desk = OS::get_singleton()->get_environment("XDG_SESSION_DESKTOP").to_lower();
swap_cancel_ok = (current_desk.contains("kde") || session_desk.contains("kde") || current_desk.contains("lxqt") || session_desk.contains("lxqt"));
xwayland = OS::get_singleton()->get_environment("XDG_SESSION_TYPE").to_lower() == "wayland";
kde5_embed_workaround = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower() == "kde" && OS::get_singleton()->get_environment("KDE_SESSION_VERSION") == "5";
kde5_embed_workaround = current_desk == "kde" && OS::get_singleton()->get_environment("KDE_SESSION_VERSION") == "5";
native_menu = memnew(NativeMenu);
context = p_context;

View File

@ -359,6 +359,7 @@ class DisplayServerX11 : public DisplayServer {
void _update_context(WindowData &wd);
Context context = CONTEXT_ENGINE;
bool swap_cancel_ok = false;
WindowID _get_focused_window_or_popup() const;
bool _window_focus_check();
@ -550,6 +551,8 @@ public:
virtual CursorShape cursor_get_shape() const override;
virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) override;
virtual bool get_swap_cancel_ok() override;
virtual int keyboard_get_layout_count() const override;
virtual int keyboard_get_current_layout() const override;
virtual void keyboard_set_current_layout(int p_index) override;