darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
alp@webkit.org | 040ad8b | 2008-02-04 11:00:43 +0000 | [diff] [blame] | 3 | * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008 Christian Dywan <christian@imendio.com> |
| 5 | * Copyright (C) 2008 Collabora Ltd. |
zecke@webkit.org | efa2055 | 2009-07-17 14:48:22 +0000 | [diff] [blame] | 6 | * Copyright (C) 2009 Holger Hans Peter Freyther |
darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
alp@webkit.org | 040ad8b | 2008-02-04 11:00:43 +0000 | [diff] [blame] | 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "config.h" |
weinig | b8d2323 | 2007-06-19 00:08:29 +0000 | [diff] [blame] | 32 | #include "PlatformScreen.h" |
darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 33 | |
kov@webkit.org | 8bab4ab | 2010-03-23 13:23:26 +0000 | [diff] [blame] | 34 | #include "GtkVersioning.h" |
jmalonzo@webkit.org | 047c340 | 2008-10-04 04:02:30 +0000 | [diff] [blame] | 35 | #include "HostWindow.h" |
fsamuel@chromium.org | a33350a | 2011-12-08 03:03:47 +0000 | [diff] [blame] | 36 | #include "NotImplemented.h" |
jmalonzo@webkit.org | 047c340 | 2008-10-04 04:02:30 +0000 | [diff] [blame] | 37 | #include "ScrollView.h" |
weinig | b8d2323 | 2007-06-19 00:08:29 +0000 | [diff] [blame] | 38 | #include "Widget.h" |
zecke | defdb0c | 2007-08-09 23:44:39 +0000 | [diff] [blame] | 39 | |
| 40 | #include <gtk/gtk.h> |
darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 41 | |
| 42 | namespace WebCore { |
| 43 | |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 44 | static GtkWidget* getToplevel(GtkWidget* widget) |
| 45 | { |
| 46 | GtkWidget* toplevel = gtk_widget_get_toplevel(widget); |
| 47 | return gtk_widget_is_toplevel(toplevel) ? toplevel : 0; |
| 48 | } |
| 49 | |
zecke@webkit.org | efa2055 | 2009-07-17 14:48:22 +0000 | [diff] [blame] | 50 | static GdkVisual* getVisual(Widget* widget) |
bdash | 2f045e5 | 2007-05-18 08:41:43 +0000 | [diff] [blame] | 51 | { |
carlosgc@webkit.org | 777f998 | 2012-01-05 14:38:23 +0000 | [diff] [blame] | 52 | GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0; |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 53 | if (!container) { |
| 54 | GdkScreen* screen = gdk_screen_get_default(); |
| 55 | return screen ? gdk_screen_get_system_visual(screen) : 0; |
zecke@webkit.org | e27e324 | 2008-12-11 10:22:40 +0000 | [diff] [blame] | 56 | } |
| 57 | |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 58 | if (!gtk_widget_get_realized(container)) |
| 59 | container = getToplevel(container); |
| 60 | return container ? gdk_window_get_visual(gtk_widget_get_window(container)) : 0; |
zecke@webkit.org | efa2055 | 2009-07-17 14:48:22 +0000 | [diff] [blame] | 61 | } |
| 62 | |
fsamuel@chromium.org | a33350a | 2011-12-08 03:03:47 +0000 | [diff] [blame] | 63 | int screenHorizontalDPI(Widget* widget) |
| 64 | { |
| 65 | notImplemented(); |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | int screenVerticalDPI(Widget* widget) |
| 70 | { |
| 71 | notImplemented(); |
| 72 | return 0; |
| 73 | } |
| 74 | |
zecke@webkit.org | efa2055 | 2009-07-17 14:48:22 +0000 | [diff] [blame] | 75 | int screenDepth(Widget* widget) |
| 76 | { |
| 77 | GdkVisual* visual = getVisual(widget); |
| 78 | if (!visual) |
| 79 | return 24; |
xan@webkit.org | cc8bbbf | 2010-06-15 19:14:38 +0000 | [diff] [blame] | 80 | return gdk_visual_get_depth(visual); |
kjk | 5514898 | 2007-02-08 22:37:14 +0000 | [diff] [blame] | 81 | } |
bdash | e2ec6f2 | 2006-09-16 00:39:12 +0000 | [diff] [blame] | 82 | |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 83 | int screenDepthPerComponent(Widget* widget) |
kjk | 5514898 | 2007-02-08 22:37:14 +0000 | [diff] [blame] | 84 | { |
zecke@webkit.org | efa2055 | 2009-07-17 14:48:22 +0000 | [diff] [blame] | 85 | GdkVisual* visual = getVisual(widget); |
| 86 | if (!visual) |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 87 | return 8; |
| 88 | |
xan@webkit.org | cc8bbbf | 2010-06-15 19:14:38 +0000 | [diff] [blame] | 89 | return gdk_visual_get_bits_per_rgb(visual); |
kjk | 5514898 | 2007-02-08 22:37:14 +0000 | [diff] [blame] | 90 | } |
darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 91 | |
alp@webkit.org | bdb392f | 2008-03-08 06:07:54 +0000 | [diff] [blame] | 92 | bool screenIsMonochrome(Widget* widget) |
alp@webkit.org | 040ad8b | 2008-02-04 11:00:43 +0000 | [diff] [blame] | 93 | { |
alp@webkit.org | bdb392f | 2008-03-08 06:07:54 +0000 | [diff] [blame] | 94 | return screenDepth(widget) < 2; |
kjk | 5514898 | 2007-02-08 22:37:14 +0000 | [diff] [blame] | 95 | } |
| 96 | |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 97 | |
| 98 | static GdkScreen* getScreen(GtkWidget* widget) |
| 99 | { |
| 100 | return gtk_widget_has_screen(widget) ? gtk_widget_get_screen(widget) : gdk_screen_get_default(); |
| 101 | } |
| 102 | |
bdakin@apple.com | c88f6da | 2012-02-03 19:29:13 +0000 | [diff] [blame] | 103 | FloatRect screenRect(Widget* widget) |
alp@webkit.org | 040ad8b | 2008-02-04 11:00:43 +0000 | [diff] [blame] | 104 | { |
bdakin@apple.com | c88f6da | 2012-02-03 19:29:13 +0000 | [diff] [blame] | 105 | GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0; |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 106 | if (container) |
| 107 | container = getToplevel(container); |
alp@webkit.org | bdb392f | 2008-03-08 06:07:54 +0000 | [diff] [blame] | 108 | |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 109 | GdkScreen* screen = container ? getScreen(container) : gdk_screen_get_default(); |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 110 | if (!screen) |
| 111 | return FloatRect(); |
| 112 | |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 113 | gint monitor = container ? gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(container)) : 0; |
| 114 | |
alp@webkit.org | bdb392f | 2008-03-08 06:07:54 +0000 | [diff] [blame] | 115 | GdkRectangle geometry; |
alp@webkit.org | bdb392f | 2008-03-08 06:07:54 +0000 | [diff] [blame] | 116 | gdk_screen_get_monitor_geometry(screen, monitor, &geometry); |
carlosgc@webkit.org | 7059237 | 2011-06-24 15:42:28 +0000 | [diff] [blame] | 117 | |
alp@webkit.org | bdb392f | 2008-03-08 06:07:54 +0000 | [diff] [blame] | 118 | return FloatRect(geometry.x, geometry.y, geometry.width, geometry.height); |
alp@webkit.org | 040ad8b | 2008-02-04 11:00:43 +0000 | [diff] [blame] | 119 | } |
| 120 | |
bdakin@apple.com | c88f6da | 2012-02-03 19:29:13 +0000 | [diff] [blame] | 121 | FloatRect screenAvailableRect(Widget* widget) |
alp@webkit.org | 040ad8b | 2008-02-04 11:00:43 +0000 | [diff] [blame] | 122 | { |
bdakin@apple.com | c88f6da | 2012-02-03 19:29:13 +0000 | [diff] [blame] | 123 | GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0; |
carlosgc@webkit.org | aaacedc | 2011-12-14 19:18:24 +0000 | [diff] [blame] | 124 | if (container && !gtk_widget_get_realized(container)) |
bdakin@apple.com | c88f6da | 2012-02-03 19:29:13 +0000 | [diff] [blame] | 125 | return screenRect(widget); |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 126 | |
carlosgc@webkit.org | aaacedc | 2011-12-14 19:18:24 +0000 | [diff] [blame] | 127 | GdkScreen* screen = container ? getScreen(container) : gdk_screen_get_default(); |
| 128 | if (!screen) |
| 129 | return FloatRect(); |
| 130 | |
carlosgc@webkit.org | d22b46e | 2012-01-03 09:17:04 +0000 | [diff] [blame] | 131 | gint monitor = container ? gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(container)) : 0; |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 132 | |
carlosgc@webkit.org | d22b46e | 2012-01-03 09:17:04 +0000 | [diff] [blame] | 133 | GdkRectangle workArea; |
| 134 | gdk_screen_get_monitor_workarea(screen, monitor, &workArea); |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 135 | |
carlosgc@webkit.org | d22b46e | 2012-01-03 09:17:04 +0000 | [diff] [blame] | 136 | return FloatRect(workArea.x, workArea.y, workArea.width, workArea.height); |
jmalonzo@webkit.org | 210145b | 2008-08-13 19:56:20 +0000 | [diff] [blame] | 137 | |
kjk | 5514898 | 2007-02-08 22:37:14 +0000 | [diff] [blame] | 138 | } |
darin | 6fb113f | 2006-07-01 04:39:50 +0000 | [diff] [blame] | 139 | |
commit-queue@webkit.org | 2360277 | 2012-07-14 02:03:21 +0000 | [diff] [blame] | 140 | void screenColorProfile(ColorProfile&) |
commit-queue@webkit.org | 26de5ec | 2012-06-20 02:15:00 +0000 | [diff] [blame] | 141 | { |
| 142 | notImplemented(); |
| 143 | } |
| 144 | |
weinig | b8d2323 | 2007-06-19 00:08:29 +0000 | [diff] [blame] | 145 | } // namespace WebCore |