summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/SCsub2
-rw-r--r--platform/x11/context_gl_x11.cpp18
-rw-r--r--platform/x11/context_gl_x11.h3
-rw-r--r--platform/x11/detect.py41
-rw-r--r--platform/x11/detect_prime.cpp1
-rw-r--r--platform/x11/joypad_linux.cpp28
-rw-r--r--platform/x11/joypad_linux.h2
-rw-r--r--platform/x11/key_mapping_x11.cpp134
-rw-r--r--platform/x11/key_mapping_x11.h1
-rw-r--r--platform/x11/os_x11.cpp467
-rw-r--r--platform/x11/os_x11.h28
-rw-r--r--platform/x11/platform_config.h1
-rw-r--r--platform/x11/power_x11.cpp577
-rw-r--r--platform/x11/vulkan_context_x11.cpp57
-rw-r--r--platform/x11/vulkan_context_x11.h (renamed from platform/x11/power_x11.h)40
15 files changed, 527 insertions, 873 deletions
diff --git a/platform/x11/SCsub b/platform/x11/SCsub
index 3d5aa15208..2268e4cc3d 100644
--- a/platform/x11/SCsub
+++ b/platform/x11/SCsub
@@ -7,11 +7,11 @@ import platform_x11_builders
common_x11 = [
"context_gl_x11.cpp",
+ "vulkan_context_x11.cpp",
"crash_handler_x11.cpp",
"os_x11.cpp",
"key_mapping_x11.cpp",
"joypad_linux.cpp",
- "power_x11.cpp",
"detect_prime.cpp"
]
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 3b88af28e4..5442af3bef 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -166,29 +166,11 @@ Error ContextGL_X11::initialize() {
int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&ctxErrorHandler);
switch (context_type) {
- case OLDSTYLE: {
-
- p->glx_context = glXCreateContext(x11_display, vi, 0, GL_TRUE);
- ERR_FAIL_COND_V(!p->glx_context, ERR_UNCONFIGURED);
- } break;
case GLES_2_0_COMPATIBLE: {
p->glx_context = glXCreateNewContext(x11_display, fbconfig, GLX_RGBA_TYPE, 0, true);
ERR_FAIL_COND_V(!p->glx_context, ERR_UNCONFIGURED);
} break;
- case GLES_3_0_COMPATIBLE: {
-
- static int context_attribs[] = {
- GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX_CONTEXT_MINOR_VERSION_ARB, 3,
- GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
- GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*|GLX_CONTEXT_DEBUG_BIT_ARB*/,
- None
- };
-
- p->glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, NULL, true, context_attribs);
- ERR_FAIL_COND_V(ctxErrorOccurred || !p->glx_context, ERR_UNCONFIGURED);
- } break;
}
swa.colormap = XCreateColormap(x11_display, RootWindow(x11_display, vi->screen), vi->visual, AllocNone);
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h
index 5e5ccc5c86..2c0643c95a 100644
--- a/platform/x11/context_gl_x11.h
+++ b/platform/x11/context_gl_x11.h
@@ -45,15 +45,12 @@ class ContextGL_X11 {
public:
enum ContextType {
- OLDSTYLE,
GLES_2_0_COMPATIBLE,
- GLES_3_0_COMPATIBLE
};
private:
ContextGL_X11_Private *p;
OS::VideoMode default_video_mode;
- //::Colormap x11_colormap;
::Display *x11_display;
::Window &x11_window;
bool double_buffer;
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index bd5e5e0812..9a9ab86068 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -1,7 +1,6 @@
import os
import platform
import sys
-from methods import get_compiler_version, using_gcc, using_clang
def is_active():
@@ -61,6 +60,7 @@ def get_opts():
BoolVariable('use_lld', 'Use the LLD linker', False),
BoolVariable('use_thinlto', 'Use ThinLTO', False),
BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically for better portability', False),
+ BoolVariable('use_coverage', 'Test Godot coverage', False),
BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False),
BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False),
BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False),
@@ -141,6 +141,10 @@ def configure(env):
print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.")
sys.exit(255)
+ if env['use_coverage']:
+ env.Append(CCFLAGS=['-ftest-coverage', '-fprofile-arcs'])
+ env.Append(LINKFLAGS=['-ftest-coverage', '-fprofile-arcs'])
+
if env['use_ubsan'] or env['use_asan'] or env['use_lsan'] or env['use_tsan']:
env.extra_suffix += "s"
@@ -179,18 +183,10 @@ def configure(env):
env.Append(CCFLAGS=['-pipe'])
env.Append(LINKFLAGS=['-pipe'])
- # Check for gcc version >= 6 before adding -no-pie
- if using_gcc(env):
- version = get_compiler_version(env)
- if version != None and version[0] >= '6':
- env.Append(CCFLAGS=['-fpie'])
- env.Append(LINKFLAGS=['-no-pie'])
- # Do the same for clang should be fine with Clang 4 and higher
- if using_clang(env):
- version = get_compiler_version(env)
- if version != None and version[0] >= '4':
- env.Append(CCFLAGS=['-fpie'])
- env.Append(LINKFLAGS=['-no-pie'])
+ # -fpie and -no-pie is supported on GCC 6+ and Clang 4+, both below our
+ # minimal requirements.
+ env.Append(CCFLAGS=['-fpie'])
+ env.Append(LINKFLAGS=['-no-pie'])
## Dependencies
@@ -229,6 +225,10 @@ def configure(env):
sys.exit(255)
env.ParseConfig('pkg-config bullet --cflags --libs')
+ if False: # not env['builtin_assimp']:
+ # FIXME: Add min version check
+ env.ParseConfig('pkg-config assimp --cflags --libs')
+
if not env['builtin_enet']:
env.ParseConfig('pkg-config libenet --cflags --libs')
@@ -318,8 +318,19 @@ def configure(env):
env.ParseConfig('pkg-config zlib --cflags --libs')
env.Prepend(CPPPATH=['#platform/x11'])
- env.Append(CPPDEFINES=['X11_ENABLED', 'UNIX_ENABLED', 'OPENGL_ENABLED', 'GLES_ENABLED'])
- env.Append(LIBS=['GL', 'pthread'])
+ env.Append(CPPDEFINES=['X11_ENABLED', 'UNIX_ENABLED'])
+
+ env.Append(CPPDEFINES=['VULKAN_ENABLED'])
+ if not env['builtin_vulkan']:
+ env.ParseConfig('pkg-config vulkan --cflags --libs')
+ if not env['builtin_glslang']:
+ # No pkgconfig file for glslang so far
+ env.Append(LIBS=['glslang', 'SPIRV'])
+
+ #env.Append(CPPDEFINES=['OPENGL_ENABLED'])
+ env.Append(LIBS=['GL'])
+
+ env.Append(LIBS=['pthread'])
if (platform.system() == "Linux"):
env.Append(LIBS=['dl'])
diff --git a/platform/x11/detect_prime.cpp b/platform/x11/detect_prime.cpp
index 98a51ff27c..a0e5f835c0 100644
--- a/platform/x11/detect_prime.cpp
+++ b/platform/x11/detect_prime.cpp
@@ -62,6 +62,7 @@ vendor vendormap[] = {
{ "NVIDIA Corporation", 30 },
{ "X.Org", 30 },
{ "Intel Open Source Technology Center", 20 },
+ { "Intel", 20 },
{ "nouveau", 10 },
{ "Mesa Project", 0 },
{ NULL, 0 }
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index a64a25aeee..a9fe7275c2 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -83,7 +83,6 @@ void JoypadLinux::Joypad::reset() {
JoypadLinux::JoypadLinux(InputDefault *in) {
exit_udev = false;
input = in;
- joy_mutex = Mutex::create();
joy_thread = Thread::create(joy_thread_func, this);
}
@@ -91,7 +90,6 @@ JoypadLinux::~JoypadLinux() {
exit_udev = true;
Thread::wait_to_finish(joy_thread);
memdelete(joy_thread);
- memdelete(joy_mutex);
close_joypad();
}
@@ -137,9 +135,8 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
- joy_mutex->lock();
+ MutexLock lock(joy_mutex);
open_joypad(devnode);
- joy_mutex->unlock();
}
}
udev_device_unref(dev);
@@ -176,7 +173,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
if (dev && udev_device_get_devnode(dev) != 0) {
- joy_mutex->lock();
+ MutexLock lock(joy_mutex);
String action = udev_device_get_action(dev);
const char *devnode = udev_device_get_devnode(dev);
if (devnode) {
@@ -192,7 +189,6 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
}
udev_device_unref(dev);
- joy_mutex->unlock();
}
}
usleep(50000);
@@ -204,15 +200,17 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
void JoypadLinux::monitor_joypads() {
while (!exit_udev) {
- joy_mutex->lock();
- for (int i = 0; i < 32; i++) {
- char fname[64];
- sprintf(fname, "/dev/input/event%d", i);
- if (attached_devices.find(fname) == -1) {
- open_joypad(fname);
+ {
+ MutexLock lock(joy_mutex);
+
+ for (int i = 0; i < 32; i++) {
+ char fname[64];
+ sprintf(fname, "/dev/input/event%d", i);
+ if (attached_devices.find(fname) == -1) {
+ open_joypad(fname);
+ }
}
}
- joy_mutex->unlock();
usleep(1000000); // 1s
}
}
@@ -457,7 +455,7 @@ InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int
void JoypadLinux::process_joypads() {
- if (joy_mutex->try_lock() != OK) {
+ if (joy_mutex.try_lock() != OK) {
return;
}
for (int i = 0; i < JOYPADS_MAX; i++) {
@@ -548,6 +546,6 @@ void JoypadLinux::process_joypads() {
}
}
}
- joy_mutex->unlock();
+ joy_mutex.unlock();
}
#endif
diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h
index e5638899bf..d5719b6dbe 100644
--- a/platform/x11/joypad_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -72,7 +72,7 @@ private:
};
bool exit_udev;
- Mutex *joy_mutex;
+ Mutex joy_mutex;
Thread *joy_thread;
InputDefault *input;
Joypad joypads[JOYPADS_MAX];
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp
index 54e1e1d357..78bd2b71a0 100644
--- a/platform/x11/key_mapping_x11.cpp
+++ b/platform/x11/key_mapping_x11.cpp
@@ -180,6 +180,140 @@ static _XTranslatePair _xkeysym_to_keycode[] = {
{ 0, 0 }
};
+struct _TranslatePair {
+
+ unsigned int keysym;
+ unsigned int keycode;
+};
+
+static _TranslatePair _scancode_to_keycode[] = {
+
+ { KEY_ESCAPE, 0x09 },
+ { KEY_1, 0x0A },
+ { KEY_2, 0x0B },
+ { KEY_3, 0x0C },
+ { KEY_4, 0x0D },
+ { KEY_5, 0x0E },
+ { KEY_6, 0x0F },
+ { KEY_7, 0x10 },
+ { KEY_8, 0x11 },
+ { KEY_9, 0x12 },
+ { KEY_0, 0x13 },
+ { KEY_MINUS, 0x14 },
+ { KEY_EQUAL, 0x15 },
+ { KEY_BACKSPACE, 0x16 },
+ { KEY_TAB, 0x17 },
+ { KEY_Q, 0x18 },
+ { KEY_W, 0x19 },
+ { KEY_E, 0x1A },
+ { KEY_R, 0x1B },
+ { KEY_T, 0x1C },
+ { KEY_Y, 0x1D },
+ { KEY_U, 0x1E },
+ { KEY_I, 0x1F },
+ { KEY_O, 0x20 },
+ { KEY_P, 0x21 },
+ { KEY_BRACELEFT, 0x22 },
+ { KEY_BRACERIGHT, 0x23 },
+ { KEY_ENTER, 0x24 },
+ { KEY_CONTROL, 0x25 },
+ { KEY_A, 0x26 },
+ { KEY_S, 0x27 },
+ { KEY_D, 0x28 },
+ { KEY_F, 0x29 },
+ { KEY_G, 0x2A },
+ { KEY_H, 0x2B },
+ { KEY_J, 0x2C },
+ { KEY_K, 0x2D },
+ { KEY_L, 0x2E },
+ { KEY_SEMICOLON, 0x2F },
+ { KEY_APOSTROPHE, 0x30 },
+ { KEY_QUOTELEFT, 0x31 },
+ { KEY_SHIFT, 0x32 },
+ { KEY_BACKSLASH, 0x33 },
+ { KEY_Z, 0x34 },
+ { KEY_X, 0x35 },
+ { KEY_C, 0x36 },
+ { KEY_V, 0x37 },
+ { KEY_B, 0x38 },
+ { KEY_N, 0x39 },
+ { KEY_M, 0x3A },
+ { KEY_COMMA, 0x3B },
+ { KEY_PERIOD, 0x3C },
+ { KEY_SLASH, 0x3D },
+ { KEY_SHIFT, 0x3E },
+ { KEY_KP_MULTIPLY, 0x3F },
+ { KEY_ALT, 0x40 },
+ { KEY_SPACE, 0x41 },
+ { KEY_CAPSLOCK, 0x42 },
+ { KEY_F1, 0x43 },
+ { KEY_F2, 0x44 },
+ { KEY_F3, 0x45 },
+ { KEY_F4, 0x46 },
+ { KEY_F5, 0x47 },
+ { KEY_F6, 0x48 },
+ { KEY_F7, 0x49 },
+ { KEY_F8, 0x4A },
+ { KEY_F9, 0x4B },
+ { KEY_F10, 0x4C },
+ { KEY_NUMLOCK, 0x4D },
+ { KEY_SCROLLLOCK, 0x4E },
+ { KEY_KP_7, 0x4F },
+ { KEY_KP_8, 0x50 },
+ { KEY_KP_9, 0x51 },
+ { KEY_KP_SUBTRACT, 0x52 },
+ { KEY_KP_4, 0x53 },
+ { KEY_KP_5, 0x54 },
+ { KEY_KP_6, 0x55 },
+ { KEY_KP_ADD, 0x56 },
+ { KEY_KP_1, 0x57 },
+ { KEY_KP_2, 0x58 },
+ { KEY_KP_3, 0x59 },
+ { KEY_KP_0, 0x5A },
+ { KEY_KP_PERIOD, 0x5B },
+ //{ KEY_???, 0x5E }, //NON US BACKSLASH
+ { KEY_F11, 0x5F },
+ { KEY_F12, 0x60 },
+ { KEY_KP_ENTER, 0x68 },
+ { KEY_CONTROL, 0x69 },
+ { KEY_KP_DIVIDE, 0x6A },
+ { KEY_PRINT, 0x6B },
+ { KEY_ALT, 0x6C },
+ { KEY_ENTER, 0x6D },
+ { KEY_HOME, 0x6E },
+ { KEY_UP, 0x6F },
+ { KEY_PAGEUP, 0x70 },
+ { KEY_LEFT, 0x71 },
+ { KEY_RIGHT, 0x72 },
+ { KEY_END, 0x73 },
+ { KEY_DOWN, 0x74 },
+ { KEY_PAGEDOWN, 0x75 },
+ { KEY_INSERT, 0x76 },
+ { KEY_DELETE, 0x77 },
+ { KEY_VOLUMEMUTE, 0x79 },
+ { KEY_VOLUMEDOWN, 0x7A },
+ { KEY_VOLUMEUP, 0x7B },
+ { KEY_PAUSE, 0x7F },
+ { KEY_SUPER_L, 0x85 },
+ { KEY_SUPER_R, 0x86 },
+ { KEY_MENU, 0x87 },
+ { KEY_UNKNOWN, 0 }
+};
+
+unsigned int KeyMappingX11::get_scancode(unsigned int p_code) {
+
+ unsigned int keycode = KEY_UNKNOWN;
+ for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
+
+ if (_scancode_to_keycode[i].keycode == p_code) {
+ keycode = _scancode_to_keycode[i].keysym;
+ break;
+ }
+ }
+
+ return keycode;
+}
+
unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) {
// kinda bruteforce.. could optimize.
diff --git a/platform/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h
index e99bf1694b..10db43bcc4 100644
--- a/platform/x11/key_mapping_x11.h
+++ b/platform/x11/key_mapping_x11.h
@@ -45,6 +45,7 @@ class KeyMappingX11 {
public:
static unsigned int get_keycode(KeySym p_keysym);
+ static unsigned int get_scancode(unsigned int p_code);
static KeySym get_keysym(unsigned int p_code);
static unsigned int get_unicode_from_keysym(KeySym p_keysym);
static KeySym get_keysym_from_unicode(unsigned int p_unicode);
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 57c7b0594c..e1f7691cf6 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -33,10 +33,17 @@
#include "core/os/dir_access.h"
#include "core/print_string.h"
-#include "drivers/gles2/rasterizer_gles2.h"
-#include "drivers/gles3/rasterizer_gles3.h"
#include "errno.h"
#include "key_mapping_x11.h"
+
+#if defined(OPENGL_ENABLED)
+#include "drivers/gles2/rasterizer_gles2.h"
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "servers/visual/rasterizer_rd/rasterizer_rd.h"
+#endif
+
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
@@ -230,137 +237,131 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
XFree(imvalret);
}
-/*
- char* windowid = getenv("GODOT_WINDOWID");
- if (windowid) {
-
- //freopen("/home/punto/stdout", "w", stdout);
- //reopen("/home/punto/stderr", "w", stderr);
- x11_window = atol(windowid);
-
- XWindowAttributes xwa;
- XGetWindowAttributes(x11_display,x11_window,&xwa);
-
- current_videomode.width = xwa.width;
- current_videomode.height = xwa.height;
- };
- */
-
-// maybe contextgl wants to be in charge of creating the window
-#if defined(OPENGL_ENABLED)
- if (getenv("DRI_PRIME") == NULL) {
- int use_prime = -1;
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //TODO - do Vulkan and GLES2 support checks, driver selection and fallback
+ video_driver_index = p_video_driver;
+#ifndef _MSC_VER
+#warning Forcing vulkan video driver because OpenGL not implemented yet
+#endif
+ video_driver_index = VIDEO_DRIVER_VULKAN;
- if (getenv("PRIMUS_DISPLAY") ||
- getenv("PRIMUS_libGLd") ||
- getenv("PRIMUS_libGLa") ||
- getenv("PRIMUS_libGL") ||
- getenv("PRIMUS_LOAD_GLOBAL") ||
- getenv("BUMBLEBEE_SOCKET")) {
+ print_verbose("Driver: " + String(get_video_driver_name(video_driver_index)) + " [" + itos(video_driver_index) + "]");
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!
- print_verbose("Optirun/primusrun detected. Skipping GPU detection");
- use_prime = 0;
- }
+ //Create window
- if (getenv("LD_LIBRARY_PATH")) {
- String ld_library_path(getenv("LD_LIBRARY_PATH"));
- Vector<String> libraries = ld_library_path.split(":");
+ long visualMask = VisualScreenMask;
+ int numberOfVisuals;
+ XVisualInfo vInfoTemplate = {};
+ vInfoTemplate.screen = DefaultScreen(x11_display);
+ XVisualInfo *visualInfo = XGetVisualInfo(x11_display, visualMask, &vInfoTemplate, &numberOfVisuals);
- for (int i = 0; i < libraries.size(); ++i) {
- if (FileAccess::exists(libraries[i] + "/libGL.so.1") ||
- FileAccess::exists(libraries[i] + "/libGL.so")) {
+ Colormap colormap = XCreateColormap(x11_display, RootWindow(x11_display, vInfoTemplate.screen), visualInfo->visual, AllocNone);
- print_verbose("Custom libGL override detected. Skipping GPU detection");
- use_prime = 0;
- }
- }
- }
+ XSetWindowAttributes windowAttributes = {};
+ windowAttributes.colormap = colormap;
+ windowAttributes.background_pixel = 0xFFFFFFFF;
+ windowAttributes.border_pixel = 0;
+ windowAttributes.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask | ExposureMask;
- if (use_prime == -1) {
- print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
- use_prime = detect_prime();
- }
+ unsigned long valuemask = CWBorderPixel | CWColormap | CWEventMask;
+ x11_window = XCreateWindow(x11_display, RootWindow(x11_display, visualInfo->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, visualInfo->depth, InputOutput, visualInfo->visual, valuemask, &windowAttributes);
- if (use_prime) {
- print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");
- print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
- setenv("DRI_PRIME", "1", 1);
- }
- }
+ //set_class_hint(x11_display, x11_window);
+ XMapWindow(x11_display, x11_window);
+ XFlush(x11_display);
- ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_3_0_COMPATIBLE;
+ XSync(x11_display, False);
+ //XSetErrorHandler(oldHandler);
- if (p_video_driver == VIDEO_DRIVER_GLES2) {
- opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
- }
+ XFree(visualInfo);
- bool editor = Engine::get_singleton()->is_editor_hint();
- bool gl_initialization_error = false;
+ // Init context and rendering device
+#if defined(OPENGL_ENABLED)
+ if (video_driver_index == VIDEO_DRIVER_GLES2) {
+ if (getenv("DRI_PRIME") == NULL) {
+ int use_prime = -1;
+
+ if (getenv("PRIMUS_DISPLAY") ||
+ getenv("PRIMUS_libGLd") ||
+ getenv("PRIMUS_libGLa") ||
+ getenv("PRIMUS_libGL") ||
+ getenv("PRIMUS_LOAD_GLOBAL") ||
+ getenv("BUMBLEBEE_SOCKET")) {
+
+ print_verbose("Optirun/primusrun detected. Skipping GPU detection");
+ use_prime = 0;
+ }
- context_gl = NULL;
- while (!context_gl) {
- context_gl = memnew(ContextGL_X11(x11_display, x11_window, current_videomode, opengl_api_type));
+ if (getenv("LD_LIBRARY_PATH")) {
+ String ld_library_path(getenv("LD_LIBRARY_PATH"));
+ Vector<String> libraries = ld_library_path.split(":");
- if (context_gl->initialize() != OK) {
- memdelete(context_gl);
- context_gl = NULL;
+ for (int i = 0; i < libraries.size(); ++i) {
+ if (FileAccess::exists(libraries[i] + "/libGL.so.1") ||
+ FileAccess::exists(libraries[i] + "/libGL.so")) {
- if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
- if (p_video_driver == VIDEO_DRIVER_GLES2) {
- gl_initialization_error = true;
- break;
+ print_verbose("Custom libGL override detected. Skipping GPU detection");
+ use_prime = 0;
+ }
}
+ }
- p_video_driver = VIDEO_DRIVER_GLES2;
- opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
- } else {
- gl_initialization_error = true;
- break;
+ if (use_prime == -1) {
+ print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
+ use_prime = detect_prime();
}
- }
- }
- while (true) {
- if (opengl_api_type == ContextGL_X11::GLES_3_0_COMPATIBLE) {
- if (RasterizerGLES3::is_viable() == OK) {
- RasterizerGLES3::register_config();
- RasterizerGLES3::make_current();
- break;
- } else {
- if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
- p_video_driver = VIDEO_DRIVER_GLES2;
- opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
- continue;
- } else {
- gl_initialization_error = true;
- break;
- }
+ if (use_prime) {
+ print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");
+ print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ setenv("DRI_PRIME", "1", 1);
}
}
- if (opengl_api_type == ContextGL_X11::GLES_2_0_COMPATIBLE) {
- if (RasterizerGLES2::is_viable() == OK) {
- RasterizerGLES2::register_config();
- RasterizerGLES2::make_current();
- break;
- } else {
- gl_initialization_error = true;
- break;
- }
+ ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
+
+ context_gles2 = memnew(ContextGL_X11(x11_display, x11_window, current_videomode, opengl_api_type));
+
+ if (context_gles2->initialize() != OK) {
+ memdelete(context_gles2);
+ context_gles2 = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
}
- }
- if (gl_initialization_error) {
- OS::get_singleton()->alert("Your video card driver does not support any of the supported OpenGL versions.\n"
- "Please update your drivers or if you have a very old or integrated GPU upgrade it.",
- "Unable to initialize Video driver");
- return ERR_UNAVAILABLE;
+ context_gles2->set_use_vsync(current_videomode.use_vsync);
+
+ if (RasterizerGLES2::is_viable() == OK) {
+ RasterizerGLES2::register_config();
+ RasterizerGLES2::make_current();
+ } else {
+ memdelete(context_gles2);
+ context_gles2 = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
}
+#endif
+#if defined(VULKAN_ENABLED)
+ if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- video_driver_index = p_video_driver;
+ context_vulkan = memnew(VulkanContextX11);
+ if (context_vulkan->initialize() != OK) {
+ memdelete(context_vulkan);
+ context_vulkan = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
+ if (context_vulkan->window_create(x11_window, x11_display, get_video_mode().width, get_video_mode().height) == -1) {
+ memdelete(context_vulkan);
+ context_vulkan = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
- context_gl->set_use_vsync(current_videomode.use_vsync);
+ //temporary
+ rendering_device_vulkan = memnew(RenderingDeviceVulkan);
+ rendering_device_vulkan->initialize(context_vulkan);
+ RasterizerRD::make_current();
+ }
#endif
visual_server = memnew(VisualServerRaster);
@@ -526,19 +527,73 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
"watch",
"left_ptr_watch",
"fleur",
- "hand1",
- "X_cursor",
- "sb_v_double_arrow",
- "sb_h_double_arrow",
+ "dnd-move",
+ "crossed_circle",
+ "v_double_arrow",
+ "h_double_arrow",
"size_bdiag",
"size_fdiag",
- "hand1",
- "sb_v_double_arrow",
- "sb_h_double_arrow",
+ "move",
+ "row_resize",
+ "col_resize",
"question_arrow"
};
img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size);
+ if (!img[i]) {
+ const char *fallback = NULL;
+
+ switch (i) {
+ case CURSOR_POINTING_HAND:
+ fallback = "pointer";
+ break;
+ case CURSOR_CROSS:
+ fallback = "crosshair";
+ break;
+ case CURSOR_WAIT:
+ fallback = "wait";
+ break;
+ case CURSOR_BUSY:
+ fallback = "progress";
+ break;
+ case CURSOR_DRAG:
+ fallback = "grabbing";
+ break;
+ case CURSOR_CAN_DROP:
+ fallback = "hand1";
+ break;
+ case CURSOR_FORBIDDEN:
+ fallback = "forbidden";
+ break;
+ case CURSOR_VSIZE:
+ fallback = "ns-resize";
+ break;
+ case CURSOR_HSIZE:
+ fallback = "ew-resize";
+ break;
+ case CURSOR_BDIAGSIZE:
+ fallback = "fd_double_arrow";
+ break;
+ case CURSOR_FDIAGSIZE:
+ fallback = "bd_double_arrow";
+ break;
+ case CURSOR_MOVE:
+ img[i] = img[CURSOR_DRAG];
+ break;
+ case CURSOR_VSPLIT:
+ fallback = "sb_v_double_arrow";
+ break;
+ case CURSOR_HSPLIT:
+ fallback = "sb_h_double_arrow";
+ break;
+ case CURSOR_HELP:
+ fallback = "help";
+ break;
+ }
+ if (fallback != NULL) {
+ img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size);
+ }
+ }
if (img[i]) {
cursors[i] = XcursorImageLoadCursor(x11_display, img[i]);
} else {
@@ -604,8 +659,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
#endif
_ensure_user_data_dir();
- power_manager = memnew(PowerX11);
-
if (p_desired.layered) {
set_window_per_pixel_transparency_enabled(true);
}
@@ -669,14 +722,8 @@ bool OS_X11::refresh_device_info() {
int range_max_x = 0;
int range_max_y = 0;
int pressure_resolution = 0;
- int pressure_min = 0;
- int pressure_max = 0;
int tilt_resolution_x = 0;
int tilt_resolution_y = 0;
- int tilt_range_min_x = 0;
- int tilt_range_min_y = 0;
- int tilt_range_max_x = 0;
- int tilt_range_max_y = 0;
for (int j = 0; j < dev->num_classes; j++) {
#ifdef TOUCH_ENABLED
if (dev->classes[j]->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) {
@@ -697,17 +744,14 @@ bool OS_X11::refresh_device_info() {
range_max_y = class_info->max;
absolute_mode = true;
} else if (class_info->number == VALUATOR_PRESSURE && class_info->mode == XIModeAbsolute) {
- pressure_resolution = class_info->resolution;
- pressure_min = class_info->min;
- pressure_max = class_info->max;
+ pressure_resolution = (class_info->max - class_info->min);
+ if (pressure_resolution == 0) pressure_resolution = 1;
} else if (class_info->number == VALUATOR_TILTX && class_info->mode == XIModeAbsolute) {
- tilt_resolution_x = class_info->resolution;
- tilt_range_min_x = class_info->min;
- tilt_range_max_x = class_info->max;
+ tilt_resolution_x = (class_info->max - class_info->min);
+ if (tilt_resolution_x == 0) tilt_resolution_x = 1;
} else if (class_info->number == VALUATOR_TILTY && class_info->mode == XIModeAbsolute) {
- tilt_resolution_y = class_info->resolution;
- tilt_range_min_y = class_info->min;
- tilt_range_max_y = class_info->max;
+ tilt_resolution_y = (class_info->max - class_info->min);
+ if (tilt_resolution_y == 0) tilt_resolution_y = 1;
}
}
}
@@ -728,15 +772,6 @@ bool OS_X11::refresh_device_info() {
print_verbose("XInput: Absolute pointing device: " + String(dev->name));
}
- if (pressure_resolution <= 0) {
- pressure_resolution = (pressure_max - pressure_min);
- }
- if (tilt_resolution_x <= 0) {
- tilt_resolution_x = (tilt_range_max_x - tilt_range_min_x);
- }
- if (tilt_resolution_y <= 0) {
- tilt_resolution_y = (tilt_range_max_y - tilt_range_min_y);
- }
xi.pressure = 0;
xi.pen_devices[dev->deviceid] = Vector3(pressure_resolution, tilt_resolution_x, tilt_resolution_y);
}
@@ -832,9 +867,26 @@ void OS_X11::finalize() {
cursors_cache.clear();
visual_server->finish();
memdelete(visual_server);
- //memdelete(rasterizer);
- memdelete(power_manager);
+#if defined(OPENGL_ENABLED)
+ if (video_driver_index == VIDEO_DRIVER_GLES2) {
+
+ if (context_gles2)
+ memdelete(context_gles2);
+ }
+#endif
+#if defined(VULKAN_ENABLED)
+ if (video_driver_index == VIDEO_DRIVER_VULKAN) {
+
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ }
+
+ if (context_vulkan)
+ memdelete(context_vulkan);
+ }
+#endif
if (xrandr_handle)
dlclose(xrandr_handle);
@@ -842,9 +894,6 @@ void OS_X11::finalize() {
XUnmapWindow(x11_display, x11_window);
XDestroyWindow(x11_display, x11_window);
-#if defined(OPENGL_ENABLED)
- memdelete(context_gl);
-#endif
for (int i = 0; i < CURSOR_MAX; i++) {
if (cursors[i] != None)
XFreeCursor(x11_display, cursors[i]);
@@ -1429,11 +1478,15 @@ void OS_X11::set_window_fullscreen(bool p_enabled) {
set_window_maximized(true);
}
set_wm_fullscreen(p_enabled);
- if (!p_enabled && !current_videomode.always_on_top) {
+ if (!p_enabled && current_videomode.always_on_top) {
// Restore
set_window_maximized(false);
}
-
+ if (!p_enabled) {
+ set_window_position(last_position_before_fs);
+ } else {
+ last_position_before_fs = get_window_position();
+ }
current_videomode.fullscreen = p_enabled;
}
@@ -1835,6 +1888,8 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
if (status == XLookupChars) {
bool keypress = xkeyevent->type == KeyPress;
unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode);
+ unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode);
+
if (keycode >= 'a' && keycode <= 'z')
keycode -= 'a' - 'A';
@@ -1843,23 +1898,29 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
for (int i = 0; i < tmp.length(); i++) {
Ref<InputEventKey> k;
k.instance();
- if (keycode == 0 && tmp[i] == 0) {
+ if (physical_keycode == 0 && keycode == 0 && tmp[i] == 0) {
continue;
}
+ if (keycode == 0)
+ keycode = physical_keycode;
+
get_key_modifier_state(xkeyevent->state, k);
k->set_unicode(tmp[i]);
k->set_pressed(keypress);
- k->set_scancode(keycode);
+ k->set_keycode(keycode);
+
+ k->set_physical_keycode(physical_keycode);
k->set_echo(false);
- if (k->get_scancode() == KEY_BACKTAB) {
+ if (k->get_keycode() == KEY_BACKTAB) {
//make it consistent across platforms.
- k->set_scancode(KEY_TAB);
+ k->set_keycode(KEY_TAB);
+ k->set_physical_keycode(KEY_TAB);
k->set_shift(true);
}
@@ -1889,6 +1950,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// keysym, so it works in all platforms the same.
unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode);
+ unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode);
/* Phase 3, obtain a unicode character from the keysym */
@@ -1908,9 +1970,12 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
bool keypress = xkeyevent->type == KeyPress;
- if (keycode == 0 && unicode == 0)
+ if (physical_keycode == 0 && keycode == 0 && unicode == 0)
return;
+ if (keycode == 0)
+ keycode = physical_keycode;
+
/* Phase 5, determine modifier mask */
// No problems here, except I had no way to
@@ -1947,8 +2012,10 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// is correct, but the xorg developers are
// not very helpful today.
- ::Time tresh = ABSDIFF(peek_event.xkey.time, xkeyevent->time);
- if (peek_event.type == KeyPress && tresh < 5) {
+#define ABSDIFF(x, y) (((x) < (y)) ? ((y) - (x)) : ((x) - (y)))
+ ::Time threshold = ABSDIFF(peek_event.xkey.time, xkeyevent->time);
+#undef ABSDIFF
+ if (peek_event.type == KeyPress && threshold < 5) {
KeySym rk;
XLookupString((XKeyEvent *)&peek_event, str, 256, &rk, NULL);
if (rk == keysym_keycode) {
@@ -1972,37 +2039,39 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
if (keycode >= 'a' && keycode <= 'z')
keycode -= 'a' - 'A';
- k->set_scancode(keycode);
+ k->set_keycode(keycode);
+ k->set_physical_keycode(physical_keycode);
k->set_unicode(unicode);
k->set_echo(p_echo);
- if (k->get_scancode() == KEY_BACKTAB) {
+ if (k->get_keycode() == KEY_BACKTAB) {
//make it consistent across platforms.
- k->set_scancode(KEY_TAB);
+ k->set_keycode(KEY_TAB);
+ k->set_physical_keycode(KEY_TAB);
k->set_shift(true);
}
//don't set mod state if modifier keys are released by themselves
//else event.is_action() will not work correctly here
if (!k->is_pressed()) {
- if (k->get_scancode() == KEY_SHIFT)
+ if (k->get_keycode() == KEY_SHIFT)
k->set_shift(false);
- else if (k->get_scancode() == KEY_CONTROL)
+ else if (k->get_keycode() == KEY_CONTROL)
k->set_control(false);
- else if (k->get_scancode() == KEY_ALT)
+ else if (k->get_keycode() == KEY_ALT)
k->set_alt(false);
- else if (k->get_scancode() == KEY_META)
+ else if (k->get_keycode() == KEY_META)
k->set_metakey(false);
}
- bool last_is_pressed = Input::get_singleton()->is_key_pressed(k->get_scancode());
+ bool last_is_pressed = Input::get_singleton()->is_key_pressed(k->get_keycode());
if (k->is_pressed()) {
if (last_is_pressed) {
k->set_echo(true);
}
}
- //printf("key: %x\n",k->get_scancode());
+ //printf("key: %x\n",k->get_keycode());
input->accumulate_input_event(k);
}
@@ -2082,6 +2151,12 @@ void OS_X11::_window_changed(XEvent *event) {
current_videomode.width = event->xconfigure.width;
current_videomode.height = event->xconfigure.height;
+
+#if defined(VULKAN_ENABLED)
+ if (video_driver_index == VIDEO_DRIVER_VULKAN) {
+ context_vulkan->window_resize(0, current_videomode.width, current_videomode.height);
+ }
+#endif
}
void OS_X11::process_xevents() {
@@ -2959,7 +3034,7 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
if (p_cursor.is_valid()) {
- Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape);
+ Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
if (cursor_c) {
if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
@@ -2970,7 +3045,7 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
cursors_cache.erase(p_shape);
}
- Ref<Texture> texture = p_cursor;
+ Ref<Texture2D> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
Size2 texture_size;
@@ -3017,8 +3092,6 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
// allocate memory to contain the whole file
cursor_image->pixels = (XcursorPixel *)memalloc(size);
- image->lock();
-
for (XcursorPixel index = 0; index < image_size; index++) {
int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
@@ -3031,8 +3104,6 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
*(cursor_image->pixels + index) = image->get_pixel(column_index, row_index).to_argb32();
}
- image->unlock();
-
ERR_FAIL_COND(cursor_image->pixels == NULL);
// Save it for a further usage
@@ -3066,24 +3137,33 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
}
void OS_X11::release_rendering_thread() {
-
#if defined(OPENGL_ENABLED)
- context_gl->release_current();
+ if (video_driver_index == VIDEO_DRIVER_GLES2) {
+ context_gles2->release_current();
+ }
#endif
}
void OS_X11::make_rendering_thread() {
-
#if defined(OPENGL_ENABLED)
- context_gl->make_current();
+ if (video_driver_index == VIDEO_DRIVER_GLES2) {
+ context_gles2->make_current();
+ }
#endif
}
void OS_X11::swap_buffers() {
-
#if defined(OPENGL_ENABLED)
- context_gl->swap_buffers();
+ if (video_driver_index == VIDEO_DRIVER_GLES2) {
+ context_gles2->swap_buffers();
+ }
#endif
+ /* not needed for now
+#if defined(VULKAN_ENABLED)
+ if (video_driver_index == VIDEO_DRIVER_VULKAN) {
+ context_vulkan->swap_buffers();
+ }
+#endif*/
}
void OS_X11::alert(const String &p_alert, const String &p_title) {
@@ -3201,10 +3281,10 @@ void OS_X11::set_icon(const Ref<Image> &p_icon) {
pd.write[0] = w;
pd.write[1] = h;
- PoolVector<uint8_t>::Read r = img->get_data().read();
+ const uint8_t *r = img->get_data().ptr();
long *wr = &pd.write[2];
- uint8_t const *pr = r.ptr();
+ uint8_t const *pr = r;
for (int i = 0; i < w * h; i++) {
long v = 0;
@@ -3271,19 +3351,13 @@ String OS_X11::get_joy_guid(int p_device) const {
void OS_X11::_set_use_vsync(bool p_enable) {
#if defined(OPENGL_ENABLED)
- if (context_gl)
- context_gl->set_use_vsync(p_enable);
+ if (video_driver_index == VIDEO_DRIVER_GLES2) {
+ if (context_gles2)
+ context_gles2->set_use_vsync(p_enable);
+ }
#endif
}
-/*
-bool OS_X11::is_vsync_enabled() const {
- if (context_gl)
- return context_gl->is_using_vsync();
-
- return true;
-}
-*/
void OS_X11::set_context(int p_context) {
XClassHint *classHint = XAllocClassHint();
@@ -3323,18 +3397,6 @@ void OS_X11::set_context(int p_context) {
}
}
-OS::PowerState OS_X11::get_power_state() {
- return power_manager->get_power_state();
-}
-
-int OS_X11::get_power_seconds_left() {
- return power_manager->get_power_seconds_left();
-}
-
-int OS_X11::get_power_percent_left() {
- return power_manager->get_power_percent_left();
-}
-
void OS_X11::disable_crash_handler() {
crash_handler.disable();
}
@@ -3402,7 +3464,7 @@ Error OS_X11::move_to_trash(const String &p_path) {
// Issue an error if none of the previous locations is appropriate for the trash can.
if (trash_can == "") {
- ERR_PRINTS("move_to_trash: Could not determine the trash can location");
+ ERR_PRINT("move_to_trash: Could not determine the trash can location");
return FAILED;
}
@@ -3413,7 +3475,7 @@ Error OS_X11::move_to_trash(const String &p_path) {
// Issue an error if trash can is not created proprely.
if (err != OK) {
- ERR_PRINTS("move_to_trash: Could not create the trash can \"" + trash_can + "\"");
+ ERR_PRINT("move_to_trash: Could not create the trash can \"" + trash_can + "\"");
return err;
}
@@ -3427,7 +3489,7 @@ Error OS_X11::move_to_trash(const String &p_path) {
// Issue an error if "mv" failed to move the given resource to the trash can.
if (err != OK || retval != 0) {
- ERR_PRINTS("move_to_trash: Could not move the resource \"" + p_path + "\" to the trash can \"" + trash_can + "\"");
+ ERR_PRINT("move_to_trash: Could not move the resource \"" + p_path + "\" to the trash can \"" + trash_can + "\"");
return FAILED;
}
@@ -3502,4 +3564,5 @@ OS_X11::OS_X11() {
window_focused = true;
xim_style = 0L;
mouse_mode = MOUSE_MODE_VISIBLE;
+ last_position_before_fs = Vector2();
}
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 01e5aac3df..997a6cc053 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -31,7 +31,6 @@
#ifndef OS_X11_H
#define OS_X11_H
-#include "context_gl_x11.h"
#include "core/os/input.h"
#include "crash_handler_x11.h"
#include "drivers/alsa/audio_driver_alsa.h"
@@ -40,11 +39,18 @@
#include "drivers/unix/os_unix.h"
#include "joypad_linux.h"
#include "main/input_default.h"
-#include "power_x11.h"
#include "servers/audio_server.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual_server.h"
-//#include "servers/visual/visual_server_wrap_mt.h"
+
+#if defined(OPENGL_ENABLED)
+#include "context_gl_x11.h"
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "drivers/vulkan/rendering_device_vulkan.h"
+#include "platform/x11/vulkan_context_x11.h"
+#endif
#include <X11/Xcursor/Xcursor.h>
#include <X11/Xlib.h>
@@ -92,8 +98,13 @@ class OS_X11 : public OS_Unix {
int xdnd_version;
#if defined(OPENGL_ENABLED)
- ContextGL_X11 *context_gl;
+ ContextGL_X11 *context_gles2;
+#endif
+#if defined(VULKAN_ENABLED)
+ VulkanContextX11 *context_vulkan;
+ RenderingDeviceVulkan *rendering_device_vulkan;
#endif
+
//Rasterizer *rasterizer;
VisualServer *visual_server;
VideoMode current_videomode;
@@ -115,6 +126,7 @@ class OS_X11 : public OS_Unix {
// IME
bool im_active;
Vector2 im_position;
+ Vector2 last_position_before_fs;
Size2 min_size;
Size2 max_size;
@@ -167,7 +179,7 @@ class OS_X11 : public OS_Unix {
Cursor cursors[CURSOR_MAX];
Cursor null_cursor;
CursorShape current_cursor;
- Map<CursorShape, Vector<Variant> > cursors_cache;
+ Map<CursorShape, Vector<Variant>> cursors_cache;
InputDefault *input;
@@ -187,8 +199,6 @@ class OS_X11 : public OS_Unix {
AudioDriverPulseAudio driver_pulseaudio;
#endif
- PowerX11 *power_manager;
-
bool layered_window;
CrashHandler crash_handler;
@@ -310,10 +320,6 @@ public:
virtual void _set_use_vsync(bool p_enable);
//virtual bool is_vsync_enabled() const;
- virtual OS::PowerState get_power_state();
- virtual int get_power_seconds_left();
- virtual int get_power_percent_left();
-
virtual bool _check_internal_feature_support(const String &p_feature);
virtual void force_process_input();
diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h
index c905ddb236..ac30519132 100644
--- a/platform/x11/platform_config.h
+++ b/platform/x11/platform_config.h
@@ -36,5 +36,4 @@
#define PTHREAD_BSD_SET_NAME
#endif
-#define GLES3_INCLUDE_H "thirdparty/glad/glad/glad.h"
#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h"
diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp
deleted file mode 100644
index 5ac5e8e87b..0000000000
--- a/platform/x11/power_x11.cpp
+++ /dev/null
@@ -1,577 +0,0 @@
-/*************************************************************************/
-/* power_x11.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-/*
-Adapted from corresponding SDL 2.0 code.
-*/
-
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "power_x11.h"
-
-#include <stdio.h>
-#include <unistd.h>
-
-#include "core/error_macros.h"
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-// CODE CHUNK IMPORTED FROM SDL 2.0
-
-static const char *proc_apm_path = "/proc/apm";
-static const char *proc_acpi_battery_path = "/proc/acpi/battery";
-static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter";
-static const char *sys_class_power_supply_path = "/sys/class/power_supply";
-
-FileAccessRef PowerX11::open_power_file(const char *base, const char *node, const char *key) {
- String path = String(base) + String("/") + String(node) + String("/") + String(key);
- FileAccessRef f = FileAccess::open(path, FileAccess::READ);
- return f;
-}
-
-bool PowerX11::read_power_file(const char *base, const char *node, const char *key, char *buf, size_t buflen) {
- ssize_t br = 0;
- FileAccessRef fd = open_power_file(base, node, key);
- if (!fd) {
- return false;
- }
- br = fd->get_buffer(reinterpret_cast<uint8_t *>(buf), buflen - 1);
- fd->close();
- if (br < 0) {
- return false;
- }
- buf[br] = '\0'; // null-terminate the string
- return true;
-}
-
-bool PowerX11::make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) {
- char *ptr = *_ptr;
-
- while (*ptr == ' ') {
- ptr++; /* skip whitespace. */
- }
-
- if (*ptr == '\0') {
- return false; /* EOF. */
- }
-
- *_key = ptr;
-
- while ((*ptr != ':') && (*ptr != '\0')) {
- ptr++;
- }
-
- if (*ptr == '\0') {
- return false; /* (unexpected) EOF. */
- }
-
- *(ptr++) = '\0'; /* terminate the key. */
-
- while (*ptr == ' ') {
- ptr++; /* skip whitespace. */
- }
-
- if (*ptr == '\0') {
- return false; /* (unexpected) EOF. */
- }
-
- *_val = ptr;
-
- while ((*ptr != '\n') && (*ptr != '\0')) {
- ptr++;
- }
-
- if (*ptr != '\0') {
- *(ptr++) = '\0'; /* terminate the value. */
- }
-
- *_ptr = ptr; /* store for next time. */
- return true;
-}
-
-void PowerX11::check_proc_acpi_battery(const char *node, bool *have_battery, bool *charging) {
- const char *base = proc_acpi_battery_path;
- char info[1024];
- char state[1024];
- char *ptr = NULL;
- char *key = NULL;
- char *val = NULL;
- bool charge = false;
- bool choose = false;
- int maximum = -1;
- int remaining = -1;
- int secs = -1;
- int pct = -1;
-
- if (!read_power_file(base, node, "state", state, sizeof(state))) {
- return;
- } else {
- if (!read_power_file(base, node, "info", info, sizeof(info)))
- return;
- }
-
- ptr = &state[0];
- while (make_proc_acpi_key_val(&ptr, &key, &val)) {
- if (String(key) == "present") {
- if (String(val) == "yes") {
- *have_battery = true;
- }
- } else if (String(key) == "charging state") {
- /* !!! FIXME: what exactly _does_ charging/discharging mean? */
- if (String(val) == "charging/discharging") {
- charge = true;
- } else if (String(val) == "charging") {
- charge = true;
- }
- } else if (String(key) == "remaining capacity") {
- String sval = val;
- const int cvt = sval.to_int();
- remaining = cvt;
- }
- }
-
- ptr = &info[0];
- while (make_proc_acpi_key_val(&ptr, &key, &val)) {
- if (String(key) == "design capacity") {
- String sval = val;
- const int cvt = sval.to_int();
- maximum = cvt;
- }
- }
-
- if ((maximum >= 0) && (remaining >= 0)) {
- pct = (int)((((float)remaining) / ((float)maximum)) * 100.0f);
- if (pct < 0) {
- pct = 0;
- } else if (pct > 100) {
- pct = 100;
- }
- }
-
- /* !!! FIXME: calculate (secs). */
-
- /*
- * We pick the battery that claims to have the most minutes left.
- * (failing a report of minutes, we'll take the highest percent.)
- */
- // -- GODOT start --
- //if ((secs < 0) && (this->nsecs_left < 0)) {
- if (this->nsecs_left < 0) {
- // -- GODOT end --
- if ((pct < 0) && (this->percent_left < 0)) {
- choose = true; /* at least we know there's a battery. */
- }
- if (pct > this->percent_left) {
- choose = true;
- }
- } else if (secs > this->nsecs_left) {
- choose = true;
- }
-
- if (choose) {
- this->nsecs_left = secs;
- this->percent_left = pct;
- *charging = charge;
- }
-}
-
-void PowerX11::check_proc_acpi_ac_adapter(const char *node, bool *have_ac) {
- const char *base = proc_acpi_ac_adapter_path;
- char state[256];
- char *ptr = NULL;
- char *key = NULL;
- char *val = NULL;
-
- if (!read_power_file(base, node, "state", state, sizeof(state))) {
- return;
- }
-
- ptr = &state[0];
- while (make_proc_acpi_key_val(&ptr, &key, &val)) {
- String skey = key;
- if (skey == "state") {
- String sval = val;
- if (sval == "on-line") {
- *have_ac = true;
- }
- }
- }
-}
-
-bool PowerX11::GetPowerInfo_Linux_proc_acpi() {
- String node;
- DirAccess *dirp = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- bool have_battery = false;
- bool have_ac = false;
- bool charging = false;
-
- this->nsecs_left = -1;
- this->percent_left = -1;
- this->power_state = OS::POWERSTATE_UNKNOWN;
-
- dirp->change_dir(proc_acpi_battery_path);
- Error err = dirp->list_dir_begin();
-
- if (err != OK) {
- return false; /* can't use this interface. */
- } else {
- node = dirp->get_next();
- while (node != "") {
- check_proc_acpi_battery(node.utf8().get_data(), &have_battery, &charging /*, seconds, percent*/);
- node = dirp->get_next();
- }
- }
- dirp->change_dir(proc_acpi_ac_adapter_path);
- err = dirp->list_dir_begin();
- if (err != OK) {
- return false; /* can't use this interface. */
- } else {
- node = dirp->get_next();
- while (node != "") {
- check_proc_acpi_ac_adapter(node.utf8().get_data(), &have_ac);
- node = dirp->get_next();
- }
- }
-
- if (!have_battery) {
- this->power_state = OS::POWERSTATE_NO_BATTERY;
- } else if (charging) {
- this->power_state = OS::POWERSTATE_CHARGING;
- } else if (have_ac) {
- this->power_state = OS::POWERSTATE_CHARGED;
- } else {
- this->power_state = OS::POWERSTATE_ON_BATTERY;
- }
-
- memdelete(dirp);
- return true; /* definitive answer. */
-}
-
-bool PowerX11::next_string(char **_ptr, char **_str) {
- char *ptr = *_ptr;
- char *str = *_str;
-
- while (*ptr == ' ') { /* skip any spaces... */
- ptr++;
- }
-
- if (*ptr == '\0') {
- return false;
- }
-
- str = ptr;
- while ((*ptr != ' ') && (*ptr != '\n') && (*ptr != '\0'))
- ptr++;
-
- if (*ptr != '\0')
- *(ptr++) = '\0';
-
- *_str = str;
- *_ptr = ptr;
- return true;
-}
-
-bool PowerX11::int_string(char *str, int *val) {
- String sval = str;
- *val = sval.to_int();
- return (*str != '\0');
-}
-
-/* http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c */
-bool PowerX11::GetPowerInfo_Linux_proc_apm() {
- bool need_details = false;
- int ac_status = 0;
- int battery_status = 0;
- int battery_flag = 0;
- int battery_percent = 0;
- int battery_time = 0;
- FileAccessRef fd = FileAccess::open(proc_apm_path, FileAccess::READ);
- char buf[128];
- char *ptr = &buf[0];
- char *str = NULL;
- ssize_t br;
-
- if (!fd) {
- return false; /* can't use this interface. */
- }
-
- br = fd->get_buffer(reinterpret_cast<uint8_t *>(buf), sizeof(buf) - 1);
- fd->close();
-
- if (br < 0) {
- return false;
- }
-
- buf[br] = '\0'; /* null-terminate the string. */
- if (!next_string(&ptr, &str)) { /* driver version */
- return false;
- }
- if (!next_string(&ptr, &str)) { /* BIOS version */
- return false;
- }
- if (!next_string(&ptr, &str)) { /* APM flags */
- return false;
- }
-
- if (!next_string(&ptr, &str)) { /* AC line status */
- return false;
- } else if (!int_string(str, &ac_status)) {
- return false;
- }
-
- if (!next_string(&ptr, &str)) { /* battery status */
- return false;
- } else if (!int_string(str, &battery_status)) {
- return false;
- }
- if (!next_string(&ptr, &str)) { /* battery flag */
- return false;
- } else if (!int_string(str, &battery_flag)) {
- return false;
- }
- if (!next_string(&ptr, &str)) { /* remaining battery life percent */
- return false;
- }
- String sstr = str;
- if (sstr[sstr.length() - 1] == '%') {
- sstr[sstr.length() - 1] = '\0';
- }
- if (!int_string(str, &battery_percent)) {
- return false;
- }
-
- if (!next_string(&ptr, &str)) { /* remaining battery life time */
- return false;
- } else if (!int_string(str, &battery_time)) {
- return false;
- }
-
- if (!next_string(&ptr, &str)) { /* remaining battery life time units */
- return false;
- } else if (String(str) == "min") {
- battery_time *= 60;
- }
-
- if (battery_flag == 0xFF) { /* unknown state */
- this->power_state = OS::POWERSTATE_UNKNOWN;
- } else if (battery_flag & (1 << 7)) { /* no battery */
- this->power_state = OS::POWERSTATE_NO_BATTERY;
- } else if (battery_flag & (1 << 3)) { /* charging */
- this->power_state = OS::POWERSTATE_CHARGING;
- need_details = true;
- } else if (ac_status == 1) {
- this->power_state = OS::POWERSTATE_CHARGED; /* on AC, not charging. */
- need_details = true;
- } else {
- this->power_state = OS::POWERSTATE_ON_BATTERY;
- need_details = true;
- }
-
- this->percent_left = -1;
- this->nsecs_left = -1;
- if (need_details) {
- const int pct = battery_percent;
- const int secs = battery_time;
-
- if (pct >= 0) { /* -1 == unknown */
- this->percent_left = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
- }
- if (secs >= 0) { /* -1 == unknown */
- this->nsecs_left = secs;
- }
- }
-
- return true;
-}
-
-/* !!! FIXME: implement d-bus queries to org.freedesktop.UPower. */
-
-bool PowerX11::GetPowerInfo_Linux_sys_class_power_supply(/*PowerState *state, int *seconds, int *percent*/) {
- const char *base = sys_class_power_supply_path;
- String name;
-
- DirAccess *dirp = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- dirp->change_dir(base);
- Error err = dirp->list_dir_begin();
-
- if (err != OK) {
- return false;
- }
-
- this->power_state = OS::POWERSTATE_NO_BATTERY; /* assume we're just plugged in. */
- this->nsecs_left = -1;
- this->percent_left = -1;
-
- name = dirp->get_next();
-
- while (name != "") {
- bool choose = false;
- char str[64];
- OS::PowerState st;
- int secs;
- int pct;
-
- if ((name == ".") || (name == "..")) {
- name = dirp->get_next();
- continue; //skip these, of course.
- } else {
- if (!read_power_file(base, name.utf8().get_data(), "type", str, sizeof(str))) {
- name = dirp->get_next();
- continue; // Don't know _what_ we're looking at. Give up on it.
- } else {
- if (String(str) != "Battery\n") {
- name = dirp->get_next();
- continue; // we don't care about UPS and such.
- }
- }
- }
-
- /* some drivers don't offer this, so if it's not explicitly reported assume it's present. */
- if (read_power_file(base, name.utf8().get_data(), "present", str, sizeof(str)) && (String(str) == "0\n")) {
- st = OS::POWERSTATE_NO_BATTERY;
- } else if (!read_power_file(base, name.utf8().get_data(), "status", str, sizeof(str))) {
- st = OS::POWERSTATE_UNKNOWN; /* uh oh */
- } else if (String(str) == "Charging\n") {
- st = OS::POWERSTATE_CHARGING;
- } else if (String(str) == "Discharging\n") {
- st = OS::POWERSTATE_ON_BATTERY;
- } else if ((String(str) == "Full\n") || (String(str) == "Not charging\n")) {
- st = OS::POWERSTATE_CHARGED;
- } else {
- st = OS::POWERSTATE_UNKNOWN; /* uh oh */
- }
-
- if (!read_power_file(base, name.utf8().get_data(), "capacity", str, sizeof(str))) {
- pct = -1;
- } else {
- pct = String(str).to_int();
- pct = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
- }
-
- if (!read_power_file(base, name.utf8().get_data(), "time_to_empty_now", str, sizeof(str))) {
- secs = -1;
- } else {
- secs = String(str).to_int();
- secs = (secs <= 0) ? -1 : secs; /* 0 == unknown */
- }
-
- /*
- * We pick the battery that claims to have the most minutes left.
- * (failing a report of minutes, we'll take the highest percent.)
- */
- if ((secs < 0) && (this->nsecs_left < 0)) {
- if ((pct < 0) && (this->percent_left < 0)) {
- choose = true; /* at least we know there's a battery. */
- } else if (pct > this->percent_left) {
- choose = true;
- }
- } else if (secs > this->nsecs_left) {
- choose = true;
- }
-
- if (choose) {
- this->nsecs_left = secs;
- this->percent_left = pct;
- this->power_state = st;
- }
-
- name = dirp->get_next();
- }
-
- memdelete(dirp);
- return true; /* don't look any further*/
-}
-
-bool PowerX11::UpdatePowerInfo() {
- if (GetPowerInfo_Linux_sys_class_power_supply()) { // try method 1
- return true;
- }
- if (GetPowerInfo_Linux_proc_acpi()) { // try further
- return true;
- }
- if (GetPowerInfo_Linux_proc_apm()) { // try even further
- return true;
- }
- return false;
-}
-
-PowerX11::PowerX11() :
- nsecs_left(-1),
- percent_left(-1),
- power_state(OS::POWERSTATE_UNKNOWN) {
-}
-
-PowerX11::~PowerX11() {
-}
-
-OS::PowerState PowerX11::get_power_state() {
- if (UpdatePowerInfo()) {
- return power_state;
- } else {
- return OS::POWERSTATE_UNKNOWN;
- }
-}
-
-int PowerX11::get_power_seconds_left() {
- if (UpdatePowerInfo()) {
- return nsecs_left;
- } else {
- return -1;
- }
-}
-
-int PowerX11::get_power_percent_left() {
- if (UpdatePowerInfo()) {
- return percent_left;
- } else {
- return -1;
- }
-}
diff --git a/platform/x11/vulkan_context_x11.cpp b/platform/x11/vulkan_context_x11.cpp
new file mode 100644
index 0000000000..602dbc77a2
--- /dev/null
+++ b/platform/x11/vulkan_context_x11.cpp
@@ -0,0 +1,57 @@
+/*************************************************************************/
+/* vulkan_context_x11.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "vulkan_context_x11.h"
+#include <vulkan/vulkan_xlib.h>
+
+const char *VulkanContextX11::_get_platform_surface_extension() const {
+ return VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
+}
+
+int VulkanContextX11::window_create(::Window p_window, Display *p_display, int p_width, int p_height) {
+
+ VkXlibSurfaceCreateInfoKHR createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.dpy = p_display;
+ createInfo.window = p_window;
+
+ VkSurfaceKHR surface;
+ VkResult err = vkCreateXlibSurfaceKHR(_get_instance(), &createInfo, NULL, &surface);
+ ERR_FAIL_COND_V(err, -1);
+ return _window_create(surface, p_width, p_height);
+}
+
+VulkanContextX11::VulkanContextX11() {
+}
+
+VulkanContextX11::~VulkanContextX11() {
+}
diff --git a/platform/x11/power_x11.h b/platform/x11/vulkan_context_x11.h
index 76f20c68e8..573f994ea6 100644
--- a/platform/x11/power_x11.h
+++ b/platform/x11/vulkan_context_x11.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* power_x11.h */
+/* vulkan_context_x11.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,39 +28,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef POWER_X11_H
-#define POWER_X11_H
+#ifndef VULKAN_DEVICE_X11_H
+#define VULKAN_DEVICE_X11_H
-#include "core/os/dir_access.h"
-#include "core/os/file_access.h"
-#include "core/os/os.h"
+#include "drivers/vulkan/vulkan_context.h"
+#include <X11/Xlib.h>
-class PowerX11 {
+class VulkanContextX11 : public VulkanContext {
-private:
- int nsecs_left;
- int percent_left;
- OS::PowerState power_state;
-
- FileAccessRef open_power_file(const char *base, const char *node, const char *key);
- bool read_power_file(const char *base, const char *node, const char *key, char *buf, size_t buflen);
- bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val);
- void check_proc_acpi_battery(const char *node, bool *have_battery, bool *charging);
- void check_proc_acpi_ac_adapter(const char *node, bool *have_ac);
- bool GetPowerInfo_Linux_proc_acpi();
- bool next_string(char **_ptr, char **_str);
- bool int_string(char *str, int *val);
- bool GetPowerInfo_Linux_proc_apm();
- bool GetPowerInfo_Linux_sys_class_power_supply();
- bool UpdatePowerInfo();
+ virtual const char *_get_platform_surface_extension() const;
public:
- PowerX11();
- virtual ~PowerX11();
+ int window_create(::Window p_window, Display *p_display, int p_width, int p_height);
- OS::PowerState get_power_state();
- int get_power_seconds_left();
- int get_power_percent_left();
+ VulkanContextX11();
+ ~VulkanContextX11();
};
-#endif // POWER_X11_H
+#endif // VULKAN_DEVICE_X11_H