Build fixes for GTK+4
This commit is contained in:
@@ -402,7 +402,11 @@ static void fg(GtkStyleContext* sc, wxColour& color, int state = GTK_STATE_FLAG_
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
gtk_style_context_set_state(sc, GtkStateFlags(state));
|
||||
#ifdef __WXGTK4__
|
||||
gtk_style_context_get_color(sc, &rgba);
|
||||
#else
|
||||
gtk_style_context_get_color(sc, GtkStateFlags(state), &rgba);
|
||||
#endif
|
||||
color = wxColour(rgba);
|
||||
StyleContextFree(sc);
|
||||
}
|
||||
@@ -517,6 +521,9 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
||||
break;
|
||||
case wxSYS_COLOUR_HOTLIGHT:
|
||||
sc = StyleContext(path, GTK_TYPE_LINK_BUTTON, "button", "link");
|
||||
#ifdef __WXGTK4__
|
||||
fg(sc, color, GTK_STATE_FLAG_LINK);
|
||||
#else
|
||||
if (gtk_check_version(3,12,0) == NULL)
|
||||
fg(sc, color, GTK_STATE_FLAG_LINK);
|
||||
else
|
||||
@@ -534,6 +541,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
||||
StyleContextFree(sc);
|
||||
wxGCC_WARNING_RESTORE()
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case wxSYS_COLOUR_INFOBK:
|
||||
sc = TooltipContext(path);
|
||||
@@ -830,6 +838,20 @@ static int GetBorderWidth(wxSystemMetric index, wxWindow* win)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __WXGTK4__
|
||||
static GdkRectangle GetMonitorGeom(GdkWindow* window)
|
||||
{
|
||||
GdkMonitor* monitor;
|
||||
if (window)
|
||||
monitor = gdk_display_get_monitor_at_window(gdk_window_get_display(window), window);
|
||||
else
|
||||
monitor = gdk_display_get_primary_monitor(gdk_display_get_default());
|
||||
GdkRectangle rect;
|
||||
gdk_monitor_get_geometry(monitor, &rect);
|
||||
return rect;
|
||||
}
|
||||
#endif
|
||||
|
||||
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
|
||||
{
|
||||
GdkWindow *window = NULL;
|
||||
@@ -961,16 +983,28 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
|
||||
return 32;
|
||||
|
||||
case wxSYS_SCREEN_X:
|
||||
#ifdef __WXGTK4__
|
||||
return GetMonitorGeom(window).width;
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
if (window)
|
||||
return gdk_screen_get_width(gdk_window_get_screen(window));
|
||||
else
|
||||
return gdk_screen_width();
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
|
||||
case wxSYS_SCREEN_Y:
|
||||
#ifdef __WXGTK4__
|
||||
return GetMonitorGeom(window).height;
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
if (window)
|
||||
return gdk_screen_get_height(gdk_window_get_screen(window));
|
||||
else
|
||||
return gdk_screen_height();
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
|
||||
case wxSYS_HSCROLL_Y:
|
||||
case wxSYS_VSCROLL_X:
|
||||
|
@@ -80,14 +80,32 @@ void *wxGetDisplay()
|
||||
|
||||
void wxDisplaySize( int *width, int *height )
|
||||
{
|
||||
#ifdef __WXGTK4__
|
||||
GdkMonitor* monitor = gdk_display_get_primary_monitor(gdk_display_get_default());
|
||||
GdkRectangle rect;
|
||||
gdk_monitor_get_geometry(monitor, &rect);
|
||||
if (width) *width = rect.width;
|
||||
if (height) *height = rect.height;
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
if (width) *width = gdk_screen_width();
|
||||
if (height) *height = gdk_screen_height();
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxDisplaySizeMM( int *width, int *height )
|
||||
{
|
||||
#ifdef __WXGTK4__
|
||||
GdkMonitor* monitor = gdk_display_get_primary_monitor(gdk_display_get_default());
|
||||
if (width) *width = gdk_monitor_get_width_mm(monitor);
|
||||
if (height) *height = gdk_monitor_get_height_mm(monitor);
|
||||
#else
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
if (width) *width = gdk_screen_width_mm();
|
||||
if (height) *height = gdk_screen_height_mm();
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxColourDisplay()
|
||||
@@ -97,7 +115,11 @@ bool wxColourDisplay()
|
||||
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
#ifdef __WXGTK4__
|
||||
return 24;
|
||||
#else
|
||||
return gdk_visual_get_depth(gdk_window_get_visual(wxGetTopLevelGDK()));
|
||||
#endif
|
||||
}
|
||||
|
||||
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||
@@ -187,12 +209,21 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
#ifdef __WXGTK3__
|
||||
if (verMaj)
|
||||
*verMaj = gtk_get_major_version();
|
||||
if (verMin)
|
||||
*verMin = gtk_get_minor_version();
|
||||
if (verMicro)
|
||||
*verMicro = gtk_get_micro_version();
|
||||
#else
|
||||
if ( verMaj )
|
||||
*verMaj = gtk_major_version;
|
||||
if ( verMin )
|
||||
*verMin = gtk_minor_version;
|
||||
if ( verMicro )
|
||||
*verMicro = gtk_micro_version;
|
||||
#endif
|
||||
|
||||
return wxPORT_GTK;
|
||||
}
|
||||
@@ -339,10 +370,14 @@ bool wxGUIAppTraits::ShowAssertDialog(const wxString& msg)
|
||||
gtk_assert_dialog_set_message(GTK_ASSERT_DIALOG(dialog), msg.mb_str());
|
||||
|
||||
GdkDisplay* display = gtk_widget_get_display(dialog);
|
||||
#ifdef __WXGTK3__
|
||||
#ifdef __WXGTK4__
|
||||
gdk_seat_ungrab(gdk_display_get_default_seat(display));
|
||||
#elif defined(__WXGTK3__)
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
GdkDeviceManager* manager = gdk_display_get_device_manager(display);
|
||||
GdkDevice* device = gdk_device_manager_get_client_pointer(manager);
|
||||
gdk_device_ungrab(device, unsigned(GDK_CURRENT_TIME));
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#else
|
||||
gdk_display_pointer_ungrab(display, unsigned(GDK_CURRENT_TIME));
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user