From 0bfe40ac76e4cd8cd16667962d6fd203e02946ba Mon Sep 17 00:00:00 2001 From: gambas Date: Thu, 23 May 2019 19:13:46 +0200 Subject: [PATCH] Message boxes now correctly use the translated title. [GB.GTK] * BUG: Message boxes now correctly use the translated title. [GB.GTK3] * BUG: Message boxes now correctly use the translated title. * BUG: Rudimentary support for GDK backends that are not X11. --- gb.gtk/src/CMessage.cpp | 5 ----- gb.gtk/src/gcontrol.cpp | 33 +++++++++++++-------------------- gb.gtk/src/gkey.cpp | 2 +- gb.gtk/src/gmessage.cpp | 2 ++ gb.gtk/src/main.cpp | 34 +++++++++++++++++++++++----------- gb.gtk/src/main.h | 1 + 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/gb.gtk/src/CMessage.cpp b/gb.gtk/src/CMessage.cpp index a8f6e2c8f..36f2b0d5f 100644 --- a/gb.gtk/src/CMessage.cpp +++ b/gb.gtk/src/CMessage.cpp @@ -41,7 +41,6 @@ static void show_message_box(int type, MSG_PARAM *_p) char *msg = GB.ToZeroString(ARG(msg)); char *btn1, *btn2, *btn3; int ret; - char *title; btn1 = MISSING(btn1) ? NULL : GB.ToZeroString(ARG(btn1)); btn2 = (type == 0 || MISSING(btn2)) ? NULL : GB.ToZeroString(ARG(btn2)); @@ -55,10 +54,6 @@ static void show_message_box(int type, MSG_PARAM *_p) _global_lock++; - title = gMessage::title(); - if (!title) - title = GB.Application.Title(); - switch (type) { case 0: ret = gMessage::showInfo(msg, btn1); break; diff --git a/gb.gtk/src/gcontrol.cpp b/gb.gtk/src/gcontrol.cpp index ce6709154..c6711e042 100644 --- a/gb.gtk/src/gcontrol.cpp +++ b/gb.gtk/src/gcontrol.cpp @@ -226,23 +226,19 @@ void gPlugin::plug(int id) void gPlugin::discard() { - #ifdef GAMBAS_DIRECTFB - stub("DIRECTFB/gPlugin:discard()"); - #else #ifdef GDK_WINDOWING_X11 + if (MAIN_display_x11) + { + Display *d = gdk_x11_display_get_xdisplay(gdk_display_get_default()); - Display *d = gdk_x11_display_get_xdisplay(gdk_display_get_default()); - - if (!client()) return; - - XRemoveFromSaveSet(d, client()); - XReparentWindow(d, client(), GDK_ROOT_WINDOW(), 0, 0); + if (!client()) return; + XRemoveFromSaveSet(d, client()); + XReparentWindow(d, client(), GDK_ROOT_WINDOW(), 0, 0); + } #else stub("no-X11/gPlugin:discard()"); #endif - #endif - } @@ -1005,21 +1001,18 @@ gMainWindow* gControl::topLevel() int gControl::handle() { - #ifndef GAMBAS_DIRECTFB #ifdef GDK_WINDOWING_X11 - if (!gtk_widget_get_window(border)) - return 0; + if (MAIN_display_x11) + { + GdkWindow *window = gtk_widget_get_window(border); + return window ? GDK_WINDOW_XID(window) : 0; + } else - return GDK_WINDOW_XID(gtk_widget_get_window(border)); + return 0; #else stub("no-X11/gControl::handle()"); return 0; #endif - #else - stub("DIRECTFB/gControl::handle()"); - return 0; - #endif - } /***************************************************************** diff --git a/gb.gtk/src/gkey.cpp b/gb.gtk/src/gkey.cpp index 16e354ab5..40b9c4d43 100644 --- a/gb.gtk/src/gkey.cpp +++ b/gb.gtk/src/gkey.cpp @@ -237,7 +237,7 @@ bool gKey::mustIgnoreEvent(GdkEventKey *event) if (!_im_has_input_method) return false; else - return (event->type == GDK_KEY_PRESS) && ((uchar)*event->string >= 32 || event->keyval == 0); + return (event->type == GDK_KEY_PRESS) && (event->keyval == 0 || !event->string || (uchar)*event->string >= 32); } void gcb_im_commit(GtkIMContext *context, const char *str, gpointer pointer) diff --git a/gb.gtk/src/gmessage.cpp b/gb.gtk/src/gmessage.cpp index 8699f9f80..c87c4f909 100644 --- a/gb.gtk/src/gmessage.cpp +++ b/gb.gtk/src/gmessage.cpp @@ -112,6 +112,8 @@ guint custom_dialog(const gchar *icon,GtkButtonsType btn,char *sg) if (bt.bt3) { gMnemonic_correctText(bt.bt3, &buf); bt.bt3 = buf; } title = gMessage::title(); + if (!title) + title = GB.Application.Title(); #ifdef GTK3 msg = gtk_dialog_new_with_buttons(title, NULL, diff --git a/gb.gtk/src/main.cpp b/gb.gtk/src/main.cpp index 60aa3563e..ea45ee2db 100644 --- a/gb.gtk/src/main.cpp +++ b/gb.gtk/src/main.cpp @@ -100,6 +100,7 @@ static GB_FUNCTION _application_keypress_func; static void *_old_hook_main; +bool MAIN_display_x11 = FALSE; int MAIN_scale = 0; bool MAIN_debug_busy = false; bool MAIN_rtl = false; @@ -257,17 +258,21 @@ void EXPORT GB_EXIT() int EXPORT GB_INFO(const char *key, void **value) { - if (!strcasecmp(key, "DISPLAY")) + if (MAIN_display_x11) { - *value = (void *)gdk_x11_display_get_xdisplay(gdk_display_get_default()); - return TRUE; + if (!strcasecmp(key, "DISPLAY")) + { + *value = (void *)gdk_x11_display_get_xdisplay(gdk_display_get_default()); + return TRUE; + } + else if (!strcasecmp(key, "ROOT_WINDOW")) + { + *value = (void *)gdk_x11_get_default_root_xwindow(); + return TRUE; + } } - else if (!strcasecmp(key, "ROOT_WINDOW")) - { - *value = (void *)gdk_x11_get_default_root_xwindow(); - return TRUE; - } - else if (!strcasecmp(key, "GET_HANDLE")) + + if (!strcasecmp(key, "GET_HANDLE")) { *value = (void *)CWIDGET_get_handle; return TRUE; @@ -355,7 +360,8 @@ void my_quit (void) gApplication::exit(); #ifdef GDK_WINDOWING_X11 - X11_exit(); + if (MAIN_display_x11) + X11_exit(); #endif } @@ -386,7 +392,13 @@ static void my_main(int *argc, char ***argv) MAIN_scale = gDesktop::scale(); #ifdef GDK_WINDOWING_X11 - X11_init(gdk_x11_display_get_xdisplay(gdk_display_get_default()), gdk_x11_get_default_root_xwindow()); + #ifdef GTK3 + if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) + #endif + { + X11_init(gdk_x11_display_get_xdisplay(gdk_display_get_default()), gdk_x11_get_default_root_xwindow()); + MAIN_display_x11 = TRUE; + } #endif if (GB.GetFunction(&_application_keypress_func, (void *)GB.Application.StartupClass(), "Application_KeyPress", "", "") == 0) diff --git a/gb.gtk/src/main.h b/gb.gtk/src/main.h index 06985afc4..9176a14e0 100644 --- a/gb.gtk/src/main.h +++ b/gb.gtk/src/main.h @@ -48,6 +48,7 @@ extern GB_CLASS CLASS_SvgImage; extern bool MAIN_debug_busy; extern bool MAIN_rtl; +extern bool MAIN_display_x11; #endif #define GB (*GB_PTR)