OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/gtk_window_utils.h" | 5 #include "content/browser/renderer_host/gtk_window_utils.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 return gfx::Rect(); | 38 return gfx::Rect(); |
39 | 39 |
40 size_t start_index = 4 * desktop; | 40 size_t start_index = 4 * desktop; |
41 if (property.size() < start_index + 4) | 41 if (property.size() < start_index + 4) |
42 return gfx::Rect(); | 42 return gfx::Rect(); |
43 | 43 |
44 return gfx::Rect(property[start_index], property[start_index + 1], | 44 return gfx::Rect(property[start_index], property[start_index + 1], |
45 property[start_index + 2], property[start_index + 3]); | 45 property[start_index + 2], property[start_index + 3]); |
46 } | 46 } |
47 | 47 |
48 WebKit::WebScreenInfo GetScreenInfo(XDisplay* display, int screenNumber) { | 48 blink::WebScreenInfo GetScreenInfo(XDisplay* display, int screenNumber) { |
49 // XDisplayWidth() and XDisplayHeight() return cached values. To ensure that | 49 // XDisplayWidth() and XDisplayHeight() return cached values. To ensure that |
50 // we return the correct dimensions after the screen is resized, query the | 50 // we return the correct dimensions after the screen is resized, query the |
51 // root window's geometry each time. | 51 // root window's geometry each time. |
52 Window root = RootWindow(display, screenNumber); | 52 Window root = RootWindow(display, screenNumber); |
53 Window root_ret; | 53 Window root_ret; |
54 int x, y; | 54 int x, y; |
55 unsigned int width, height, border, depth; | 55 unsigned int width, height, border, depth; |
56 XGetGeometry( | 56 XGetGeometry( |
57 display, root, &root_ret, &x, &y, &width, &height, &border, &depth); | 57 display, root, &root_ret, &x, &y, &width, &height, &border, &depth); |
58 | 58 |
59 WebKit::WebScreenInfo results; | 59 blink::WebScreenInfo results; |
60 results.depthPerComponent = 8; // Assume 8bpp, which is usually right. | 60 results.depthPerComponent = 8; // Assume 8bpp, which is usually right. |
61 results.depth = depth; | 61 results.depth = depth; |
62 results.isMonochrome = depth == 1; | 62 results.isMonochrome = depth == 1; |
63 results.rect = WebKit::WebRect(x, y, width, height); | 63 results.rect = blink::WebRect(x, y, width, height); |
64 results.availableRect = results.rect; | 64 results.availableRect = results.rect; |
65 return results; | 65 return results; |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 void GetScreenInfoFromNativeWindow( | 70 void GetScreenInfoFromNativeWindow( |
71 GdkWindow* gdk_window, WebKit::WebScreenInfo* results) { | 71 GdkWindow* gdk_window, blink::WebScreenInfo* results) { |
72 GdkScreen* screen = gdk_window_get_screen(gdk_window); | 72 GdkScreen* screen = gdk_window_get_screen(gdk_window); |
73 *results = GetScreenInfo(gdk_x11_drawable_get_xdisplay(gdk_window), | 73 *results = GetScreenInfo(gdk_x11_drawable_get_xdisplay(gdk_window), |
74 gdk_x11_screen_get_screen_number(screen)); | 74 gdk_x11_screen_get_screen_number(screen)); |
75 | 75 |
76 int monitor_number = gdk_screen_get_monitor_at_window(screen, gdk_window); | 76 int monitor_number = gdk_screen_get_monitor_at_window(screen, gdk_window); |
77 GdkRectangle monitor_rect; | 77 GdkRectangle monitor_rect; |
78 gdk_screen_get_monitor_geometry(screen, monitor_number, &monitor_rect); | 78 gdk_screen_get_monitor_geometry(screen, monitor_number, &monitor_rect); |
79 results->rect = WebKit::WebRect(monitor_rect.x, monitor_rect.y, | 79 results->rect = blink::WebRect(monitor_rect.x, monitor_rect.y, |
80 monitor_rect.width, monitor_rect.height); | 80 monitor_rect.width, monitor_rect.height); |
81 | 81 |
82 gfx::Rect available_rect = results->rect; | 82 gfx::Rect available_rect = results->rect; |
83 gfx::Rect work_area = GetWorkArea(GDK_WINDOW_XID(gdk_window)); | 83 gfx::Rect work_area = GetWorkArea(GDK_WINDOW_XID(gdk_window)); |
84 if (!work_area.IsEmpty()) | 84 if (!work_area.IsEmpty()) |
85 available_rect.Intersect(work_area); | 85 available_rect.Intersect(work_area); |
86 results->availableRect = available_rect; | 86 results->availableRect = available_rect; |
87 } | 87 } |
88 | 88 |
89 } // namespace content | 89 } // namespace content |
OLD | NEW |