diff options
Diffstat (limited to 'WebCore/platform/gtk/PlatformScreenGtk.cpp')
-rw-r--r-- | WebCore/platform/gtk/PlatformScreenGtk.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/WebCore/platform/gtk/PlatformScreenGtk.cpp b/WebCore/platform/gtk/PlatformScreenGtk.cpp index 27985ef..4ba6d43 100644 --- a/WebCore/platform/gtk/PlatformScreenGtk.cpp +++ b/WebCore/platform/gtk/PlatformScreenGtk.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2008 Christian Dywan <christian@imendio.com> * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2009 Holger Hans Peter Freyther * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,47 +44,55 @@ namespace WebCore { -int screenDepth(Widget* widget) +static GdkVisual* getVisual(Widget* widget) { + if (!widget) + return 0; + GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); if (!container) - return 24; + return 0; if (!GTK_WIDGET_REALIZED(container)) { GtkWidget* toplevel = gtk_widget_get_toplevel(container); if (GTK_WIDGET_TOPLEVEL(toplevel)) container = toplevel; else - return 24; + return 0; } - GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(container->window)); + return gdk_drawable_get_visual(GDK_DRAWABLE(container->window)); +} + +int screenDepth(Widget* widget) +{ + GdkVisual* visual = getVisual(widget); + if (!visual) + return 24; return visual->depth; } int screenDepthPerComponent(Widget* widget) { - GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); - if (!container) + GdkVisual* visual = getVisual(widget); + if (!visual) return 8; - GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(GTK_WIDGET(widget->root()->hostWindow()->platformWindow())->window)); return visual->bits_per_rgb; } bool screenIsMonochrome(Widget* widget) { - GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); - if (!container) - return false; - return screenDepth(widget) < 2; } FloatRect screenRect(Widget* widget) { + if (!widget) + return FloatRect(); + GtkWidget* container = gtk_widget_get_toplevel(GTK_WIDGET(widget->root()->hostWindow()->platformWindow())); if (!GTK_WIDGET_TOPLEVEL(container)) return FloatRect(); @@ -101,6 +110,9 @@ FloatRect screenRect(Widget* widget) FloatRect screenAvailableRect(Widget* widget) { + if (!widget) + return FloatRect(); + #if PLATFORM(X11) GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); if (!container) |