summaryrefslogtreecommitdiff
path: root/platform/x11/os_x11.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r--platform/x11/os_x11.cpp91
1 files changed, 67 insertions, 24 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 733d2509f7..ca9fd68412 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -170,13 +170,13 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
#ifdef TOUCH_ENABLED
if (!XQueryExtension(x11_display, "XInputExtension", &touch.opcode, &event_base, &error_base)) {
- fprintf(stderr, "XInput extension not available");
+ print_verbose("XInput extension not available, touch support disabled.");
} else {
// 2.2 is the first release with multitouch
int xi_major = 2;
int xi_minor = 2;
if (XIQueryVersion(x11_display, &xi_major, &xi_minor) != Success) {
- fprintf(stderr, "XInput 2.2 not available (server supports %d.%d)\n", xi_major, xi_minor);
+ print_verbose(vformat("XInput 2.2 not available (server supports %d.%d), touch support disabled.", xi_major, xi_minor));
touch.opcode = 0;
} else {
int dev_count;
@@ -198,14 +198,14 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
}
if (direct_touch) {
touch.devices.push_back(dev->deviceid);
- fprintf(stderr, "Using touch device: %s\n", dev->name);
+ print_verbose("XInput: Using touch device: " + String(dev->name));
}
}
XIFreeDeviceInfo(info);
- if (is_stdout_verbose() && !touch.devices.size()) {
- fprintf(stderr, "No touch devices found\n");
+ if (!touch.devices.size()) {
+ print_verbose("XInput: No touch devices found.");
}
}
}
@@ -266,7 +266,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
*/
// maybe contextgl wants to be in charge of creating the window
-//print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height));
#if defined(OPENGL_ENABLED)
ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_3_0_COMPATIBLE;
@@ -342,10 +341,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
AudioDriverManager::initialize(p_audio_driver);
-#ifdef ALSAMIDI_ENABLED
- driver_alsamidi.open();
-#endif
-
ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE);
@@ -427,9 +422,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
cursor_theme = XcursorGetTheme(x11_display);
if (!cursor_theme) {
- if (is_stdout_verbose()) {
- print_line("XcursorGetTheme could not get cursor theme");
- }
+ print_verbose("XcursorGetTheme could not get cursor theme");
cursor_theme = "default";
}
@@ -442,7 +435,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
current_cursor = CURSOR_ARROW;
if (cursor_theme) {
- //print_line("cursor theme: "+String(cursor_theme));
for (int i = 0; i < CURSOR_MAX; i++) {
static const char *cursor_file[] = {
@@ -468,10 +460,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size);
if (img[i]) {
cursors[i] = XcursorImageLoadCursor(x11_display, img[i]);
- //print_line("found cursor: "+String(cursor_file[i])+" id "+itos(cursors[i]));
} else {
- if (OS::is_stdout_verbose())
- print_line("failed cursor: " + String(cursor_file[i]));
+ print_verbose("Failed loading custom cursor: " + String(cursor_file[i]));
}
}
}
@@ -1516,7 +1506,6 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// KeyMappingX11 also translates keysym to unicode.
// It does a binary search on a table to translate
// most properly.
- //print_line("keysym_unicode: "+rtos(keysym_unicode));
unsigned int unicode = keysym_unicode > 0 ? KeyMappingX11::get_unicode_from_keysym(keysym_unicode) : 0;
/* Phase 4, determine if event must be filtered */
@@ -1539,7 +1528,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// know Mod1 was ALT and Mod4 was META (applekey/winkey)
// just tried Mods until i found them.
- //print_line("mod1: "+itos(xkeyevent->state&Mod1Mask)+" mod 5: "+itos(xkeyevent->state&Mod5Mask));
+ //print_verbose("mod1: "+itos(xkeyevent->state&Mod1Mask)+" mod 5: "+itos(xkeyevent->state&Mod5Mask));
Ref<InputEventKey> k;
k.instance();
@@ -2575,14 +2564,68 @@ void OS_X11::swap_buffers() {
}
void OS_X11::alert(const String &p_alert, const String &p_title) {
+ const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" };
+
+ String path = get_environment("PATH");
+ Vector<String> path_elems = path.split(":", false);
+ String program;
+
+ for (int i = 0; i < path_elems.size(); i++) {
+ for (unsigned int k = 0; k < sizeof(message_programs) / sizeof(char *); k++) {
+ String tested_path = path_elems[i] + "/" + message_programs[k];
+
+ if (FileAccess::exists(tested_path)) {
+ program = tested_path;
+ break;
+ }
+ }
+
+ if (program.length())
+ break;
+ }
List<String> args;
- args.push_back("-center");
- args.push_back("-title");
- args.push_back(p_title);
- args.push_back(p_alert);
- execute("xmessage", args, true);
+ if (program.ends_with("zenity")) {
+ args.push_back("--error");
+ args.push_back("--width");
+ args.push_back("500");
+ args.push_back("--title");
+ args.push_back(p_title);
+ args.push_back("--text");
+ args.push_back(p_alert);
+ }
+
+ if (program.ends_with("kdialog")) {
+ args.push_back("--error");
+ args.push_back(p_alert);
+ args.push_back("--title");
+ args.push_back(p_title);
+ }
+
+ if (program.ends_with("Xdialog")) {
+ args.push_back("--title");
+ args.push_back(p_title);
+ args.push_back("--msgbox");
+ args.push_back(p_alert);
+ args.push_back("0");
+ args.push_back("0");
+ }
+
+ if (program.ends_with("xmessage")) {
+ args.push_back("-center");
+ args.push_back("-title");
+ args.push_back(p_title);
+ args.push_back(p_alert);
+ }
+
+ if (program.length()) {
+ execute(program, args, true);
+ } else {
+ print_line(p_alert);
+ }
+
+ return;
}
void OS_X11::set_icon(const Ref<Image> &p_icon) {