Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: ui/base/gtk/gtk_screen_util.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/base/gtk/gtk_screen_util.h" 5 #include "ui/base/gtk/gtk_screen_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 bool IsScreenComposited() { 11 bool IsScreenComposited() {
12 GdkScreen* screen = gdk_screen_get_default(); 12 GdkScreen* screen = gdk_screen_get_default();
13 return gdk_screen_is_composited(screen) == TRUE; 13 return gdk_screen_is_composited(screen) == TRUE;
14 } 14 }
15 15
16 gfx::Point ScreenPoint(GtkWidget* widget) { 16 gfx::Point ScreenPoint(GtkWidget* widget) {
17 int x, y; 17 int x, y;
18 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y, 18 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y,
19 NULL); 19 NULL);
20 return gfx::Point(x, y); 20 return gfx::Point(x, y);
21 } 21 }
22 22
23 gfx::Point ClientPoint(GtkWidget* widget) { 23 gfx::Point ClientPoint(GtkWidget* widget) {
24 int x, y; 24 int x, y;
25 gtk_widget_get_pointer(widget, &x, &y); 25 gtk_widget_get_pointer(widget, &x, &y);
26 return gfx::Point(x, y); 26 return gfx::Point(x, y);
27 } 27 }
28 28
29 gfx::Point GetWidgetScreenPosition(GtkWidget* widget) { 29 gfx::Vector2d GetWidgetScreenOffset(GtkWidget* widget) {
30 GdkWindow* window = gtk_widget_get_window(widget); 30 GdkWindow* window = gtk_widget_get_window(widget);
31 31
32 if (!window) { 32 if (!window) {
33 NOTREACHED() << "Must only be called on realized widgets."; 33 NOTREACHED() << "Must only be called on realized widgets.";
34 return gfx::Point(0, 0); 34 return gfx::Vector2d(0, 0);
35 } 35 }
36 36
37 gint x, y; 37 gint x, y;
38 gdk_window_get_origin(window, &x, &y); 38 gdk_window_get_origin(window, &x, &y);
39 39
40 if (!gtk_widget_get_has_window(widget)) { 40 if (!gtk_widget_get_has_window(widget)) {
41 GtkAllocation allocation; 41 GtkAllocation allocation;
42 gtk_widget_get_allocation(widget, &allocation); 42 gtk_widget_get_allocation(widget, &allocation);
43 x += allocation.x; 43 x += allocation.x;
44 y += allocation.y; 44 y += allocation.y;
45 } 45 }
46 46
47 return gfx::Point(x, y); 47 return gfx::Vector2d(x, y);
48 } 48 }
49 49
50 gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) { 50 gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) {
51 gfx::Point position = GetWidgetScreenPosition(widget);
52
53 GtkAllocation allocation; 51 GtkAllocation allocation;
54 gtk_widget_get_allocation(widget, &allocation); 52 gtk_widget_get_allocation(widget, &allocation);
55 53
56 return gfx::Rect(position.x(), position.y(), 54 return gfx::Rect(PointAtOffsetFromOrigin(GetWidgetScreenOffset(widget)),
57 allocation.width, allocation.height); 55 gfx::Size(allocation.width, allocation.height));
58 } 56 }
59 57
60 } // namespace ui 58 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698