Add wxDisplay implementation for GTK+4
GdkMonitor replaces GdkScreen
This commit is contained in:
@@ -26,6 +26,8 @@ GdkWindow* wxGetTopLevelGDK();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WXGTK4__
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
void wxGetWorkAreaX11(Screen* screen, int& x, int& y, int& width, int& height);
|
||||
#endif
|
||||
@@ -46,6 +48,7 @@ static inline int wx_gdk_screen_get_primary_monitor(GdkScreen* screen)
|
||||
static inline void
|
||||
wx_gdk_screen_get_monitor_workarea(GdkScreen* screen, int monitor, GdkRectangle* dest)
|
||||
{
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
#if GTK_CHECK_VERSION(3,4,0)
|
||||
if (gtk_check_version(3,4,0) == NULL)
|
||||
gdk_screen_get_monitor_workarea(screen, monitor, dest);
|
||||
@@ -67,16 +70,27 @@ wx_gdk_screen_get_monitor_workarea(GdkScreen* screen, int monitor, GdkRectangle*
|
||||
}
|
||||
#endif // GDK_WINDOWING_X11
|
||||
}
|
||||
wxGCC_WARNING_RESTORE()
|
||||
}
|
||||
#define gdk_screen_get_monitor_workarea wx_gdk_screen_get_monitor_workarea
|
||||
|
||||
#endif // !__WXGTK4__
|
||||
|
||||
void wxClientDisplayRect(int* x, int* y, int* width, int* height)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
GdkWindow* window = wxGetTopLevelGDK();
|
||||
#ifdef __WXGTK4__
|
||||
GdkMonitor* monitor =
|
||||
gdk_display_get_monitor_at_window(gdk_window_get_display(window), window);
|
||||
gdk_monitor_get_workarea(monitor, &rect);
|
||||
#else
|
||||
GdkScreen* screen = gdk_window_get_screen(window);
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
int monitor = gdk_screen_get_monitor_at_window(screen, window);
|
||||
gdk_screen_get_monitor_workarea(screen, monitor, &rect);
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
if (x)
|
||||
*x = rect.x;
|
||||
if (y)
|
||||
@@ -109,15 +123,25 @@ public:
|
||||
virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE;
|
||||
virtual wxVideoMode GetCurrentMode() const wxOVERRIDE;
|
||||
virtual bool ChangeMode(const wxVideoMode& mode) wxOVERRIDE;
|
||||
|
||||
#ifdef __WXGTK4__
|
||||
GdkMonitor* const m_monitor;
|
||||
#else
|
||||
GdkScreen* const m_screen;
|
||||
#endif
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXGTK4__
|
||||
static inline GdkDisplay* GetDisplay()
|
||||
{
|
||||
return gdk_window_get_display(wxGetTopLevelGDK());
|
||||
}
|
||||
#else
|
||||
static inline GdkScreen* GetScreen()
|
||||
{
|
||||
return gdk_window_get_screen(wxGetTopLevelGDK());
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
#endif
|
||||
|
||||
wxDisplayImpl* wxDisplayFactoryGTK::CreateDisplay(unsigned n)
|
||||
{
|
||||
@@ -126,38 +150,77 @@ wxDisplayImpl* wxDisplayFactoryGTK::CreateDisplay(unsigned n)
|
||||
|
||||
unsigned wxDisplayFactoryGTK::GetCount()
|
||||
{
|
||||
#ifdef __WXGTK4__
|
||||
return gdk_display_get_n_monitors(GetDisplay());
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
return gdk_screen_get_n_monitors(GetScreen());
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
}
|
||||
|
||||
int wxDisplayFactoryGTK::GetFromPoint(const wxPoint& pt)
|
||||
{
|
||||
GdkScreen* screen = GetScreen();
|
||||
int monitor = gdk_screen_get_monitor_at_point(screen, pt.x, pt.y);
|
||||
GdkRectangle rect;
|
||||
#ifdef __WXGTK4__
|
||||
GdkDisplay* display = GetDisplay();
|
||||
GdkMonitor* monitor = gdk_display_get_monitor_at_point(display, pt.x, pt.y);
|
||||
gdk_monitor_get_geometry(monitor, &rect);
|
||||
if (wxRect(rect.x, rect.y, rect.width, rect.height).Contains(pt))
|
||||
{
|
||||
for (unsigned i = gdk_display_get_n_monitors(display); i--;)
|
||||
{
|
||||
if (gdk_display_get_monitor(display, i) == monitor)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return wxNOT_FOUND;
|
||||
#else
|
||||
GdkScreen* screen = GetScreen();
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
int monitor = gdk_screen_get_monitor_at_point(screen, pt.x, pt.y);
|
||||
gdk_screen_get_monitor_geometry(screen, monitor, &rect);
|
||||
wxGCC_WARNING_RESTORE()
|
||||
if (!wxRect(rect.x, rect.y, rect.width, rect.height).Contains(pt))
|
||||
monitor = wxNOT_FOUND;
|
||||
return monitor;
|
||||
#endif
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxDisplayImplGTK::wxDisplayImplGTK(unsigned i)
|
||||
: base_type(i)
|
||||
#ifdef __WXGTK4__
|
||||
, m_monitor(gdk_display_get_monitor(GetDisplay(), i))
|
||||
#else
|
||||
, m_screen(GetScreen())
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
wxRect wxDisplayImplGTK::GetGeometry() const
|
||||
{
|
||||
GdkRectangle rect;
|
||||
#ifdef __WXGTK4__
|
||||
gdk_monitor_get_geometry(m_monitor, &rect);
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
gdk_screen_get_monitor_geometry(m_screen, m_index, &rect);
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
return wxRect(rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
wxRect wxDisplayImplGTK::GetClientArea() const
|
||||
{
|
||||
GdkRectangle rect;
|
||||
#ifdef __WXGTK4__
|
||||
gdk_monitor_get_workarea(m_monitor, &rect);
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
gdk_screen_get_monitor_workarea(m_screen, m_index, &rect);
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
return wxRect(rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
@@ -168,10 +231,16 @@ wxString wxDisplayImplGTK::GetName() const
|
||||
|
||||
bool wxDisplayImplGTK::IsPrimary() const
|
||||
{
|
||||
#ifdef __WXGTK4__
|
||||
return gdk_monitor_is_primary(m_monitor) != 0;
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
return gdk_screen_get_primary_monitor(m_screen) == int(m_index);
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#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);
|
||||
@@ -181,7 +250,7 @@ wxArrayVideoModes wxX11_GetModes(const wxDisplayImpl* impl, const wxVideoMode& m
|
||||
wxArrayVideoModes wxDisplayImplGTK::GetModes(const wxVideoMode& mode) const
|
||||
{
|
||||
wxArrayVideoModes modes;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#if defined(GDK_WINDOWING_X11) && !defined(__WXGTK4__)
|
||||
#ifdef __WXGTK3__
|
||||
if (GDK_IS_X11_SCREEN(m_screen))
|
||||
#endif
|
||||
@@ -203,7 +272,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)
|
||||
#if defined(GDK_WINDOWING_X11) && defined(HAVE_X11_EXTENSIONS_XF86VMODE_H) && !defined(__WXGTK4__)
|
||||
#ifdef __WXGTK3__
|
||||
if (GDK_IS_X11_SCREEN(m_screen))
|
||||
#endif
|
||||
@@ -219,7 +288,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)
|
||||
#if defined(GDK_WINDOWING_X11) && defined(HAVE_X11_EXTENSIONS_XF86VMODE_H) && !defined(__WXGTK4__)
|
||||
#ifdef __WXGTK3__
|
||||
if (GDK_IS_X11_SCREEN(m_screen))
|
||||
#endif
|
||||
@@ -233,6 +302,7 @@ bool wxDisplayImplGTK::ChangeMode(const wxVideoMode& mode)
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxDisplayFactory* wxDisplay::CreateFactory()
|
||||
{
|
||||
|
Reference in New Issue
Block a user