Replace Xlib with xcb

This commit is contained in:
Robbert van der Helm
2020-03-17 22:08:44 +01:00
parent e2d8c0883f
commit 70ebb5d243
4 changed files with 15 additions and 6 deletions
+1
View File
@@ -67,6 +67,7 @@ the following dependencies:
- gcc (tested using GCC 9.2) - gcc (tested using GCC 9.2)
- A Wine installation with `wiengcc` and the development headers. - A Wine installation with `wiengcc` and the development headers.
- Boost - Boost
- xcb
The following dependencies are included as a Meson wrap: The following dependencies are included as a Meson wrap:
+2 -2
View File
@@ -32,7 +32,7 @@ bitsery_dep = subproject('bitsery').get_variable('bitsery_dep')
threads_dep = dependency('threads') threads_dep = dependency('threads')
# The built in threads dependency does not know how to handle winegcc # The built in threads dependency does not know how to handle winegcc
wine_threads_dep = declare_dependency(link_args : '-lpthread') wine_threads_dep = declare_dependency(link_args : '-lpthread')
x11_dep = dependency('x11') xcb_dep = dependency('xcb')
include_dir = include_directories('src/include') include_dir = include_directories('src/include')
@@ -62,7 +62,7 @@ executable(
], ],
native : false, native : false,
include_directories : include_dir, include_directories : include_dir,
dependencies : [boost_dep, bitsery_dep, wine_threads_dep, x11_dep], dependencies : [boost_dep, bitsery_dep, wine_threads_dep, xcb_dep],
cpp_args : compiler_options, cpp_args : compiler_options,
link_args : [] link_args : []
) )
+7 -3
View File
@@ -3,7 +3,8 @@
ATOM register_window_class(std::string window_class_name); ATOM register_window_class(std::string window_class_name);
Win32Editor::Win32Editor(std::string window_class_name) Win32Editor::Win32Editor(std::string window_class_name)
: window_class(register_window_class(window_class_name)) {} : window_class(register_window_class(window_class_name)),
x11_connection(xcb_connect(nullptr, nullptr), &xcb_disconnect) {}
HWND Win32Editor::open() { HWND Win32Editor::open() {
window_handle = window_handle =
@@ -20,14 +21,17 @@ HWND Win32Editor::open() {
void Win32Editor::close() { void Win32Editor::close() {
// RAII does the rest for us // RAII does the rest for us
window_handle = std::nullopt; window_handle = std::nullopt;
// TODO: Do we need to do something on the X11 side or does the host do
// everything for us?
} }
std::optional<intptr_t> Win32Editor::get_x11_handle() { std::optional<xcb_window_t> Win32Editor::get_x11_handle() {
if (!window_handle.has_value()) { if (!window_handle.has_value()) {
return std::nullopt; return std::nullopt;
} }
return reinterpret_cast<intptr_t>( return reinterpret_cast<size_t>(
GetProp(window_handle.value().get(), "__wine_x11_whole_window")); GetProp(window_handle.value().get(), "__wine_x11_whole_window"));
} }
+5 -1
View File
@@ -1,3 +1,5 @@
#include <xcb/xcb.h>
#define NOMINMAX #define NOMINMAX
#define NOSERVICE #define NOSERVICE
#define NOMCX #define NOMCX
@@ -32,7 +34,7 @@ class Win32Editor {
/** /**
* Return the X11 window handle for the window if it's currently open. * Return the X11 window handle for the window if it's currently open.
*/ */
std::optional<intptr_t> get_x11_handle(); std::optional<xcb_window_t> get_x11_handle();
private: private:
ATOM window_class; ATOM window_class;
@@ -44,4 +46,6 @@ class Win32Editor {
std::optional< std::optional<
std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>> std::unique_ptr<std::remove_pointer_t<HWND>, decltype(&DestroyWindow)>>
window_handle; window_handle;
std::unique_ptr<xcb_connection_t, decltype(&xcb_disconnect)> x11_connection;
}; };