forked from wxWidgets/Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_ex.cpp
58 lines (48 loc) · 1.23 KB
/
window_ex.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef __WXGTK__
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#endif // ifdef __WXGTK__
wxUIntPtr wxPyGetWinHandle(const wxWindow* win)
{
#ifdef __WXMSW__
return (wxUIntPtr)win->GetHandle();
#endif
#ifdef __WXX11__
return (wxUIntPtr)win->GetHandle();
#endif
#ifdef __WXMAC__
return (wxUIntPtr)win->GetHandle();
#endif
#ifdef __WXGTK__
GtkWidget *gtk_widget = win->GetHandle();
if (!gtk_widget) {
return 0;
};
// gtk_widget_get_window disappears in GTK4; then it will be via
// gtk_widget_get_native() -> gtk_native_get_surface().
GdkWindow *window = gtk_widget_get_window(gtk_widget);
if (!window) {
return 0;
}
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_WINDOW(window)) {
return (wxUIntPtr)gdk_x11_window_get_xid(window);
}
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_WINDOW(window)) {
return (wxUIntPtr)gdk_wayland_window_get_wl_surface(window);
}
#endif
// Returning 0 on any other backend using GTK.
// This is less confusing than returning something else that might
// mismatch C++ GetHandle.
#endif
return 0;
}