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

Side by Side Diff: ui/aura/desktop/desktop_screen_x11.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some new gfx::Screen additions Created 8 years, 2 months 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/aura/desktop/desktop_screen.h" 5 #include "ui/aura/desktop/desktop_screen.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 8
9 // It clashes with out RootWindow. 9 // It clashes with out RootWindow.
10 #undef RootWindow 10 #undef RootWindow
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
14 #include "ui/aura/root_window_host.h" 14 #include "ui/aura/root_window_host.h"
15 #include "ui/base/x/x11_util.h" 15 #include "ui/base/x/x11_util.h"
16 #include "ui/gfx/display.h" 16 #include "ui/gfx/display.h"
17 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/screen_impl.h" 18 #include "ui/gfx/screen.h"
19 19
20 namespace { 20 namespace {
21 21
22 // TODO(erg): This method is a temporary hack, until we can reliably extract 22 // TODO(erg): This method is a temporary hack, until we can reliably extract
23 // location data out of XRandR. 23 // location data out of XRandR.
24 gfx::Size GetPrimaryDisplaySize() { 24 gfx::Size GetPrimaryDisplaySize() {
25 ::Display* display = ui::GetXDisplay(); 25 ::Display* display = ui::GetXDisplay();
26 ::Screen* screen = DefaultScreenOfDisplay(display); 26 ::Screen* screen = DefaultScreenOfDisplay(display);
27 int width = WidthOfScreen(screen); 27 int width = WidthOfScreen(screen);
28 int height = HeightOfScreen(screen); 28 int height = HeightOfScreen(screen);
29 29
30 return gfx::Size(width, height); 30 return gfx::Size(width, height);
31 } 31 }
32 32
33 class DesktopScreenX11 : public gfx::ScreenImpl { 33 class DesktopScreenX11 : public gfx::Screen {
34 public: 34 public:
35 DesktopScreenX11(); 35 DesktopScreenX11();
36 virtual ~DesktopScreenX11(); 36 virtual ~DesktopScreenX11();
37 37
38 // Overridden from gfx::ScreenImpl: 38 // Overridden from gfx::Screen:
39 virtual bool IsDIPEnabled() OVERRIDE;
39 virtual gfx::Point GetCursorScreenPoint() OVERRIDE; 40 virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
40 virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; 41 virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE;
41 virtual int GetNumDisplays() OVERRIDE; 42 virtual int GetNumDisplays() OVERRIDE;
42 virtual gfx::Display GetDisplayNearestWindow( 43 virtual gfx::Display GetDisplayNearestWindow(
43 gfx::NativeView window) const OVERRIDE; 44 gfx::NativeView window) const OVERRIDE;
44 virtual gfx::Display GetDisplayNearestPoint( 45 virtual gfx::Display GetDisplayNearestPoint(
45 const gfx::Point& point) const OVERRIDE; 46 const gfx::Point& point) const OVERRIDE;
46 virtual gfx::Display GetDisplayMatching( 47 virtual gfx::Display GetDisplayMatching(
47 const gfx::Rect& match_rect) const OVERRIDE; 48 const gfx::Rect& match_rect) const OVERRIDE;
48 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; 49 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
49 50
50 private: 51 private:
51 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11); 52 DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11);
52 }; 53 };
53 54
54 //////////////////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////////////////
55 // DesktopScreenX11, public: 56 // DesktopScreenX11, public:
56 57
57 DesktopScreenX11::DesktopScreenX11() { 58 DesktopScreenX11::DesktopScreenX11() {
58 } 59 }
59 60
60 DesktopScreenX11::~DesktopScreenX11() { 61 DesktopScreenX11::~DesktopScreenX11() {
61 } 62 }
62 63
63 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
64 // DesktopScreenX11, gfx::ScreenImpl implementation: 65 // DesktopScreenX11, gfx::Screen implementation:
66
67 bool DesktopScreenX11::IsDIPEnabled() {
68 return false;
69 }
65 70
66 gfx::Point DesktopScreenX11::GetCursorScreenPoint() { 71 gfx::Point DesktopScreenX11::GetCursorScreenPoint() {
67 Display* display = ui::GetXDisplay(); 72 Display* display = ui::GetXDisplay();
68 73
69 ::Window root, child; 74 ::Window root, child;
70 int root_x, root_y, win_x, win_y; 75 int root_x, root_y, win_x, win_y;
71 unsigned int mask; 76 unsigned int mask;
72 XQueryPointer(display, 77 XQueryPointer(display,
73 DefaultRootWindow(display), 78 DefaultRootWindow(display),
74 &root, 79 &root,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // TODO(erg): Do the right thing once we know what that is. 121 // TODO(erg): Do the right thing once we know what that is.
117 return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize())); 122 return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize()));
118 } 123 }
119 124
120 } // namespace 125 } // namespace
121 126
122 //////////////////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////////////////
123 128
124 namespace aura { 129 namespace aura {
125 130
126 gfx::ScreenImpl* CreateDesktopScreen() { 131 gfx::Screen* CreateDesktopScreen() {
127 return new DesktopScreenX11; 132 return new DesktopScreenX11;
128 } 133 }
129 134
130 } // namespace aura 135 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698