Extract X11 functions used by wxGTK in a separate header

This makes src/unix/displayx11.cpp almost readable as it's not littered
by "#ifndef __WXGTK20__" checks everywhere any more -- instead this file
is just not compiled as part of wxGTK2 at all any longer (it is still
included in wxGTK1 as well as wxX11 itself and wxMotif).

wxGTK code also can just include the new wx/unix/private/displayx11.h
instead of having to declare all the X11 functions it uses manually.

There should be no changes in behaviour, this is just a clean up.
This commit is contained in:
Vadim Zeitlin
2018-10-04 17:07:11 +02:00
parent c38a8f960e
commit e0ba727dec
7 changed files with 284 additions and 365 deletions

View File

@@ -12,6 +12,12 @@
#include "wx/gtk/private/wrapgtk.h"
#ifdef GDK_WINDOWING_X11
#ifndef __WXGTK4__
#include "wx/unix/private/displayx11.h"
#define wxGTK_HAVE_X11_DISPLAY
#endif
#include <gdk/gdkx.h>
#endif
@@ -23,10 +29,6 @@ GdkWindow* wxGetTopLevelGDK();
#ifndef __WXGTK4__
#ifdef GDK_WINDOWING_X11
void wxGetWorkAreaX11(Screen* screen, int& x, int& y, int& width, int& height);
#endif
#ifndef __WXGTK3__
static inline int wx_gdk_screen_get_primary_monitor(GdkScreen* screen)
{
@@ -51,7 +53,7 @@ wx_gdk_screen_get_monitor_workarea(GdkScreen* screen, int monitor, GdkRectangle*
#endif
{
gdk_screen_get_monitor_geometry(screen, monitor, dest);
#ifdef GDK_WINDOWING_X11
#ifdef wxGTK_HAVE_X11_DISPLAY
#ifdef __WXGTK3__
if (GDK_IS_X11_SCREEN(screen))
#endif
@@ -63,7 +65,7 @@ wx_gdk_screen_get_monitor_workarea(GdkScreen* screen, int monitor, GdkRectangle*
if (rect.width && rect.height)
gdk_rectangle_intersect(dest, &rect, dest);
}
#endif // GDK_WINDOWING_X11
#endif // wxGTK_HAVE_X11_DISPLAY
}
wxGCC_WARNING_RESTORE()
}
@@ -216,17 +218,10 @@ bool wxDisplayImplGTK::IsPrimary() const
#endif
}
#if defined(GDK_WINDOWING_X11) && !defined(__WXGTK4__)
wxArrayVideoModes wxXF86VidMode_GetModes(const wxVideoMode& mode, Display* pDisplay, int nScreen);
wxVideoMode wxXF86VidMode_GetCurrentMode(Display* display, int nScreen);
bool wxXF86VidMode_ChangeMode(const wxVideoMode& mode, Display* display, int nScreen);
wxArrayVideoModes wxX11_GetModes(const wxDisplayImpl* impl, const wxVideoMode& modeMatch, Display* display);
#endif
wxArrayVideoModes wxDisplayImplGTK::GetModes(const wxVideoMode& mode) const
{
wxArrayVideoModes modes;
#if defined(GDK_WINDOWING_X11) && !defined(__WXGTK4__)
#ifdef wxGTK_HAVE_X11_DISPLAY
#ifdef __WXGTK3__
if (GDK_IS_X11_SCREEN(m_screen))
#endif
@@ -248,7 +243,7 @@ wxArrayVideoModes wxDisplayImplGTK::GetModes(const wxVideoMode& mode) const
wxVideoMode wxDisplayImplGTK::GetCurrentMode() const
{
wxVideoMode mode;
#if defined(GDK_WINDOWING_X11) && defined(HAVE_X11_EXTENSIONS_XF86VMODE_H) && !defined(__WXGTK4__)
#if defined(wxGTK_HAVE_X11_DISPLAY) && defined(HAVE_X11_EXTENSIONS_XF86VMODE_H)
#ifdef __WXGTK3__
if (GDK_IS_X11_SCREEN(m_screen))
#endif
@@ -264,7 +259,7 @@ wxVideoMode wxDisplayImplGTK::GetCurrentMode() const
bool wxDisplayImplGTK::ChangeMode(const wxVideoMode& mode)
{
bool success = false;
#if defined(GDK_WINDOWING_X11) && defined(HAVE_X11_EXTENSIONS_XF86VMODE_H) && !defined(__WXGTK4__)
#if defined(wxGTK_HAVE_X11_DISPLAY) && defined(HAVE_X11_EXTENSIONS_XF86VMODE_H)
#ifdef __WXGTK3__
if (GDK_IS_X11_SCREEN(m_screen))
#endif