[vulkan linux] Fix native_platform_handle with gtk
Use gtk connection as handle and use it when creating surface.
This commit is contained in:
parent
f1b9e1afce
commit
d146e31921
|
@ -71,10 +71,6 @@ bool VulkanContext::Initialize() {
|
|||
#ifdef GDK_WINDOWING_X11
|
||||
GtkWidget* window_handle =
|
||||
static_cast<GtkWidget*>(target_window_->native_handle());
|
||||
GdkDisplay* gdk_display = gtk_widget_get_display(window_handle);
|
||||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window =
|
||||
gdk_x11_window_get_xid(gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
|
|
|
@ -81,6 +81,10 @@ void GTKWindow::Create() {
|
|||
NULL);
|
||||
g_signal_connect(G_OBJECT(window_), "event", G_CALLBACK(gtk_event_handler_),
|
||||
reinterpret_cast<gpointer>(this));
|
||||
|
||||
GdkDisplay* gdk_display = gtk_widget_get_display(window_);
|
||||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
connection_ = XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
}
|
||||
|
||||
bool GTKWindow::OnCreate() {
|
||||
|
|
|
@ -28,7 +28,7 @@ class GTKWindow : public Window {
|
|||
~GTKWindow() override;
|
||||
|
||||
NativePlatformHandle native_platform_handle() const override {
|
||||
return nullptr;
|
||||
return connection_;
|
||||
}
|
||||
NativeWindowHandle native_handle() const override { return window_; }
|
||||
|
||||
|
@ -67,6 +67,7 @@ class GTKWindow : public Window {
|
|||
private:
|
||||
void Create();
|
||||
GtkWidget* window_;
|
||||
xcb_connection_t* connection_;
|
||||
|
||||
friend void gtk_event_handler_(GtkWidget*, GdkEvent*, gpointer);
|
||||
bool HandleMouse(GdkEventAny* event);
|
||||
|
|
Loading…
Reference in New Issue