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

Side by Side Diff: aura/desktop_host_linux.cc

Issue 7833016: aura: A few changes to have aura_demo compile and run on linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: events Created 9 years, 3 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
« no previous file with comments | « aura/desktop.h ('k') | aura/event.h » ('j') | aura/event.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "aura/desktop_host.h" 5 #include "aura/desktop_host.h"
6 6
7 #include "aura/desktop.h" 7 #include "aura/desktop.h"
8 #include "aura/event.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/message_pump_x.h" 10 #include "base/message_pump_x.h"
10 11
11 #include <X11/Xlib.h> 12 #include <X11/Xlib.h>
12 13
13 namespace aura { 14 namespace aura {
14 15
15 namespace { 16 namespace {
16 17
17 class DesktopHostLinux : public DesktopHost { 18 class DesktopHostLinux : public DesktopHost {
18 public: 19 public:
19 explicit DesktopHostLinux(const gfx::Rect& bounds); 20 explicit DesktopHostLinux(const gfx::Rect& bounds);
20 virtual ~DesktopHostLinux(); 21 virtual ~DesktopHostLinux();
21 22
22 private: 23 private:
23 // base::MessageLoop::Dispatcher Override. 24 // base::MessageLoop::Dispatcher Override.
24 virtual DispatchStatus Dispatch(XEvent* xev) OVERRIDE; 25 virtual DispatchStatus Dispatch(XEvent* xev) OVERRIDE;
25 26
26 // DesktopHost Overrides. 27 // DesktopHost Overrides.
27 virtual void SetDesktop(Desktop* desktop) OVERRIDE; 28 virtual void SetDesktop(Desktop* desktop) OVERRIDE;
28 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; 29 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
29 virtual void Show() OVERRIDE; 30 virtual void Show() OVERRIDE;
30 virtual gfx::Size GetSize() OVERRIDE; 31 virtual gfx::Size GetSize() OVERRIDE;
32 virtual void SetSize(const gfx::Size& size) OVERRIDE;
31 33
32 Desktop* desktop_; 34 Desktop* desktop_;
33 35
34 // The display and the native X window hosting the desktop. 36 // The display and the native X window hosting the desktop.
35 Display* xdisplay_; 37 Display* xdisplay_;
36 ::Window xwindow_; 38 ::Window xwindow_;
37 39
38 // The size of |xwindow_|. 40 // The size of |xwindow_|.
39 gfx::Rect bounds_; 41 gfx::Rect bounds_;
40 42
(...skipping 20 matching lines...) Expand all
61 XSelectInput(xdisplay_, xwindow_, event_mask); 63 XSelectInput(xdisplay_, xwindow_, event_mask);
62 XFlush(xdisplay_); 64 XFlush(xdisplay_);
63 } 65 }
64 66
65 DesktopHostLinux::~DesktopHostLinux() { 67 DesktopHostLinux::~DesktopHostLinux() {
66 XDestroyWindow(xdisplay_, xwindow_); 68 XDestroyWindow(xdisplay_, xwindow_);
67 } 69 }
68 70
69 base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch( 71 base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch(
70 XEvent* xev) { 72 XEvent* xev) {
71 // TODO(sad): Create events and dispatch to the appropriate window. 73 bool handled = false;
72 switch (xev->type) { 74 switch (xev->type) {
73 case Expose: 75 case Expose:
74 desktop_->Draw(); 76 desktop_->Draw();
77 handled = true;
75 break; 78 break;
79 case KeyPress:
80 case KeyRelease: {
81 KeyEvent keyev(xev);
82 handled = desktop_->OnKeyEvent(keyev);
83 }
sky 2011/09/04 16:01:48 break
sadrul 2011/09/04 18:14:13 Doh! Done
84 case ButtonPress:
85 case ButtonRelease:
86 case MotionNotify: {
87 MouseEvent mouseev(xev);
88 handled = desktop_->OnMouseEvent(mouseev);
89 }
sky 2011/09/04 16:01:48 break
sadrul 2011/09/04 18:14:13 Done.
76 } 90 }
77 return EVENT_IGNORED; 91 return handled ? EVENT_PROCESSED : EVENT_IGNORED;
78 } 92 }
79 93
80 void DesktopHostLinux::SetDesktop(Desktop* desktop) { 94 void DesktopHostLinux::SetDesktop(Desktop* desktop) {
81 desktop_ = desktop; 95 desktop_ = desktop;
82 } 96 }
83 97
84 gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() { 98 gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() {
85 return xwindow_; 99 return xwindow_;
86 } 100 }
87 101
88 void DesktopHostLinux::Show() { 102 void DesktopHostLinux::Show() {
89 } 103 }
90 104
91 gfx::Size DesktopHostLinux::GetSize() { 105 gfx::Size DesktopHostLinux::GetSize() {
92 return bounds_.size(); 106 return bounds_.size();
93 } 107 }
94 108
109 void DesktopHostLinux::SetSize(const gfx::Size& size) {
110 XResizeWindow(xdisplay_, xwindow_, size.width(), size.height());
111 }
112
95 } // namespace 113 } // namespace
96 114
97 // static 115 // static
98 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { 116 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) {
99 return new DesktopHostLinux(bounds); 117 return new DesktopHostLinux(bounds);
100 } 118 }
101 119
102 } // namespace aura 120 } // namespace aura
OLDNEW
« no previous file with comments | « aura/desktop.h ('k') | aura/event.h » ('j') | aura/event.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698