summaryrefslogtreecommitdiffstats
path: root/aura
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-22 16:01:19 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-22 16:01:19 +0000
commit711d8a82e7ce1fc9531fed9311b21ea707e78b8e (patch)
treee7617475969ee552e3b50f3ef7887b2ab2964983 /aura
parent3ec620efa02c8c77e426cb4dd091506b6a5381e9 (diff)
downloadchromium_src-711d8a82e7ce1fc9531fed9311b21ea707e78b8e.zip
chromium_src-711d8a82e7ce1fc9531fed9311b21ea707e78b8e.tar.gz
chromium_src-711d8a82e7ce1fc9531fed9311b21ea707e78b8e.tar.bz2
aura: Desktop-host implementation for linux in pure X.
Also, make DesktopHost the entry point for events into aura from the message-pump. BUG=none TEST=none Review URL: http://codereview.chromium.org/7686019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'aura')
-rw-r--r--aura/aura.gyp1
-rw-r--r--aura/demo/demo_main.cc6
-rw-r--r--aura/desktop_host.h3
-rw-r--r--aura/desktop_host_linux.cc102
-rw-r--r--aura/desktop_host_win.cc5
-rw-r--r--aura/desktop_host_win.h5
-rw-r--r--aura/event.h3
7 files changed, 122 insertions, 3 deletions
diff --git a/aura/aura.gyp b/aura/aura.gyp
index 3f24b3e..fa76c99 100644
--- a/aura/aura.gyp
+++ b/aura/aura.gyp
@@ -21,6 +21,7 @@
],
'sources': [
'desktop_host.h',
+ 'desktop_host_linux.cc',
'desktop_host_win.cc',
'desktop_host_win.h',
'desktop.cc',
diff --git a/aura/demo/demo_main.cc b/aura/demo/demo_main.cc
index 2c8091d..908e63b 100644
--- a/aura/demo/demo_main.cc
+++ b/aura/demo/demo_main.cc
@@ -59,6 +59,10 @@ int main(int argc, char** argv) {
icu_util::Initialize();
ResourceBundle::InitSharedInstance("en-US");
+#if defined(USE_X11)
+ base::MessagePumpX::DisableGtkMessagePump();
+#endif
+
// Create the DesktopHost and Desktop.
scoped_ptr<aura::DesktopHost> host(
aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768)));
@@ -96,6 +100,6 @@ int main(int argc, char** argv) {
host->Show();
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
- MessageLoopForUI::current()->Run(NULL);
+ MessageLoopForUI::current()->Run(host.get());
return 0;
}
diff --git a/aura/desktop_host.h b/aura/desktop_host.h
index d0e7d4a..f7ba295 100644
--- a/aura/desktop_host.h
+++ b/aura/desktop_host.h
@@ -6,6 +6,7 @@
#define AURA_DESKTOP_HOST_H_
#pragma once
+#include "base/message_loop.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
@@ -19,7 +20,7 @@ class Desktop;
// DesktopHost bridges between a native window and the embedded Desktop. It
// provides the accelerated widget and maps events from the native os to aura.
-class DesktopHost {
+class DesktopHost : public MessageLoop::Dispatcher {
public:
virtual ~DesktopHost() {}
diff --git a/aura/desktop_host_linux.cc b/aura/desktop_host_linux.cc
new file mode 100644
index 0000000..746be03
--- /dev/null
+++ b/aura/desktop_host_linux.cc
@@ -0,0 +1,102 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "aura/desktop_host.h"
+
+#include "aura/desktop.h"
+#include "base/message_loop.h"
+#include "base/message_pump_x.h"
+
+#include <X11/Xlib.h>
+
+namespace aura {
+
+namespace {
+
+class DesktopHostLinux : public DesktopHost {
+ public:
+ explicit DesktopHostLinux(const gfx::Rect& bounds);
+ virtual ~DesktopHostLinux();
+
+ private:
+ // base::MessageLoop::Dispatcher Override.
+ virtual DispatchStatus Dispatch(XEvent* xev) OVERRIDE;
+
+ // DesktopHost Overrides.
+ virtual void SetDesktop(Desktop* desktop) OVERRIDE;
+ virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
+ virtual void Show() OVERRIDE;
+ virtual gfx::Size GetSize() OVERRIDE;
+
+ Desktop* desktop_;
+
+ // The display and the native X window hosting the desktop.
+ Display* xdisplay_;
+ ::Window xwindow_;
+
+ // The size of |xwindow_|.
+ gfx::Rect bounds_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopHostLinux);
+};
+
+DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds)
+ : desktop_(NULL),
+ xdisplay_(NULL),
+ xwindow_(0),
+ bounds_(bounds) {
+ // This assumes that the message-pump creates and owns the display.
+ xdisplay_ = base::MessagePumpX::GetDefaultXDisplay();
+ xwindow_ = XCreateSimpleWindow(xdisplay_, DefaultRootWindow(xdisplay_),
+ bounds.x(), bounds.y(),
+ bounds.width(), bounds.height(),
+ 0, 0, 0);
+ XMapWindow(xdisplay_, xwindow_);
+
+ long event_mask = ButtonPressMask | ButtonReleaseMask |
+ KeyPressMask | KeyReleaseMask |
+ ExposureMask | VisibilityChangeMask |
+ StructureNotifyMask | PropertyChangeMask;
+ XSelectInput(xdisplay_, xwindow_, event_mask);
+ XFlush(xdisplay_);
+}
+
+DesktopHostLinux::~DesktopHostLinux() {
+ XDestroyWindow(xdisplay_, xwindow_);
+}
+
+base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch(
+ XEvent* xev) {
+ // TODO(sad): Create events and dispatch to the appropriate window.
+ switch (xev->type) {
+ case Expose:
+ desktop_->Draw();
+ break;
+ }
+ return EVENT_IGNORED;
+}
+
+void DesktopHostLinux::SetDesktop(Desktop* desktop) {
+ desktop_ = desktop;
+}
+
+gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() {
+ return xwindow_;
+}
+
+void DesktopHostLinux::Show() {
+}
+
+gfx::Size DesktopHostLinux::GetSize() {
+ return bounds_.size();
+}
+
+} // namespace
+
+// static
+DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) {
+ return new DesktopHostLinux(bounds);
+}
+
+} // namespace aura
diff --git a/aura/desktop_host_win.cc b/aura/desktop_host_win.cc
index 70489ea..d418150 100644
--- a/aura/desktop_host_win.cc
+++ b/aura/desktop_host_win.cc
@@ -22,6 +22,11 @@ DesktopHostWin::~DesktopHostWin() {
DestroyWindow(hwnd());
}
+bool DesktopHostWin::Dispatch(const MSG& msg) {
+ // TODO(ben):
+ return true;
+}
+
void DesktopHostWin::SetDesktop(Desktop* desktop) {
desktop_ = desktop;
}
diff --git a/aura/desktop_host_win.h b/aura/desktop_host_win.h
index 9513a37..0f0d68f 100644
--- a/aura/desktop_host_win.h
+++ b/aura/desktop_host_win.h
@@ -14,9 +14,12 @@ namespace aura {
class DesktopHostWin : public DesktopHost, public ui::WindowImpl {
public:
- DesktopHostWin(const gfx::Rect& bounds);
+ explicit DesktopHostWin(const gfx::Rect& bounds);
virtual ~DesktopHostWin();
+ // MessageLoop::Dispatcher:
+ virtual bool Dispatch(const MSG& msg);
+
// DesktopHost:
virtual void SetDesktop(Desktop* desktop) OVERRIDE;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
diff --git a/aura/event.h b/aura/event.h
index c717fc9..27a8f30 100644
--- a/aura/event.h
+++ b/aura/event.h
@@ -16,6 +16,9 @@ namespace aura {
#if defined(OS_WIN)
typedef MSG NativeEvent;
+#elif defined(USE_X11)
+typedef union _XEvent XEvent;
+typedef XEvent* NativeEvent;
#endif
class Event {