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

Side by Side Diff: ui/aura/root_window_host_linux.cc

Issue 10279005: Aura on Linux: Make a DesktopScreenX11 to match the windows one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/root_window_host_linux.h" 5 #include "ui/aura/root_window_host_linux.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/extensions/Xfixes.h> 10 #include <X11/extensions/Xfixes.h>
11 #include <X11/extensions/Xrandr.h> 11 #include <X11/extensions/Xrandr.h>
12 #include <algorithm> 12 #include <algorithm>
13 13
14 #include "base/message_pump_x.h" 14 #include "base/message_pump_x.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "ui/aura/client/user_gesture_client.h" 17 #include "ui/aura/client/user_gesture_client.h"
18 #include "ui/aura/dispatcher_linux.h" 18 #include "ui/aura/dispatcher_linux.h"
19 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
20 #include "ui/aura/event.h" 20 #include "ui/aura/event.h"
21 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
22 #include "ui/base/cursor/cursor.h" 22 #include "ui/base/cursor/cursor.h"
23 #include "ui/base/keycodes/keyboard_codes.h" 23 #include "ui/base/keycodes/keyboard_codes.h"
24 #include "ui/base/touch/touch_factory.h" 24 #include "ui/base/touch/touch_factory.h"
25 #include "ui/base/x/x11_util.h" 25 #include "ui/base/x/x11_util.h"
26 #include "ui/base/view_prop.h"
26 #include "ui/gfx/compositor/layer.h" 27 #include "ui/gfx/compositor/layer.h"
27 28
28 using std::max; 29 using std::max;
29 using std::min; 30 using std::min;
30 31
31 namespace aura { 32 namespace aura {
32 33
33 namespace { 34 namespace {
34 35
35 // Standard Linux mouse buttons for going back and forward. 36 // Standard Linux mouse buttons for going back and forward.
36 const int kBackMouseButton = 8; 37 const int kBackMouseButton = 8;
37 const int kForwardMouseButton = 9; 38 const int kForwardMouseButton = 9;
38 39
40 const char* kRootWindowHostLinuxKey = "__AURA_ROOT_WINDOW_HOST_LINUX__";
Daniel Erat 2012/05/01 22:51:48 nit: i think that "const char kRootWindowHostLinux
41
39 // The events reported for slave devices can have incorrect information for some 42 // The events reported for slave devices can have incorrect information for some
40 // fields. This utility function is used to check for such inconsistencies. 43 // fields. This utility function is used to check for such inconsistencies.
41 void CheckXEventForConsistency(XEvent* xevent) { 44 void CheckXEventForConsistency(XEvent* xevent) {
42 static bool expect_master_event = false; 45 static bool expect_master_event = false;
43 static XIDeviceEvent slave_event; 46 static XIDeviceEvent slave_event;
44 static gfx::Point slave_location; 47 static gfx::Point slave_location;
45 static int slave_button; 48 static int slave_button;
46 49
47 // Note: If an event comes from a slave pointer device, then it will be 50 // Note: If an event comes from a slave pointer device, then it will be
48 // followed by the same event, but reported from its master pointer device. 51 // followed by the same event, but reported from its master pointer device.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 bounds.x(), bounds.y(), bounds.width(), bounds.height(), 310 bounds.x(), bounds.y(), bounds.width(), bounds.height(),
308 0, // border width 311 0, // border width
309 CopyFromParent, // depth 312 CopyFromParent, // depth
310 InputOutput, 313 InputOutput,
311 CopyFromParent, // visual 314 CopyFromParent, // visual
312 CWBackPixmap, 315 CWBackPixmap,
313 &swa); 316 &swa);
314 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())-> 317 static_cast<DispatcherLinux*>(Env::GetInstance()->GetDispatcher())->
315 WindowDispatcherCreated(xwindow_, this); 318 WindowDispatcherCreated(xwindow_, this);
316 319
320 prop_.reset(new ui::ViewProp(xwindow_, kRootWindowHostLinuxKey, this));
321
317 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | 322 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
318 KeyPressMask | KeyReleaseMask | 323 KeyPressMask | KeyReleaseMask |
319 EnterWindowMask | LeaveWindowMask | 324 EnterWindowMask | LeaveWindowMask |
320 ExposureMask | VisibilityChangeMask | 325 ExposureMask | VisibilityChangeMask |
321 StructureNotifyMask | PropertyChangeMask | 326 StructureNotifyMask | PropertyChangeMask |
322 PointerMotionMask; 327 PointerMotionMask;
323 XSelectInput(xdisplay_, xwindow_, event_mask); 328 XSelectInput(xdisplay_, xwindow_, event_mask);
324 XFlush(xdisplay_); 329 XFlush(xdisplay_);
325 330
326 if (base::MessagePumpForUI::HasXInput2()) 331 if (base::MessagePumpForUI::HasXInput2())
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 804 }
800 805
801 // static 806 // static
802 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { 807 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
803 return new RootWindowHostLinux(bounds); 808 return new RootWindowHostLinux(bounds);
804 } 809 }
805 810
806 // static 811 // static
807 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( 812 RootWindowHost* RootWindowHost::GetForAcceleratedWidget(
808 gfx::AcceleratedWidget accelerated_widget) { 813 gfx::AcceleratedWidget accelerated_widget) {
809 NOTIMPLEMENTED(); 814 return reinterpret_cast<RootWindowHost*>(
810 return NULL; // TODO(erg): implement if necessary or remove this comment. 815 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey));
811 } 816 }
812 817
813 // static 818 // static
814 gfx::Size RootWindowHost::GetNativeScreenSize() { 819 gfx::Size RootWindowHost::GetNativeScreenSize() {
815 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); 820 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay();
816 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 821 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
817 } 822 }
818 823
819 } // namespace aura 824 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698