| 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 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ui/base/x/x11_util.h" | 13 #include "ui/base/x/x11_util.h" |
| 14 #include "ui/gfx/gtk_compat.h" | 14 #include "ui/gfx/gtk_compat.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/x/x11_types.h" |
| 16 #include "third_party/WebKit/public/web/WebScreenInfo.h" | 17 #include "third_party/WebKit/public/web/WebScreenInfo.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Returns the region of |window|'s desktop that isn't occupied by docks or | 23 // Returns the region of |window|'s desktop that isn't occupied by docks or |
| 23 // panels. Returns an empty rect on failure. | 24 // panels. Returns an empty rect on failure. |
| 24 gfx::Rect GetWorkArea(Window window) { | 25 gfx::Rect GetWorkArea(Window window) { |
| 25 Window root = ui::GetX11RootWindow(); | 26 Window root = ui::GetX11RootWindow(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 return gfx::Rect(); | 38 return gfx::Rect(); |
| 38 | 39 |
| 39 size_t start_index = 4 * desktop; | 40 size_t start_index = 4 * desktop; |
| 40 if (property.size() < start_index + 4) | 41 if (property.size() < start_index + 4) |
| 41 return gfx::Rect(); | 42 return gfx::Rect(); |
| 42 | 43 |
| 43 return gfx::Rect(property[start_index], property[start_index + 1], | 44 return gfx::Rect(property[start_index], property[start_index + 1], |
| 44 property[start_index + 2], property[start_index + 3]); | 45 property[start_index + 2], property[start_index + 3]); |
| 45 } | 46 } |
| 46 | 47 |
| 47 WebKit::WebScreenInfo GetScreenInfo(Display* display, int screenNumber) { | 48 WebKit::WebScreenInfo GetScreenInfo(XDisplay* display, int screenNumber) { |
| 48 // XDisplayWidth() and XDisplayHeight() return cached values. To ensure that | 49 // XDisplayWidth() and XDisplayHeight() return cached values. To ensure that |
| 49 // 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 |
| 50 // root window's geometry each time. | 51 // root window's geometry each time. |
| 51 Window root = RootWindow(display, screenNumber); | 52 Window root = RootWindow(display, screenNumber); |
| 52 Window root_ret; | 53 Window root_ret; |
| 53 int x, y; | 54 int x, y; |
| 54 unsigned int width, height, border, depth; | 55 unsigned int width, height, border, depth; |
| 55 XGetGeometry( | 56 XGetGeometry( |
| 56 display, root, &root_ret, &x, &y, &width, &height, &border, &depth); | 57 display, root, &root_ret, &x, &y, &width, &height, &border, &depth); |
| 57 | 58 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 79 monitor_rect.width, monitor_rect.height); | 80 monitor_rect.width, monitor_rect.height); |
| 80 | 81 |
| 81 gfx::Rect available_rect = results->rect; | 82 gfx::Rect available_rect = results->rect; |
| 82 gfx::Rect work_area = GetWorkArea(GDK_WINDOW_XID(gdk_window)); | 83 gfx::Rect work_area = GetWorkArea(GDK_WINDOW_XID(gdk_window)); |
| 83 if (!work_area.IsEmpty()) | 84 if (!work_area.IsEmpty()) |
| 84 available_rect.Intersect(work_area); | 85 available_rect.Intersect(work_area); |
| 85 results->availableRect = available_rect; | 86 results->availableRect = available_rect; |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace content | 89 } // namespace content |
| OLD | NEW |