Remove run-time dependencies on GTK3 backends for Wayland, Mir, Broadway
This allows running with a GTK+ library that was built with different backends than the one wxWidgets was built with. Since GTK3 provides no way to determine the backends available at run-time, avoid referencing symbols in the backends by checking the type name of the GdkDisplay, on the assumption that they are unlikely to ever be changed. The X11 backend is still required at run-time if it was available at build-time, although this dependency could also be removed.
This commit is contained in:
@@ -38,20 +38,6 @@
|
||||
#include <X11/Xatom.h> // XA_CARDINAL
|
||||
#include "wx/unix/utilsx11.h"
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include <gdk/gdkwayland.h>
|
||||
#define HAS_CLIENT_DECOR
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_MIR
|
||||
extern "C" {
|
||||
#include <gdk/gdkmir.h>
|
||||
}
|
||||
#define HAS_CLIENT_DECOR
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
#include <gdk/gdkbroadway.h>
|
||||
#define HAS_CLIENT_DECOR
|
||||
#endif
|
||||
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/gtk/private/gtk2-compat.h"
|
||||
@@ -80,25 +66,29 @@ static enum {
|
||||
static bool gs_decorCacheValid;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_CLIENT_DECOR
|
||||
#ifdef __WXGTK3__
|
||||
static bool HasClientDecor(GtkWidget* widget)
|
||||
{
|
||||
GdkDisplay* display = gtk_widget_get_display(widget);
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_DISPLAY(display))
|
||||
return true;
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_MIR
|
||||
if (GDK_IS_MIR_DISPLAY(display))
|
||||
return true;
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
if (GDK_IS_BROADWAY_DISPLAY(display))
|
||||
return true;
|
||||
#endif
|
||||
static bool has;
|
||||
static bool once;
|
||||
if (!once)
|
||||
{
|
||||
once = true;
|
||||
GdkDisplay* display = gtk_widget_get_display(widget);
|
||||
const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display));
|
||||
has =
|
||||
strcmp(name, "GdkWaylandDisplay") == 0 ||
|
||||
strcmp(name, "GdkMirDisplay") == 0 ||
|
||||
strcmp(name, "GdkBroadwayDisplay") == 0;
|
||||
}
|
||||
return has;
|
||||
}
|
||||
#else
|
||||
static inline bool HasClientDecor(GtkWidget*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif // HAS_CLIENT_DECOR
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RequestUserAttention related functions
|
||||
@@ -253,7 +243,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win)
|
||||
GtkAllocation a;
|
||||
gtk_widget_get_allocation(win->m_widget, &a);
|
||||
wxSize size(a.width, a.height);
|
||||
#ifdef HAS_CLIENT_DECOR
|
||||
if (HasClientDecor(win->m_widget))
|
||||
{
|
||||
GtkAllocation a2;
|
||||
@@ -266,7 +255,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win)
|
||||
win->GTKUpdateDecorSize(decorSize);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
size.x += win->m_decorSize.left + win->m_decorSize.right;
|
||||
size.y += win->m_decorSize.top + win->m_decorSize.bottom;
|
||||
@@ -740,9 +728,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
|
||||
if ( style & wxCAPTION )
|
||||
m_gdkDecor |= GDK_DECOR_TITLE;
|
||||
#if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,10,0)
|
||||
#if GTK_CHECK_VERSION(3,10,0)
|
||||
else if (
|
||||
GDK_IS_WAYLAND_DISPLAY(gtk_widget_get_display(m_widget)) &&
|
||||
strcmp("GdkWaylandDisplay", g_type_name(G_TYPE_FROM_INSTANCE(gtk_widget_get_display(m_widget)))) == 0 &&
|
||||
gtk_check_version(3,10,0) == NULL)
|
||||
{
|
||||
gtk_window_set_titlebar(GTK_WINDOW(m_widget), gtk_header_bar_new());
|
||||
@@ -1080,9 +1068,7 @@ void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXU
|
||||
void wxTopLevelWindowGTK::GTKDoGetSize(int *width, int *height) const
|
||||
{
|
||||
wxSize size(m_width, m_height);
|
||||
#ifdef HAS_CLIENT_DECOR
|
||||
if (!HasClientDecor(m_widget))
|
||||
#endif
|
||||
{
|
||||
size.x -= m_decorSize.left + m_decorSize.right;
|
||||
size.y -= m_decorSize.top + m_decorSize.bottom;
|
||||
@@ -1239,14 +1225,12 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
|
||||
hints.max_height = INT_MAX / 16;
|
||||
int decorSize_x;
|
||||
int decorSize_y;
|
||||
#ifdef HAS_CLIENT_DECOR
|
||||
if (HasClientDecor(m_widget))
|
||||
{
|
||||
decorSize_x = 0;
|
||||
decorSize_y = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
decorSize_x = m_decorSize.left + m_decorSize.right;
|
||||
decorSize_y = m_decorSize.top + m_decorSize.bottom;
|
||||
@@ -1282,13 +1266,11 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize)
|
||||
if (!IsMaximized() && !IsFullScreen())
|
||||
GetCachedDecorSize() = decorSize;
|
||||
|
||||
#ifdef HAS_CLIENT_DECOR
|
||||
if (HasClientDecor(m_widget))
|
||||
{
|
||||
m_decorSize = decorSize;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize)))
|
||||
{
|
||||
|
Reference in New Issue
Block a user