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 <X11/Xatom.h> // XA_CARDINAL
|
||||||
#include "wx/unix/utilsx11.h"
|
#include "wx/unix/utilsx11.h"
|
||||||
#endif
|
#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.h"
|
||||||
#include "wx/gtk/private/gtk2-compat.h"
|
#include "wx/gtk/private/gtk2-compat.h"
|
||||||
@@ -80,25 +66,29 @@ static enum {
|
|||||||
static bool gs_decorCacheValid;
|
static bool gs_decorCacheValid;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_CLIENT_DECOR
|
#ifdef __WXGTK3__
|
||||||
static bool HasClientDecor(GtkWidget* widget)
|
static bool HasClientDecor(GtkWidget* widget)
|
||||||
{
|
{
|
||||||
GdkDisplay* display = gtk_widget_get_display(widget);
|
static bool has;
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
static bool once;
|
||||||
if (GDK_IS_WAYLAND_DISPLAY(display))
|
if (!once)
|
||||||
return true;
|
{
|
||||||
#endif
|
once = true;
|
||||||
#ifdef GDK_WINDOWING_MIR
|
GdkDisplay* display = gtk_widget_get_display(widget);
|
||||||
if (GDK_IS_MIR_DISPLAY(display))
|
const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display));
|
||||||
return true;
|
has =
|
||||||
#endif
|
strcmp(name, "GdkWaylandDisplay") == 0 ||
|
||||||
#ifdef GDK_WINDOWING_BROADWAY
|
strcmp(name, "GdkMirDisplay") == 0 ||
|
||||||
if (GDK_IS_BROADWAY_DISPLAY(display))
|
strcmp(name, "GdkBroadwayDisplay") == 0;
|
||||||
return true;
|
}
|
||||||
#endif
|
return has;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline bool HasClientDecor(GtkWidget*)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // HAS_CLIENT_DECOR
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// RequestUserAttention related functions
|
// RequestUserAttention related functions
|
||||||
@@ -253,7 +243,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win)
|
|||||||
GtkAllocation a;
|
GtkAllocation a;
|
||||||
gtk_widget_get_allocation(win->m_widget, &a);
|
gtk_widget_get_allocation(win->m_widget, &a);
|
||||||
wxSize size(a.width, a.height);
|
wxSize size(a.width, a.height);
|
||||||
#ifdef HAS_CLIENT_DECOR
|
|
||||||
if (HasClientDecor(win->m_widget))
|
if (HasClientDecor(win->m_widget))
|
||||||
{
|
{
|
||||||
GtkAllocation a2;
|
GtkAllocation a2;
|
||||||
@@ -266,7 +255,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win)
|
|||||||
win->GTKUpdateDecorSize(decorSize);
|
win->GTKUpdateDecorSize(decorSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
size.x += win->m_decorSize.left + win->m_decorSize.right;
|
size.x += win->m_decorSize.left + win->m_decorSize.right;
|
||||||
size.y += win->m_decorSize.top + win->m_decorSize.bottom;
|
size.y += win->m_decorSize.top + win->m_decorSize.bottom;
|
||||||
@@ -740,9 +728,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
|||||||
|
|
||||||
if ( style & wxCAPTION )
|
if ( style & wxCAPTION )
|
||||||
m_gdkDecor |= GDK_DECOR_TITLE;
|
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 (
|
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_check_version(3,10,0) == NULL)
|
||||||
{
|
{
|
||||||
gtk_window_set_titlebar(GTK_WINDOW(m_widget), gtk_header_bar_new());
|
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
|
void wxTopLevelWindowGTK::GTKDoGetSize(int *width, int *height) const
|
||||||
{
|
{
|
||||||
wxSize size(m_width, m_height);
|
wxSize size(m_width, m_height);
|
||||||
#ifdef HAS_CLIENT_DECOR
|
|
||||||
if (!HasClientDecor(m_widget))
|
if (!HasClientDecor(m_widget))
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
size.x -= m_decorSize.left + m_decorSize.right;
|
size.x -= m_decorSize.left + m_decorSize.right;
|
||||||
size.y -= m_decorSize.top + m_decorSize.bottom;
|
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;
|
hints.max_height = INT_MAX / 16;
|
||||||
int decorSize_x;
|
int decorSize_x;
|
||||||
int decorSize_y;
|
int decorSize_y;
|
||||||
#ifdef HAS_CLIENT_DECOR
|
|
||||||
if (HasClientDecor(m_widget))
|
if (HasClientDecor(m_widget))
|
||||||
{
|
{
|
||||||
decorSize_x = 0;
|
decorSize_x = 0;
|
||||||
decorSize_y = 0;
|
decorSize_y = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
decorSize_x = m_decorSize.left + m_decorSize.right;
|
decorSize_x = m_decorSize.left + m_decorSize.right;
|
||||||
decorSize_y = m_decorSize.top + m_decorSize.bottom;
|
decorSize_y = m_decorSize.top + m_decorSize.bottom;
|
||||||
@@ -1282,13 +1266,11 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize)
|
|||||||
if (!IsMaximized() && !IsFullScreen())
|
if (!IsMaximized() && !IsFullScreen())
|
||||||
GetCachedDecorSize() = decorSize;
|
GetCachedDecorSize() = decorSize;
|
||||||
|
|
||||||
#ifdef HAS_CLIENT_DECOR
|
|
||||||
if (HasClientDecor(m_widget))
|
if (HasClientDecor(m_widget))
|
||||||
{
|
{
|
||||||
m_decorSize = decorSize;
|
m_decorSize = decorSize;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize)))
|
if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize)))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user