diff options
60 files changed, 23 insertions, 2376 deletions
diff --git a/base/base.gypi b/base/base.gypi index bc310e6..f9fb0c0 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -400,7 +400,6 @@ 'nix/mime_util_xdg.h', 'nix/xdg_util.cc', 'nix/xdg_util.h', - 'wayland/wayland_event.h', 'win/accessibility_misc_utils.h', 'win/accessibility_misc_utils.cc', 'win/enum_variant.h', @@ -478,12 +477,6 @@ 'sources!' : [ 'message_pump_gtk.cc', ], 'sources/' : [ [ 'include', '^message_pump_x\\.cc$', ] ], }], - [ 'use_wayland==1', { - 'sources/': [ - [ 'exclude', '^message_pump_gtk\\.cc$',], - [ 'exclude', '^message_pump_x\\.cc$',], - ], - }], [ 'OS != "linux" and os_bsd != 1', { 'sources!': [ # Not automatically excluded by the *linux.cc rules. @@ -783,7 +776,6 @@ 'message_pump_libevent.h', 'message_pump_mac.h', 'message_pump_mac.mm', - 'message_pump_wayland.h', 'metrics/field_trial.cc', 'metrics/field_trial.h', 'string16.cc', diff --git a/base/event_types.h b/base/event_types.h index ed0f02f..3a3b6d2 100644 --- a/base/event_types.h +++ b/base/event_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -10,12 +10,6 @@ #if defined(OS_WIN) #include <windows.h> -#elif defined(USE_WAYLAND) -namespace base { -namespace wayland { -union WaylandEvent; -} -} #elif defined(USE_X11) typedef union _XEvent XEvent; #elif defined(OS_MACOSX) @@ -31,8 +25,6 @@ namespace base { // Cross platform typedefs for native event types. #if defined(OS_WIN) typedef MSG NativeEvent; -#elif defined(USE_WAYLAND) -typedef wayland::WaylandEvent* NativeEvent; #elif defined(USE_X11) typedef XEvent* NativeEvent; #elif defined(OS_MACOSX) diff --git a/base/message_loop.h b/base/message_loop.h index 0611ad4..4527c5b 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -31,9 +31,7 @@ #include "base/message_pump_libevent.h" #if !defined(OS_MACOSX) && !defined(OS_ANDROID) -#if defined(USE_WAYLAND) -#include "base/message_pump_wayland.h" -#elif defined(USE_AURA) +#if defined(USE_AURA) #include "base/message_pump_x.h" #else #include "base/message_pump_gtk.h" diff --git a/base/message_pump_wayland.h b/base/message_pump_wayland.h deleted file mode 100644 index 89c9b8f..0000000 --- a/base/message_pump_wayland.h +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -#ifndef BASE_MESSAGE_PUMP_WAYLAND_H_ -#define BASE_MESSAGE_PUMP_WAYLAND_H_ -#pragma once - -#include "base/memory/scoped_ptr.h" -#include "base/message_pump_glib.h" -#include "base/message_pump_observer.h" - -namespace base { - -namespace wayland { -union WaylandEvent; -} - -// The documentation for this class is in message_pump_glib.h -// -// The nested loop is exited by either posting a quit, or returning false -// from Dispatch. -class MessagePumpDispatcher { - public: - enum DispatchStatus { - EVENT_IGNORED, // The event was not processed. - EVENT_PROCESSED, // The event has been processed. - EVENT_QUIT // The event was processed and the message-loop should - // terminate. - }; - - // Dispatches the event. If true is returned processing continues as - // normal. If false is returned, the nested loop exits immediately. - virtual DispatchStatus Dispatch(wayland::WaylandEvent* event) = 0; - - protected: - virtual ~MessagePumpDispatcher() {} -}; - -typedef MessagePumpGlib MessagePumpForUI; - -} // namespace base - -#endif // BASE_MESSAGE_PUMP_WAYLAND_H_ diff --git a/base/wayland/wayland_event.h b/base/wayland/wayland_event.h deleted file mode 100644 index 1d6808d..0000000 --- a/base/wayland/wayland_event.h +++ /dev/null @@ -1,117 +0,0 @@ -// 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. - -#ifndef BASE_WAYLAND_WAYLAND_EVENT_H_ -#define BASE_WAYLAND_WAYLAND_EVENT_H_ - -#include <stdint.h> - -// Wayland event information is being passed in as arguments to the callbacks. -// (See wayland_input_device.{h,cc} for information on the callbacks and how -// events are processed.) -// In order to provide a more generic look for events we wrap these arguments -// in specific event structs. Then define a WaylandEvent as a union of all -// types of events that Wayland will send. -// -// The following fields are common for most event types and their use is -// similar: -// - time: -// The time of the event. This should be monotonically increasing. -// - state: -// The value of the button event as given by evdev. This is 0 if button -// isn't pressed. -// - modifiers: -// Stores all the keyboard modifiers (Ctrl, Alt, Shift, ...) currently -// active. The modifiers are values as defined by xkbcommon. - -namespace base { -namespace wayland { - -// Types of events Wayland will send -enum WaylandEventType { - WAYLAND_BUTTON, - WAYLAND_KEY, - WAYLAND_MOTION, - WAYLAND_POINTER_FOCUS, - WAYLAND_KEYBOARD_FOCUS, - WAYLAND_GEOMETRY_CHANGE, -}; - -struct WaylandEventButton { - WaylandEventType type; - uint32_t time; - // WaylandEventButtonType defines some of the values button can take - uint32_t button; - uint32_t state; - uint32_t modifiers; - int32_t x; - int32_t y; -}; - -struct WaylandEventKey { - WaylandEventType type; - uint32_t time; - // The raw key value that evdev returns. - uint32_t key; - // The key symbol returned by processing the raw key using the xkbcommon - // library. - uint32_t sym; - uint32_t state; - uint32_t modifiers; -}; - -// Triggered when there is a motion event. The motion event is triggered -// only if there is a window under focus. -struct WaylandEventMotion { - WaylandEventType type; - uint32_t time; - uint32_t modifiers; - int32_t x; - int32_t y; -}; - -// Triggered when a window enters/exits pointer focus. The state tells us -// if the window lost focus (state == 0) or gained focus (state != 0). -struct WaylandEventPointerFocus { - WaylandEventType type; - uint32_t time; - uint32_t state; - int32_t x; - int32_t y; -}; - -// Triggered when a window enters/exits keyboard focus. The state tells us -// if the window lost focus (state == 0) or gained focus (state != 0). -struct WaylandEventKeyboardFocus { - WaylandEventType type; - uint32_t time; - uint32_t state; - uint32_t modifiers; -}; - -// Event triggered when a window's geometry changes. The event contains the -// position and dimensions of the window. -struct WaylandEventGeometryChange { - WaylandEventType type; - uint32_t time; - int32_t x; - int32_t y; - int32_t width; - int32_t height; -}; - -union WaylandEvent { - WaylandEventType type; - WaylandEventButton button; - WaylandEventKey key; - WaylandEventMotion motion; - WaylandEventPointerFocus pointer_focus; - WaylandEventKeyboardFocus keyboard_focus; - WaylandEventGeometryChange geometry_change; -}; - -} // namespace wayland -} // namespace base - -#endif // BASE_WAYLAND_WAYLAND_EVENT_H_ diff --git a/build/all.gyp b/build/all.gyp index ee51f10..90afd5c 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -90,11 +90,6 @@ }], ], }], - ['use_wayland==1', { - 'dependencies': [ - '../ui/wayland/wayland.gyp:*', - ], - }], ['toolkit_uses_gtk==1', { 'dependencies': [ '../tools/gtk_clipboard_dump/gtk_clipboard_dump.gyp:*', diff --git a/build/common.gypi b/build/common.gypi index 10105c8..9739cc1 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -518,9 +518,6 @@ 'force_rlz_use_chrome_net%': '<(force_rlz_use_chrome_net)', 'enable_task_manager%': '<(enable_task_manager)', - # Whether to build for Wayland display server - 'use_wayland%': 0, - # Use system yasm instead of bundled one. 'use_system_yasm%': 0, @@ -1207,9 +1204,6 @@ ['use_xi2_mt!=0', { 'defines': ['USE_XI2_MT=<(use_xi2_mt)'], }], - ['use_wayland==1', { - 'defines': ['USE_WAYLAND=1', 'WL_EGL_PLATFORM=1'], - }], ['file_manager_extension==1', { 'defines': ['FILE_MANAGER_EXTENSION=1'], }], diff --git a/build/filename_rules.gypi b/build/filename_rules.gypi index 1de7e5d..d5a5a65 100644 --- a/build/filename_rules.gypi +++ b/build/filename_rules.gypi @@ -80,12 +80,5 @@ ['exclude', '(^|/)ash/'], ] }], - ['use_wayland!=1', { - 'sources/': [ - ['exclude', '_(wayland)(_unittest)?\\.(h|cc)$'], - ['exclude', '(^|/)wayland/'], - ['exclude', '(^|/)(wayland)_[^/]*\\.(h|cc)$'], - ], - }], ] } diff --git a/build/linux/system.gyp b/build/linux/system.gyp index 5170c10..b82c36c 100644 --- a/build/linux/system.gyp +++ b/build/linux/system.gyp @@ -609,30 +609,6 @@ ], }, { - 'target_name': 'wayland', - 'type': 'none', - 'conditions': [ - ['use_wayland == 1', { - 'cflags': [ - '<!@(<(pkg-config) --cflags cairo wayland-client wayland-egl xkbcommon)', - ], - 'direct_dependent_settings': { - 'cflags': [ - '<!@(<(pkg-config) --cflags cairo wayland-client wayland-egl xkbcommon)', - ], - }, - 'link_settings': { - 'ldflags': [ - '<!@(<(pkg-config) --libs-only-L --libs-only-other wayland-client wayland-egl xkbcommon)', - ], - 'libraries': [ - '<!@(<(pkg-config) --libs-only-l wayland-client wayland-egl xkbcommon)', - ], - }, - }], - ], - }, - { 'target_name': 'udev', 'type': 'none', 'conditions': [ diff --git a/chrome/browser/chromeos/system_key_event_listener.cc b/chrome/browser/chromeos/system_key_event_listener.cc index 2c7780e..7ff74bf 100644 --- a/chrome/browser/chromeos/system_key_event_listener.cc +++ b/chrome/browser/chromeos/system_key_event_listener.cc @@ -10,16 +10,11 @@ #include <X11/XKBlib.h> #undef Status +#include "base/message_pump_x.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/chromeos/input_method/xkeyboard.h" #include "ui/base/x/x11_util.h" -#if defined(USE_WAYLAND) -#include "base/message_pump_wayland.h" -#else -#include "base/message_pump_x.h" -#endif - namespace chromeos { namespace { diff --git a/chrome/browser/ui/views/infobars/infobar_background.cc b/chrome/browser/ui/views/infobars/infobar_background.cc index 383e394..9144578 100644 --- a/chrome/browser/ui/views/infobars/infobar_background.cc +++ b/chrome/browser/ui/views/infobars/infobar_background.cc @@ -8,7 +8,6 @@ #include "chrome/browser/ui/views/infobars/infobar_view.h" #include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/canvas_skia_paint.h" #include "ui/gfx/color_utils.h" #include "ui/views/view.h" diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index 4570d73..e0e0f37 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -23,7 +23,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/canvas_skia_paint.h" #include "ui/gfx/image/image.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/menu_button.h" diff --git a/content/browser/renderer_host/image_transport_client_linux.cc b/content/browser/renderer_host/image_transport_client_linux.cc index 1153c6a..779e1eb 100644 --- a/content/browser/renderer_host/image_transport_client_linux.cc +++ b/content/browser/renderer_host/image_transport_client_linux.cc @@ -83,8 +83,6 @@ class ImageTransportClientEGL : public ImageTransportClient { EGLImageKHR image_; }; -#if !defined(USE_WAYLAND) - class ImageTransportClientGLX : public ImageTransportClient { public: ImageTransportClientGLX(ImageTransportFactory* factory, const gfx::Size& size) @@ -289,20 +287,16 @@ class ImageTransportClientOSMesa : public ImageTransportClient { }; uint32 ImageTransportClientOSMesa::next_handle_ = 0; -#endif // !USE_WAYLAND - } // anonymous namespace ImageTransportClient* ImageTransportClient::Create( ImageTransportFactory* factory, const gfx::Size& size) { switch (gfx::GetGLImplementation()) { -#if !defined(USE_WAYLAND) case gfx::kGLImplementationOSMesaGL: return new ImageTransportClientOSMesa(factory, size); case gfx::kGLImplementationDesktopGL: return new ImageTransportClientGLX(factory, size); -#endif case gfx::kGLImplementationEGLGLES2: return new ImageTransportClientEGL(factory, size); default: diff --git a/skia/ext/canvas_paint.h b/skia/ext/canvas_paint.h index 89923b66..d1925d9 100644 --- a/skia/ext/canvas_paint.h +++ b/skia/ext/canvas_paint.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -14,12 +14,10 @@ #elif defined(__APPLE__) #include "skia/ext/canvas_paint_mac.h" #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) -#if defined(USE_WAYLAND) -#include "skia/ext/canvas_paint_wayland.h" -#elif defined(TOOLKIT_GTK) +#if defined(TOOLKIT_GTK) #include "skia/ext/canvas_paint_gtk.h" #else -#include "skia/ext/canvas_paint_x.h" +#error "No canvas paint for this platform" #endif #endif diff --git a/skia/ext/canvas_paint_wayland.h b/skia/ext/canvas_paint_wayland.h deleted file mode 100644 index bceb8bb..0000000 --- a/skia/ext/canvas_paint_wayland.h +++ /dev/null @@ -1,115 +0,0 @@ -// 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. - -#ifndef SKIA_EXT_CANVAS_PAINT_WAYLAND_H_ -#define SKIA_EXT_CANVAS_PAINT_WAYLAND_H_ -#pragma once - -#include "base/logging.h" -#include "skia/ext/canvas_paint_common.h" -#include "skia/ext/platform_canvas.h" - -namespace skia { - -// A class designed to translate skia painting into a region in a Wayland window -// surface. On construction, it will set up a context for painting into, and on -// destruction, it will commit it to the Wayland window surface. -// Note: The created context is always inialized to (0, 0, 0, 0). -template <class T> -class CanvasPaintT : public T { - public: - // This constructor assumes the result is opaque. - CanvasPaintT(cairo_surface_t* cairo_window_surface, - cairo_rectangle_int_t* region) - : context_(NULL), - cairo_window_surface_(cairo_window_surface), - region_(region), - composite_alpha_(false) { - init(true); - } - - CanvasPaintT(cairo_surface_t* cairo_window_surface, - cairo_rectangle_int_t* region, - bool opaque) - : context_(NULL), - cairo_window_surface_(cairo_window_surface), - region_(region), - composite_alpha_(false) { - init(opaque); - } - - virtual ~CanvasPaintT() { - if (!is_empty()) { - PlatformCanvas* canvas = GetPlatformCanvas(this); - canvas->restoreToCount(1); - - // Blit the dirty rect to the window. - CHECK(cairo_window_surface_); - cairo_t* cr = cairo_create(cairo_window_surface_); - CHECK(cr); - - if (composite_alpha_) - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - - cairo_surface_t* source_surface = cairo_get_target(context_); - CHECK(source_surface); - // Flush cairo's cache of the surface. - cairo_surface_mark_dirty(source_surface); - cairo_set_source_surface(cr, source_surface, region_->x, region_->y); - cairo_rectangle(cr, - region_->x, - region_->y, - region_->width, - region_->height); - cairo_fill(cr); - cairo_destroy(cr); - } - } - - // Sets whether the bitmap is composited in such a way that the alpha channel - // is honored. This is only useful if you've enabled an RGBA colormap on the - // widget. The default is false. - void set_composite_alpha(bool composite_alpha) { - composite_alpha_ = composite_alpha; - } - - // Returns true if the invalid region is empty. The caller should call this - // function to determine if anything needs painting. - bool is_empty() const { - return region_->width == 0 && region_->height == 0; - } - - private: - void init(bool opaque) { - PlatformCanvas* canvas = GetPlatformCanvas(this); - if (!canvas->initialize(region_->width, region_->height, opaque, NULL)) { - // Cause a deliberate crash; - CHECK(false); - } - // No need to clear the canvas, because cairo automatically performs the - // clear. - - // Need to translate so that the dirty region appears at the origin of the - // surface. - canvas->translate(-SkIntToScalar(region_->x), -SkIntToScalar(region_->y)); - - context_ = BeginPlatformPaint(canvas); - } - - cairo_t* context_; - cairo_surface_t* cairo_window_surface_; - cairo_rectangle_int_t* region_; - // See description above setter. - bool composite_alpha_; - - // Disallow copy and assign. - CanvasPaintT(const CanvasPaintT&); - CanvasPaintT& operator=(const CanvasPaintT&); -}; - -typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint; - -} // namespace skia - -#endif // SKIA_EXT_CANVAS_PAINT_WAYLAND_H_ diff --git a/skia/ext/canvas_paint_x.h b/skia/ext/canvas_paint_x.h deleted file mode 100644 index a714a2e..0000000 --- a/skia/ext/canvas_paint_x.h +++ /dev/null @@ -1,118 +0,0 @@ -// 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. - -#ifndef SKIA_EXT_CANVAS_PAINT_WAYLAND_H_ -#define SKIA_EXT_CANVAS_PAINT_WAYLAND_H_ -#pragma once - -#include "base/logging.h" -#include "skia/ext/canvas_paint_common.h" -#include "skia/ext/platform_canvas.h" - -#include <cairo/cairo.h> - -namespace skia { - -// A class designed to translate skia painting into a region in a Wayland window -// surface. On construction, it will set up a context for painting into, and on -// destruction, it will commit it to the Wayland window surface. -// Note: The created context is always inialized to (0, 0, 0, 0). -template <class T> -class CanvasPaintT : public T { - public: - // This constructor assumes the result is opaque. - CanvasPaintT(cairo_surface_t* cairo_window_surface, - cairo_rectangle_t* region) - : context_(NULL), - cairo_window_surface_(cairo_window_surface), - region_(region), - composite_alpha_(false) { - init(true); - } - - CanvasPaintT(cairo_surface_t* cairo_window_surface, - cairo_rectangle_t* region, - bool opaque) - : context_(NULL), - cairo_window_surface_(cairo_window_surface), - region_(region), - composite_alpha_(false) { - init(opaque); - } - - virtual ~CanvasPaintT() { - if (!is_empty()) { - PlatformCanvas* canvas = GetPlatformCanvas(this); - canvas->restoreToCount(1); - - // Blit the dirty rect to the window. - CHECK(cairo_window_surface_); - cairo_t* cr = cairo_create(cairo_window_surface_); - CHECK(cr); - - if (composite_alpha_) - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - - cairo_surface_t* source_surface = cairo_get_target(context_); - CHECK(source_surface); - // Flush cairo's cache of the surface. - cairo_surface_mark_dirty(source_surface); - cairo_set_source_surface(cr, source_surface, region_->x, region_->y); - cairo_rectangle(cr, - region_->x, - region_->y, - region_->width, - region_->height); - cairo_fill(cr); - cairo_destroy(cr); - } - } - - // Sets whether the bitmap is composited in such a way that the alpha channel - // is honored. This is only useful if you've enabled an RGBA colormap on the - // widget. The default is false. - void set_composite_alpha(bool composite_alpha) { - composite_alpha_ = composite_alpha; - } - - // Returns true if the invalid region is empty. The caller should call this - // function to determine if anything needs painting. - bool is_empty() const { - return region_->width == 0 && region_->height == 0; - } - - private: - void init(bool opaque) { - PlatformCanvas* canvas = GetPlatformCanvas(this); - if (!canvas->initialize(region_->width, region_->height, opaque, NULL)) { - // Cause a deliberate crash; - CHECK(false); - } - // No need to clear the canvas, because cairo automatically performs the - // clear. - - // Need to translate so that the dirty region appears at the origin of the - // surface. - canvas->translate(-SkDoubleToScalar(region_->x), - -SkDoubleToScalar(region_->y)); - - context_ = BeginPlatformPaint(canvas); - } - - cairo_t* context_; - cairo_surface_t* cairo_window_surface_; - cairo_rectangle_t* region_; - // See description above setter. - bool composite_alpha_; - - // Disallow copy and assign. - CanvasPaintT(const CanvasPaintT&); - CanvasPaintT& operator=(const CanvasPaintT&); -}; - -typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint; - -} // namespace skia - -#endif // SKIA_EXT_CANVAS_PAINT_WAYLAND_H_ diff --git a/skia/skia.gyp b/skia/skia.gyp index 6c81a56..c4a8388 100644 --- a/skia/skia.gyp +++ b/skia/skia.gyp @@ -696,9 +696,7 @@ 'ext/canvas_paint_common.h', 'ext/canvas_paint_gtk.h', 'ext/canvas_paint_mac.h', - 'ext/canvas_paint_wayland.h', 'ext/canvas_paint_win.h', - 'ext/canvas_paint_x.h', 'ext/convolver.cc', 'ext/convolver.h', 'ext/google_logging.cc', diff --git a/ui/base/wayland/events_wayland.cc b/ui/base/wayland/events_wayland.cc deleted file mode 100644 index cec7c49..0000000 --- a/ui/base/wayland/events_wayland.cc +++ /dev/null @@ -1,151 +0,0 @@ -// 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 "ui/base/events.h" - -#include <linux/input.h> -#include <X11/extensions/XInput2.h> - -#include "base/event_types.h" -#include "base/logging.h" -#include "ui/base/keycodes/keyboard_code_conversion_x.h" -#include "ui/gfx/point.h" - -using namespace base::wayland; - -namespace ui { - -// These are the mouse events expected. The event type Wayland sends is an -// evdev event. The following is the correct mapping from evdev to expected -// events type. -enum WaylandEventButtonType { - LEFT_BUTTON = BTN_LEFT, - MIDDLE_BUTTON = BTN_RIGHT, - RIGHT_BUTTON = BTN_MIDDLE, - SCROLL_UP = BTN_SIDE, - SCROLL_DOWN = BTN_EXTRA, -}; - -} // namespace ui - -namespace { - -// Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. -static int kWheelScrollAmount = 53; - -int GetEventFlagsFromState(unsigned int state) { - int flags = 0; - if (state & ControlMask) - flags |= ui::EF_CONTROL_DOWN; - if (state & ShiftMask) - flags |= ui::EF_SHIFT_DOWN; - if (state & Mod1Mask) - flags |= ui::EF_ALT_DOWN; - if (state & LockMask) - flags |= ui::EF_CAPS_LOCK_DOWN; - if (state & Button1Mask) - flags |= ui::EF_LEFT_MOUSE_BUTTON; - if (state & Button2Mask) - flags |= ui::EF_MIDDLE_MOUSE_BUTTON; - if (state & Button3Mask) - flags |= ui::EF_RIGHT_MOUSE_BUTTON; - - return flags; -} - -int GetButtonEventFlagsFromNativeEvent(const base::NativeEvent& native_event) { - // TODO(dnicoara): Need to add double click. - int flags = 0; - switch (native_event->button.button) { - case ui::LEFT_BUTTON: - return flags | ui::EF_LEFT_MOUSE_BUTTON; - case ui::MIDDLE_BUTTON: - return flags | ui::EF_MIDDLE_MOUSE_BUTTON; - case ui::RIGHT_BUTTON: - return flags | ui::EF_RIGHT_MOUSE_BUTTON; - } - return flags; -} - -} // namespace - -namespace ui { - -EventType EventTypeFromNative(const base::NativeEvent& native_event) { - switch (native_event->type) { - case WAYLAND_BUTTON: - switch (native_event->button.button) { - case LEFT_BUTTON: - case RIGHT_BUTTON: - case MIDDLE_BUTTON: - return native_event->button.state ? ET_MOUSE_PRESSED - : ET_MOUSE_RELEASED; - case SCROLL_UP: - case SCROLL_DOWN: - return ET_MOUSEWHEEL; - default: - break; - } - break; - case WAYLAND_KEY: - return native_event->key.state ? ET_KEY_PRESSED : ET_KEY_RELEASED; - case WAYLAND_MOTION: - return ET_MOUSE_MOVED; - case WAYLAND_POINTER_FOCUS: - return native_event->pointer_focus.state ? ET_MOUSE_ENTERED - : ET_MOUSE_EXITED; - case WAYLAND_KEYBOARD_FOCUS: - return ET_UNKNOWN; - default: - break; - } - return ET_UNKNOWN; -} - -int EventFlagsFromNative(const base::NativeEvent& native_event) { - switch (native_event->type) { - case WAYLAND_BUTTON: - return GetButtonEventFlagsFromNativeEvent(native_event) | - GetEventFlagsFromState(native_event->button.modifiers); - case WAYLAND_KEY: - return GetEventFlagsFromState(native_event->key.modifiers); - case WAYLAND_MOTION: - return GetEventFlagsFromState(native_event->motion.modifiers); - case WAYLAND_KEYBOARD_FOCUS: - return GetEventFlagsFromState(native_event->keyboard_focus.modifiers); - default: - return 0; - } -} - -gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { - switch (native_event->type) { - case WAYLAND_BUTTON: - return gfx::Point(native_event->button.x, native_event->button.y); - case WAYLAND_MOTION: - return gfx::Point(native_event->motion.x, native_event->motion.y); - case WAYLAND_POINTER_FOCUS: - return gfx::Point(native_event->pointer_focus.x, - native_event->pointer_focus.y); - default: - return gfx::Point(); - } -} - -KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { - return KeyboardCodeFromXKeysym(native_event->key.sym); -} - -bool IsMouseEvent(const base::NativeEvent& native_event) { - return native_event->type == WAYLAND_BUTTON || - native_event->type == WAYLAND_MOTION || - native_event->type == WAYLAND_POINTER_FOCUS; -} - -int GetMouseWheelOffset(const base::NativeEvent& native_event) { - return native_event->button.button == SCROLL_UP ? - kWheelScrollAmount : -kWheelScrollAmount; -} - -} // namespace ui diff --git a/ui/gfx/gl/gl.gyp b/ui/gfx/gl/gl.gyp index 9132b5e..9db771a 100644 --- a/ui/gfx/gl/gl.gyp +++ b/ui/gfx/gl/gl.gyp @@ -137,7 +137,7 @@ '<(DEPTH)/third_party/angle/include', ], }], - ['use_x11 == 1 and use_wayland != 1', { + ['use_x11 == 1', { 'sources': [ 'gl_context_glx.cc', 'gl_context_glx.h', diff --git a/ui/gfx/gl/gl_bindings.h b/ui/gfx/gl/gl_bindings.h index 6d947ca..b2ad79d 100644 --- a/ui/gfx/gl/gl_bindings.h +++ b/ui/gfx/gl/gl_bindings.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -74,10 +74,6 @@ typedef HWND EGLNativeWindowType; typedef void *EGLNativeDisplayType; typedef struct egl_native_pixmap_t *EGLNativePixmapType; typedef struct ANativeWindow *EGLNativeWindowType; -#elif defined(USE_WAYLAND) -typedef struct wl_display *EGLNativeDisplayType; -typedef struct wl_egl_pixmap *EGLNativePixmapType; -typedef struct wl_egl_window *EGLNativeWindowType; #else typedef Display *EGLNativeDisplayType; typedef Pixmap EGLNativePixmapType; diff --git a/ui/gfx/gl/gl_context_linux.cc b/ui/gfx/gl/gl_context_linux.cc index a6f7525..121abee 100644 --- a/ui/gfx/gl/gl_context_linux.cc +++ b/ui/gfx/gl/gl_context_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -27,7 +27,6 @@ scoped_refptr<GLContext> GLContext::CreateGLContext( GLSurface* compatible_surface, GpuPreference gpu_preference) { switch (GetGLImplementation()) { -#if !defined(USE_WAYLAND) case kGLImplementationOSMesaGL: { scoped_refptr<GLContext> context(new GLContextOSMesa(share_group)); if (!context->Initialize(compatible_surface, gpu_preference)) @@ -42,7 +41,6 @@ scoped_refptr<GLContext> GLContext::CreateGLContext( return context; } -#endif case kGLImplementationEGLGLES2: { scoped_refptr<GLContext> context(new GLContextEGL(share_group)); if (!context->Initialize(compatible_surface, gpu_preference)) diff --git a/ui/gfx/gl/gl_implementation_linux.cc b/ui/gfx/gl/gl_implementation_linux.cc index b03d94a..db8cb45 100644 --- a/ui/gfx/gl/gl_implementation_linux.cc +++ b/ui/gfx/gl/gl_implementation_linux.cc @@ -48,13 +48,9 @@ base::NativeLibrary LoadLibrary(const char* filename) { } // namespace anonymous void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { -#if !defined(USE_WAYLAND) impls->push_back(kGLImplementationDesktopGL); -#endif impls->push_back(kGLImplementationEGLGLES2); -#if !defined(USE_WAYLAND) impls->push_back(kGLImplementationOSMesaGL); -#endif } bool InitializeGLBindings(GLImplementation implementation) { @@ -71,7 +67,6 @@ bool InitializeGLBindings(GLImplementation implementation) { base::ThreadRestrictions::ScopedAllowIO allow_io; switch (implementation) { -#if !defined(USE_WAYLAND) case kGLImplementationOSMesaGL: { FilePath module_path; if (!PathService::Get(base::DIR_MODULE, &module_path)) { @@ -139,7 +134,6 @@ bool InitializeGLBindings(GLImplementation implementation) { InitializeGLBindingsGLX(); break; } -#endif // !defined(USE_WAYLAND) case kGLImplementationEGLGLES2: { base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so.2"); if (!gles_library) @@ -192,7 +186,6 @@ bool InitializeGLBindings(GLImplementation implementation) { bool InitializeGLExtensionBindings(GLImplementation implementation, GLContext* context) { switch (implementation) { -#if !defined(USE_WAYLAND) case kGLImplementationOSMesaGL: InitializeGLExtensionBindingsGL(context); InitializeGLExtensionBindingsOSMESA(context); @@ -201,7 +194,6 @@ bool InitializeGLExtensionBindings(GLImplementation implementation, InitializeGLExtensionBindingsGL(context); InitializeGLExtensionBindingsGLX(context); break; -#endif case kGLImplementationEGLGLES2: InitializeGLExtensionBindingsGL(context); InitializeGLExtensionBindingsEGL(context); @@ -219,19 +211,15 @@ bool InitializeGLExtensionBindings(GLImplementation implementation, void InitializeDebugGLBindings() { InitializeDebugGLBindingsEGL(); InitializeDebugGLBindingsGL(); -#if !defined(USE_WAYLAND) InitializeDebugGLBindingsGLX(); InitializeDebugGLBindingsOSMESA(); -#endif } void ClearGLBindings() { ClearGLBindingsEGL(); ClearGLBindingsGL(); -#if !defined(USE_WAYLAND) ClearGLBindingsGLX(); ClearGLBindingsOSMESA(); -#endif SetGLImplementation(kGLImplementationNone); UnloadGLNativeLibraries(); diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc index 7f4fb36..df529a2 100644 --- a/ui/gfx/gl/gl_surface_egl.cc +++ b/ui/gfx/gl/gl_surface_egl.cc @@ -23,16 +23,12 @@ // it brings in #defines that cause conflicts. #include "ui/gfx/gl/gl_bindings.h" -#if defined(USE_X11) && !defined(USE_WAYLAND) +#if defined(USE_X11) extern "C" { #include <X11/Xlib.h> } #endif -#if defined(USE_WAYLAND) -#include "ui/wayland/wayland_display.h" -#endif - namespace gfx { namespace { @@ -55,9 +51,7 @@ bool GLSurfaceEGL::InitializeOneOff() { if (initialized) return true; -#if defined(USE_WAYLAND) - g_native_display = ui::WaylandDisplay::Connect(NULL)->display(); -#elif defined(USE_X11) +#if defined(USE_X11) g_native_display = base::MessagePumpForUI::GetDefaultXDisplay(); #else g_native_display = EGL_DEFAULT_DISPLAY; @@ -81,12 +75,7 @@ bool GLSurfaceEGL::InitializeOneOff() { EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT -#if defined(USE_WAYLAND) - | EGL_PIXMAP_BIT, -#else - | EGL_PBUFFER_BIT, -#endif + EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, EGL_NONE }; diff --git a/ui/gfx/gl/gl_surface_egl.h b/ui/gfx/gl/gl_surface_egl.h index 2be03c2..a4a010b 100644 --- a/ui/gfx/gl/gl_surface_egl.h +++ b/ui/gfx/gl/gl_surface_egl.h @@ -23,8 +23,6 @@ typedef void* EGLSurface; typedef void* EGLNativeDisplayType; #elif defined(OS_WIN) typedef HDC EGLNativeDisplayType; -#elif defined(USE_WAYLAND) -typedef struct wl_display* EGLNativeDisplayType; #else typedef struct _XDisplay* EGLNativeDisplayType; #endif diff --git a/ui/gfx/gl/gl_surface_linux.cc b/ui/gfx/gl/gl_surface_linux.cc index 8273c7a..23164b9 100644 --- a/ui/gfx/gl/gl_surface_linux.cc +++ b/ui/gfx/gl/gl_surface_linux.cc @@ -7,22 +7,16 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#if !defined(USE_WAYLAND) #include "third_party/mesa/MesaLib/include/GL/osmesa.h" -#endif #include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_implementation.h" #include "ui/gfx/gl/gl_surface_egl.h" -#if !defined(USE_WAYLAND) #include "ui/gfx/gl/gl_surface_glx.h" #include "ui/gfx/gl/gl_surface_osmesa.h" -#endif #include "ui/gfx/gl/gl_surface_stub.h" namespace gfx { -#if !defined(USE_WAYLAND) - namespace { Display* g_osmesa_display; } // namespace anonymous @@ -54,11 +48,8 @@ class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa); }; -#endif // !USE_WAYLAND - bool GLSurface::InitializeOneOffInternal() { switch (GetGLImplementation()) { -#if !defined(USE_WAYLAND) case kGLImplementationDesktopGL: if (!GLSurfaceGLX::InitializeOneOff()) { LOG(ERROR) << "GLSurfaceGLX::InitializeOneOff failed."; @@ -71,7 +62,6 @@ bool GLSurface::InitializeOneOffInternal() { return false; } break; -#endif case kGLImplementationEGLGLES2: if (!GLSurfaceEGL::InitializeOneOff()) { LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; @@ -85,8 +75,6 @@ bool GLSurface::InitializeOneOffInternal() { return true; } -#if !defined(USE_WAYLAND) - NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( gfx::AcceleratedWidget window) : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)), @@ -272,8 +260,6 @@ bool NativeViewGLSurfaceOSMesa::PostSubBuffer( return true; } -#endif // !USE_WAYLAND - scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( bool software, gfx::AcceleratedWidget window) { @@ -281,7 +267,6 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return NULL; switch (GetGLImplementation()) { -#if !defined(USE_WAYLAND) case kGLImplementationOSMesaGL: { scoped_refptr<GLSurface> surface( new NativeViewGLSurfaceOSMesa(window)); @@ -298,7 +283,6 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return surface; } -#endif case kGLImplementationEGLGLES2: { scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL( false, window)); @@ -322,7 +306,6 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return NULL; switch (GetGLImplementation()) { -#if !defined(USE_WAYLAND) case kGLImplementationOSMesaGL: { scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, size)); @@ -338,7 +321,6 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return surface; } -#endif case kGLImplementationEGLGLES2: { scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(false, size)); if (!surface->Initialize()) diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h index 964ffc9..d804c20 100644 --- a/ui/gfx/native_widget_types.h +++ b/ui/gfx/native_widget_types.h @@ -80,16 +80,7 @@ typedef struct _PangoFontDescription PangoFontDescription; typedef struct _cairo cairo_t; #endif -#if defined(USE_WAYLAND) -typedef struct _GdkPixbuf GdkPixbuf; -struct wl_egl_window; - -namespace ui { -class WaylandWindow; -} - -typedef struct _GdkRegion GdkRegion; -#elif defined(TOOLKIT_GTK) +#if defined(TOOLKIT_GTK) typedef struct _GdkCursor GdkCursor; typedef union _GdkEvent GdkEvent; typedef struct _GdkPixbuf GdkPixbuf; @@ -120,14 +111,6 @@ typedef NSCursor* NativeCursor; typedef NSView* NativeView; typedef NSWindow* NativeWindow; typedef NSEvent* NativeEvent; -#elif defined(USE_WAYLAND) -typedef void* NativeCursor; -typedef ui::WaylandWindow* NativeView; -typedef ui::WaylandWindow* NativeWindow; -// TODO(dnicoara) This should be replaced with a cairo region or maybe -// a Wayland specific region -typedef GdkRegion* NativeRegion; -typedef void* NativeEvent; #elif defined(TOOLKIT_GTK) typedef GdkCursor* NativeCursor; typedef GtkWidget* NativeView; @@ -154,12 +137,6 @@ typedef NSTextField* NativeEditView; typedef CGContext* NativeDrawingContext; typedef void* NativeMenu; typedef void* NativeViewAccessible; -#elif defined(USE_WAYLAND) -typedef PangoFontDescription* NativeFont; -typedef void* NativeEditView; -typedef cairo_t* NativeDrawingContext; -typedef void* NativeMenu; -typedef void* NativeViewAccessible; #elif defined(TOOLKIT_GTK) typedef PangoFontDescription* NativeFont; typedef GtkWidget* NativeEditView; @@ -233,9 +210,6 @@ static inline NativeView NativeViewFromIdInBrowser(NativeViewId id) { #if defined(OS_WIN) typedef HWND PluginWindowHandle; const PluginWindowHandle kNullPluginWindow = NULL; -#elif defined(USE_WAYLAND) - typedef struct wl_egl_window* PluginWindowHandle; - const PluginWindowHandle kNullPluginWindow = NULL; #elif defined(USE_X11) typedef unsigned long PluginWindowHandle; const PluginWindowHandle kNullPluginWindow = 0; @@ -295,9 +269,6 @@ struct GLSurfaceHandle { #if defined(OS_WIN) typedef HWND AcceleratedWidget; const AcceleratedWidget kNullAcceleratedWidget = NULL; -#elif defined(USE_WAYLAND) -typedef struct wl_egl_window* AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = NULL; #elif defined(USE_X11) typedef unsigned long AcceleratedWidget; const AcceleratedWidget kNullAcceleratedWidget = 0; diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc index b051729..e835602 100644 --- a/ui/gfx/pango_util.cc +++ b/ui/gfx/pango_util.cc @@ -20,7 +20,7 @@ #include "ui/gfx/platform_font_pango.h" #include "ui/gfx/rect.h" -#if !defined(USE_WAYLAND) && defined(TOOLKIT_GTK) +#if defined(TOOLKIT_GTK) #include <gdk/gdk.h> #include <gtk/gtk.h> #include "ui/gfx/gtk_util.h" @@ -179,7 +179,7 @@ float GetPixelsInPoint() { namespace gfx { PangoContext* GetPangoContext() { -#if defined(USE_WAYLAND) || defined(USE_AURA) +#if defined(USE_AURA) PangoFontMap* font_map = pango_cairo_font_map_get_default(); return pango_font_map_create_context(font_map); #else diff --git a/ui/gfx/platform_font_pango.cc b/ui/gfx/platform_font_pango.cc index b09819e..fe4d4e68 100644 --- a/ui/gfx/platform_font_pango.cc +++ b/ui/gfx/platform_font_pango.cc @@ -22,7 +22,7 @@ #include "ui/gfx/font.h" #include "ui/gfx/pango_util.h" -#if !defined(USE_WAYLAND) && defined(TOOLKIT_GTK) +#if defined(TOOLKIT_GTK) #include <gdk/gdk.h> #include <gtk/gtk.h> #endif @@ -63,7 +63,7 @@ std::string FindBestMatchFontFamilyName( // Returns a Pango font description (suitable for parsing by // pango_font_description_from_string()) for the default UI font. std::string GetDefaultFont() { -#if defined(USE_WAYLAND) || !defined(TOOLKIT_GTK) +#if !defined(TOOLKIT_GTK) #if defined(OS_CHROMEOS) return l10n_util::GetStringUTF8(IDS_UI_FONT_FAMILY_CROS); #else @@ -82,7 +82,7 @@ std::string GetDefaultFont() { std::string default_font = std::string(font_name); g_free(font_name); return default_font; -#endif // defined(USE_WAYLAND) || !defined(TOOLKIT_GTK) +#endif // !defined(TOOLKIT_GTK) } } // namespace diff --git a/ui/gfx/rect.cc b/ui/gfx/rect.cc index f05dc09..7a3f347 100644 --- a/ui/gfx/rect.cc +++ b/ui/gfx/rect.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,9 +11,6 @@ #elif defined(TOOLKIT_GTK) #include <gdk/gdk.h> #endif -#if defined(USE_WAYLAND) -#include <cairo.h> -#endif #include "base/logging.h" #include "base/stringprintf.h" @@ -94,20 +91,6 @@ Rect& Rect::operator=(const GdkRectangle& r) { return *this; } #endif -#if defined(USE_WAYLAND) -Rect::Rect(const cairo_rectangle_int_t& r) - : origin_(r.x, r.y) { - set_width(r.width); - set_height(r.height); -} - -Rect& Rect::operator=(const cairo_rectangle_int_t& r) { - origin_.SetPoint(r.x, r.y); - set_width(r.width); - set_height(r.height); - return *this; -} -#endif void Rect::SetRect(int x, int y, int width, int height) { origin_.SetPoint(x, y); @@ -164,12 +147,6 @@ GdkRectangle Rect::ToGdkRectangle() const { return r; } #endif -#if defined(USE_WAYLAND) -cairo_rectangle_int_t Rect::ToCairoRectangle() const { - cairo_rectangle_int_t r = {x(), y(), width(), height()}; - return r; -} -#endif bool Rect::Contains(int point_x, int point_y) const { return (point_x >= x()) && (point_x < right()) && diff --git a/ui/gfx/rect.h b/ui/gfx/rect.h index 1136471..4343825 100644 --- a/ui/gfx/rect.h +++ b/ui/gfx/rect.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -24,10 +24,6 @@ typedef struct tagRECT RECT; typedef struct _GdkRectangle GdkRectangle; #endif -#if defined(USE_WAYLAND) -typedef struct _cairo_rectangle_int cairo_rectangle_int_t; -#endif - namespace gfx { class Insets; @@ -44,9 +40,6 @@ class UI_EXPORT Rect { #elif defined(TOOLKIT_GTK) explicit Rect(const GdkRectangle& r); #endif -#if defined(USE_WAYLAND) - explicit Rect(const cairo_rectangle_int_t& r); -#endif explicit Rect(const gfx::Size& size); Rect(const gfx::Point& origin, const gfx::Size& size); @@ -59,9 +52,6 @@ class UI_EXPORT Rect { #elif defined(TOOLKIT_GTK) Rect& operator=(const GdkRectangle& r); #endif -#if defined(USE_WAYLAND) - Rect& operator=(const cairo_rectangle_int_t& r); -#endif int x() const { return origin_.x(); } void set_x(int x) { origin_.set_x(x); } @@ -129,9 +119,6 @@ class UI_EXPORT Rect { // Construct an equivalent CoreGraphics object. CGRect ToCGRect() const; #endif -#if defined(USE_WAYLAND) - cairo_rectangle_int_t ToCairoRectangle() const; -#endif // Returns true if the point identified by point_x and point_y falls inside // this rectangle. The point (x, y) is inside the rectangle, but the diff --git a/ui/gfx/screen_wayland.cc b/ui/gfx/screen_wayland.cc deleted file mode 100644 index 037cc89..0000000 --- a/ui/gfx/screen_wayland.cc +++ /dev/null @@ -1,57 +0,0 @@ -// 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 "ui/gfx/screen.h" - -#include "base/logging.h" -#include "ui/gfx/gl/gl_surface_egl.h" -#include "ui/wayland/wayland_display.h" -#include "ui/wayland/wayland_screen.h" - -namespace gfx { - -// static -gfx::Point Screen::GetCursorScreenPoint() { - NOTIMPLEMENTED(); - return gfx::Point(); -} - -gfx::Rect static GetPrimaryMonitorBounds() { - ui::WaylandDisplay* display = ui::WaylandDisplay::GetDisplay( - gfx::GLSurfaceEGL::GetNativeDisplay()); - std::list<ui::WaylandScreen*> screens = display->GetScreenList(); - - return screens.empty() ? gfx::Rect() : screens.front()->GetAllocation(); -} - -// static -gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeView view) { - // TODO(dnicoara): use |view|. - return GetPrimaryMonitorBounds(); -} - -// static -gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) { - NOTIMPLEMENTED(); - return gfx::Rect(); -} - -// static -gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { - return GetMonitorAreaNearestPoint(point); -} - -// static -gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { - NOTIMPLEMENTED(); - return gfx::Rect(); -} - -gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { - NOTIMPLEMENTED(); - return NULL; -} - -} // namespace gfx - diff --git a/ui/gfx/surface/accelerated_surface_wayland.cc b/ui/gfx/surface/accelerated_surface_wayland.cc deleted file mode 100644 index a83fb78..0000000 --- a/ui/gfx/surface/accelerated_surface_wayland.cc +++ /dev/null @@ -1,48 +0,0 @@ -// 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 "ui/gfx/surface/accelerated_surface_wayland.h" - -#include <wayland-egl.h> - -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" -#include "ui/gfx/gl/gl_bindings.h" -#include "ui/gfx/gl/gl_surface_egl.h" -#include "ui/wayland/wayland_display.h" - -AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) - : size_(size), - image_(NULL), - pixmap_(NULL), - texture_(0) { - EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); - - pixmap_ = wl_egl_pixmap_create(size_.width(), - size_.height(), - 0); - - image_ = eglCreateImageKHR( - edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (void*) pixmap_, NULL); - - glGenTextures(1, &texture_); - - GLint current_texture = 0; - glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); - - glBindTexture(GL_TEXTURE_2D, texture_); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); - - glBindTexture(GL_TEXTURE_2D, current_texture); -} - -AcceleratedSurface::~AcceleratedSurface() { - glDeleteTextures(1, &texture_); - eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); - wl_egl_pixmap_destroy(pixmap_); -} diff --git a/ui/gfx/surface/accelerated_surface_wayland.h b/ui/gfx/surface/accelerated_surface_wayland.h deleted file mode 100644 index 3deda3c..0000000 --- a/ui/gfx/surface/accelerated_surface_wayland.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -#ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_ -#define UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_ -#pragma once - -#include "base/memory/ref_counted.h" -#include "ui/gfx/size.h" -#include "ui/gfx/surface/surface_export.h" - -struct wl_egl_pixmap; - -// The GL context associated with the surface must be current when -// an instance is created or destroyed. -class SURFACE_EXPORT AcceleratedSurface - : public base::RefCounted<AcceleratedSurface> { - public: - AcceleratedSurface(const gfx::Size& size); - const gfx::Size& size() const { return size_; } - // The pointer returned is owned by this object - wl_egl_pixmap* pixmap() const { return pixmap_; } - uint32 texture() const { return texture_; } - - private: - friend class base::RefCounted<AcceleratedSurface>; - - ~AcceleratedSurface(); - - gfx::Size size_; - void* image_; - wl_egl_pixmap* pixmap_; - uint32 texture_; - - DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); -}; - -#endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_ diff --git a/ui/gfx/surface/surface.gyp b/ui/gfx/surface/surface.gyp index 02ab651..e11c492 100644 --- a/ui/gfx/surface/surface.gyp +++ b/ui/gfx/surface/surface.gyp @@ -30,8 +30,6 @@ 'sources': [ 'accelerated_surface_mac.cc', 'accelerated_surface_mac.h', - 'accelerated_surface_wayland.cc', - 'accelerated_surface_wayland.h', 'accelerated_surface_win.cc', 'accelerated_surface_win.h', 'io_surface_support_mac.cc', @@ -244,7 +244,6 @@ 'base/ui_export.h', 'base/view_prop.cc', 'base/view_prop.h', - 'base/wayland/events_wayland.cc', 'base/win/atl_module.h', 'base/win/events_win.cc', 'base/win/foreground_helper.cc', @@ -363,7 +362,6 @@ 'gfx/screen_ash.cc', 'gfx/screen_gtk.cc', 'gfx/screen_mac.mm', - 'gfx/screen_wayland.cc', 'gfx/screen_win.cc', 'gfx/scoped_cg_context_save_gstate_mac.h', 'gfx/scoped_ns_graphics_context_save_gstate_mac.h', @@ -522,25 +520,6 @@ 'gfx/native_theme_gtk.h', ] }], - ['use_wayland == 1', { - 'sources/': [ - ['exclude', '_(gtk|x)\\.cc$'], - ['exclude', '/(gtk|x11)_[^/]*\\.cc$'], - ['include', 'base/dragdrop/gtk_dnd_util.cc'], - ['include', 'base/dragdrop/gtk_dnd_util.h'], - ['include', 'base/dragdrop/os_exchange_data_provider_gtk.cc'], - ['include', 'base/dragdrop/os_exchange_data_provider_gtk.h'], - ['include', 'base/keycodes/keyboard_code_conversion_x.cc'], - ['include', 'base/keycodes/keyboard_code_conversion_x.h'], - ['include', 'gfx/gtk_util.cc'], - ['include', 'gfx/gtk_util.h'], - ['include', 'gfx/path_gtk.cc'], - ['include', 'gfx/platform_font_pango.cc'], - ['include', 'gfx/platform_font_pango.h'], - ['include', 'gfx/linux_util.cc'], - ['include', 'gfx/linux_util.h'], - ], - }], ['OS=="win"', { 'sources': [ 'gfx/gdi_util.cc', diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index c1bd2d6..a1438fb 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -913,14 +913,6 @@ bool MenuController::Dispatch(const MSG& msg) { DispatchMessage(&msg); return exit_type_ == EXIT_NONE; } -#elif defined(USE_WAYLAND) -base::MessagePumpDispatcher::DispatchStatus - MenuController::Dispatch(base::wayland::WaylandEvent* ev) { - return exit_type_ != EXIT_NONE ? - base::MessagePumpDispatcher::EVENT_QUIT : - base::MessagePumpDispatcher::EVENT_PROCESSED; -} - #elif defined(USE_AURA) base::MessagePumpDispatcher::DispatchStatus MenuController::Dispatch(XEvent* xev) { diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h index 9588186..f8bb62e 100644 --- a/ui/views/controls/menu/menu_controller.h +++ b/ui/views/controls/menu/menu_controller.h @@ -242,9 +242,6 @@ class VIEWS_EXPORT MenuController : public MessageLoop::Dispatcher { // Dispatcher method. This returns true if the menu was canceled, or // if the message is such that the menu should be closed. virtual bool Dispatch(const MSG& msg) OVERRIDE; -#elif defined(USE_WAYLAND) - virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( - base::wayland::WaylandEvent* event) OVERRIDE; #elif defined(USE_AURA) virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( XEvent* xevent) OVERRIDE; diff --git a/ui/views/controls/scrollbar/native_scroll_bar_views.cc b/ui/views/controls/scrollbar/native_scroll_bar_views.cc index 40e0e45..7eb2a08 100644 --- a/ui/views/controls/scrollbar/native_scroll_bar_views.cc +++ b/ui/views/controls/scrollbar/native_scroll_bar_views.cc @@ -374,7 +374,7 @@ gfx::Rect NativeScrollBarViews::GetTrackBounds() const { return bounds; } -#if defined(USE_WAYLAND) || defined(USE_AURA) +#if defined(USE_AURA) //////////////////////////////////////////////////////////////////////////////// // NativewScrollBarWrapper, public: diff --git a/ui/views/controls/textfield/native_textfield_wayland.cc b/ui/views/controls/textfield/native_textfield_wayland.cc deleted file mode 100644 index 63d02c7..0000000 --- a/ui/views/controls/textfield/native_textfield_wayland.cc +++ /dev/null @@ -1,20 +0,0 @@ -// 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 "base/logging.h" -#include "ui/views/controls/textfield/native_textfield_views.h" -#include "ui/views/controls/textfield/textfield.h" - -namespace views { - -/////////////////////////////////////////////////////////////////////////////// -// NativeTextfieldWrapper: - -// static -NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( - Textfield* field) { - return new NativeTextfieldViews(field); -} - -} // namespace views diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h index 7897294..7f5cab1 100644 --- a/ui/views/focus/accelerator_handler.h +++ b/ui/views/focus/accelerator_handler.h @@ -17,11 +17,11 @@ namespace views { -#if defined(USE_AURA) && defined(USE_X11) && !defined(USE_WAYLAND) +#if defined(USE_AURA) && defined(USE_X11) // Dispatch an XEvent to the RootView. Return true if the event was dispatched // and handled, false otherwise. bool VIEWS_EXPORT DispatchXEvent(XEvent* xevent); -#endif // USE_AURA && USE_X11 && !USE_WAYLAND +#endif // USE_AURA && USE_X11 // This class delegates the key messages to the associated FocusManager class // for the window that is receiving these messages for accelerator processing. @@ -37,9 +37,6 @@ class VIEWS_EXPORT AcceleratorHandler : public MessageLoop::Dispatcher { // focus manager #if defined(OS_WIN) virtual bool Dispatch(const MSG& msg) OVERRIDE; -#elif defined(USE_WAYLAND) - virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( - base::wayland::WaylandEvent* ev) OVERRIDE; #elif defined(OS_MACOSX) // TODO(dhollowa): Implement on Mac. http://crbug.com/109946 #elif defined(USE_AURA) diff --git a/ui/views/focus/accelerator_handler_wayland.cc b/ui/views/focus/accelerator_handler_wayland.cc deleted file mode 100644 index 167ae68..0000000 --- a/ui/views/focus/accelerator_handler_wayland.cc +++ /dev/null @@ -1,18 +0,0 @@ -// 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 "ui/views/focus/accelerator_handler.h" - -#include "ui/views/focus/focus_manager.h" - -namespace views { - -AcceleratorHandler::AcceleratorHandler() {} - -base::MessagePumpDispatcher::DispatchStatus - AcceleratorHandler::Dispatch(base::wayland::WaylandEvent* ev) { - return base::MessagePumpDispatcher::EVENT_IGNORED; -} - -} // namespace views diff --git a/ui/views/mouse_watcher.cc b/ui/views/mouse_watcher.cc index 8139bf34..0ade766 100644 --- a/ui/views/mouse_watcher.cc +++ b/ui/views/mouse_watcher.cc @@ -59,22 +59,6 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer { break; } } -#elif defined(USE_WAYLAND) - virtual MessageLoopForUI::Observer::EventStatus WillProcessEvent( - base::wayland::WaylandEvent* event) OVERRIDE { - switch (event->type) { - case base::wayland::WAYLAND_MOTION: - HandleGlobalMouseMoveEvent(MouseWatcherHost::MOUSE_MOVE); - break; - case base::wayland::WAYLAND_POINTER_FOCUS: - if (!event->pointer_focus.state) - HandleGlobalMouseMoveEvent(MouseWatcherHost::MOUSE_EXIT); - break; - default: - break; - } - return EVENT_CONTINUE; - } #elif defined(USE_AURA) virtual base::EventStatus WillProcessEvent( const base::NativeEvent& event) OVERRIDE { diff --git a/ui/wayland/wayland.gyp b/ui/wayland/wayland.gyp deleted file mode 100644 index 3953e2c..0000000 --- a/ui/wayland/wayland.gyp +++ /dev/null @@ -1,41 +0,0 @@ -# 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. - -{ - 'targets': [ - { - 'target_name': 'wayland', - 'type': 'static_library', - 'dependencies': [ - '../../base/base.gyp:base', - '../../build/linux/system.gyp:wayland', - '../ui.gyp:ui', - ], - 'include_dirs': [ - '.', - '../..', - 'events', - ], - 'sources': [ - 'wayland_buffer.cc', - 'wayland_buffer.h', - 'wayland_cursor.cc', - 'wayland_cursor.h', - 'wayland_display.cc', - 'wayland_display.h', - 'wayland_input_device.cc', - 'wayland_input_device.h', - 'wayland_message_pump.cc', - 'wayland_message_pump.h', - 'wayland_screen.cc', - 'wayland_screen.h', - 'wayland_shm_buffer.cc', - 'wayland_shm_buffer.h', - 'wayland_widget.h', - 'wayland_window.cc', - 'wayland_window.h', - ], - } - ], -} diff --git a/ui/wayland/wayland_buffer.cc b/ui/wayland/wayland_buffer.cc deleted file mode 100644 index 4fed8a18..0000000 --- a/ui/wayland/wayland_buffer.cc +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "ui/wayland/wayland_buffer.h" - -namespace ui { - -WaylandBuffer::WaylandBuffer() { -} - -WaylandBuffer::~WaylandBuffer() { -} - -} // namespace ui diff --git a/ui/wayland/wayland_buffer.h b/ui/wayland/wayland_buffer.h deleted file mode 100644 index a5b84c5..0000000 --- a/ui/wayland/wayland_buffer.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_BUFFER_H_ -#define UI_WAYLAND_WAYLAND_BUFFER_H_ - -#include "base/basictypes.h" - -struct wl_buffer; - -namespace ui { - -// Wrapper around a wl_buffer. A wl_buffer is associated with a drawing -// surface. -// -// This class is a basic interface of what a buffer should be/provide. -// Implementations whould create and destroy the wl_buffer. -class WaylandBuffer { - public: - WaylandBuffer(); - virtual ~WaylandBuffer(); - - wl_buffer* buffer() const { return buffer_; } - - protected: - // Owned by this object and should be destroyed by this object. - wl_buffer* buffer_; - - private: - DISALLOW_COPY_AND_ASSIGN(WaylandBuffer); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_BUFFER_H_ diff --git a/ui/wayland/wayland_cursor.cc b/ui/wayland/wayland_cursor.cc deleted file mode 100644 index 54d915d..0000000 --- a/ui/wayland/wayland_cursor.cc +++ /dev/null @@ -1,76 +0,0 @@ -// 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 "ui/wayland/wayland_cursor.h" - -#include <cairo.h> - -#include "base/logging.h" -#include "ui/wayland/wayland_display.h" -#include "ui/wayland/wayland_shm_buffer.h" - -namespace { - -struct PointerImage { - const char* filename; - int hotspot_x, hotspot_y; -}; - -// TODO(dnicoara) Add more pointer images and fix the path. -const PointerImage kPointerImages[] = { - {"left_ptr.png", 10, 5}, - {"hand.png", 10, 5}, -}; - -} // namespace - -namespace ui { - -WaylandCursor::WaylandCursor(WaylandDisplay* display) - : display_(display), - buffer_(NULL) { -} - -WaylandCursor::~WaylandCursor() { - if (buffer_) { - delete buffer_; - buffer_ = NULL; - } -} - -void WaylandCursor::ChangeCursor(Type type) { - const PointerImage& ptr = kPointerImages[type]; - - cairo_surface_t* ptr_surface = cairo_image_surface_create_from_png( - ptr.filename); - - if (!ptr_surface) { - LOG(ERROR) << "Failed to create cursor surface"; - return; - } - - int width = cairo_image_surface_get_width(ptr_surface); - int height = cairo_image_surface_get_height(ptr_surface); - - if (buffer_) { - delete buffer_; - buffer_ = NULL; - } - - // TODO(dnicoara) There should be a simpler way to create a wl_buffer for - // a cairo surface. Meantime we just copy the contents of the cairo surface - // created from file to the cairo surface created using a shm file. - buffer_ = new WaylandShmBuffer(display_, width, height); - cairo_surface_t* shared_surface = buffer_->data_surface(); - - cairo_t* cr = cairo_create(shared_surface); - cairo_set_source_surface(cr, ptr_surface, 0, 0); - cairo_rectangle(cr, 0, 0, width, height); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_fill(cr); - - display_->SetCursor(buffer_, ptr.hotspot_x, ptr.hotspot_y); -} - -} // namespace ui diff --git a/ui/wayland/wayland_cursor.h b/ui/wayland/wayland_cursor.h deleted file mode 100644 index 748252b..0000000 --- a/ui/wayland/wayland_cursor.h +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_CURSOR_H_ -#define UI_WAYLAND_WAYLAND_CURSOR_H_ - -#include "base/basictypes.h" - -namespace ui { - -class WaylandDisplay; -class WaylandShmBuffer; - -// This class allows applications to change the currently displaying cursor. -class WaylandCursor { - public: - // Types of Wayland cursors supported - enum Type { - ARROW_CURSOR, - HAND_CURSOR, - }; - - explicit WaylandCursor(WaylandDisplay* display); - ~WaylandCursor(); - - // Used to change the current type to the type specified in 'type' - void ChangeCursor(Type type); - - private: - // Pointer to the current display. This is not owned by this class. - WaylandDisplay* display_; - // The currently set cursor image. - // This class should dispose of this on deletion. - WaylandShmBuffer* buffer_; - - DISALLOW_COPY_AND_ASSIGN(WaylandCursor); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_CURSOR_H_ diff --git a/ui/wayland/wayland_display.cc b/ui/wayland/wayland_display.cc deleted file mode 100644 index cf79de9..0000000 --- a/ui/wayland/wayland_display.cc +++ /dev/null @@ -1,132 +0,0 @@ -// 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 "ui/wayland/wayland_display.h" - -#include <string.h> -#include <wayland-client.h> - -#include "ui/wayland/wayland_buffer.h" -#include "ui/wayland/wayland_input_device.h" -#include "ui/wayland/wayland_screen.h" -#include "ui/wayland/wayland_window.h" - -namespace ui { - -// static -WaylandDisplay* WaylandDisplay::Connect(char* name) { - WaylandDisplay* display = new WaylandDisplay(name); - if (!display->display_) { - delete display; - return NULL; - } - - wl_display_set_user_data(display->display_, display); - // Register the display initialization handler and iterate over the initial - // connection events sent by the server. This is required since the display - // will send registration events needed to initialize everything else. This - // will create the compositor, etc.., which are required in creating - // a drawing context. - wl_display_add_global_listener(display->display_, - WaylandDisplay::DisplayHandleGlobal, - display); - wl_display_iterate(display->display_, WL_DISPLAY_READABLE); - - return display; -} - -// static -WaylandDisplay* WaylandDisplay::GetDisplay(wl_display* display) { - return static_cast<WaylandDisplay*>(wl_display_get_user_data(display)); -} - -WaylandDisplay::WaylandDisplay(char* name) : display_(NULL), - compositor_(NULL), - shell_(NULL), - shm_(NULL) { - display_ = wl_display_connect(name); -} - -WaylandDisplay::~WaylandDisplay() { - if (display_) - wl_display_destroy(display_); - if (compositor_) - wl_compositor_destroy(compositor_); - if (shell_) - wl_shell_destroy(shell_); - if (shm_) - wl_shm_destroy(shm_); - for (std::list<WaylandInputDevice*>::iterator i = input_list_.begin(); - i != input_list_.end(); ++i) { - delete *i; - } - for (std::list<WaylandScreen*>::iterator i = screen_list_.begin(); - i != screen_list_.end(); ++i) { - delete *i; - } -} - -wl_surface* WaylandDisplay::CreateSurface() { - return wl_compositor_create_surface(compositor_); -} - -void WaylandDisplay::SetCursor(WaylandBuffer* buffer, - int32_t x, int32_t y) { - // Currently there is no way of knowing which input device should have the - // buffer attached, so we just attach to every input device. - for (std::list<WaylandInputDevice*>::iterator i = input_list_.begin(); - i != input_list_.end(); ++i) { - (*i)->Attach(buffer->buffer(), x, y); - } -} - -std::list<WaylandScreen*> WaylandDisplay::GetScreenList() const { - return screen_list_; -} - -// static -void WaylandDisplay::DisplayHandleGlobal(wl_display* display, - uint32_t id, - const char* interface, - uint32_t version, - void* data) { - WaylandDisplay* disp = static_cast<WaylandDisplay*>(data); - - static const wl_shell_listener kShellListener = { - WaylandDisplay::ShellHandleConfigure, - }; - - if (strcmp(interface, "wl_compositor") == 0) { - disp->compositor_ = static_cast<wl_compositor*>( - wl_display_bind(display, id, &wl_compositor_interface)); - } else if (strcmp(interface, "wl_output") == 0) { - WaylandScreen* screen = new WaylandScreen(disp, id); - disp->screen_list_.push_back(screen); - } else if (strcmp(interface, "wl_input_device") == 0) { - WaylandInputDevice *input_device = new WaylandInputDevice(display, id); - disp->input_list_.push_back(input_device); - } else if (strcmp(interface, "wl_shell") == 0) { - disp->shell_ = static_cast<wl_shell*>( - wl_display_bind(display, id, &wl_shell_interface)); - wl_shell_add_listener(disp->shell_, &kShellListener, disp); - } else if (strcmp(interface, "wl_shm") == 0) { - disp->shm_ = static_cast<wl_shm*>( - wl_display_bind(display, id, &wl_shm_interface)); - } -} - -// static -void WaylandDisplay::ShellHandleConfigure(void* data, - wl_shell* shell, - uint32_t time, - uint32_t edges, - wl_surface* surface, - int32_t width, - int32_t height) { - WaylandWindow* window = static_cast<WaylandWindow*>( - wl_surface_get_user_data(surface)); - window->Configure(time, edges, 0, 0, width, height); -} - -} // namespace ui diff --git a/ui/wayland/wayland_display.h b/ui/wayland/wayland_display.h deleted file mode 100644 index f122e55..0000000 --- a/ui/wayland/wayland_display.h +++ /dev/null @@ -1,95 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_DISPLAY_H_ -#define UI_WAYLAND_WAYLAND_DISPLAY_H_ - -#include <stdint.h> - -#include <list> - -#include "base/basictypes.h" - -struct wl_compositor; -struct wl_display; -struct wl_shell; -struct wl_shm; -struct wl_surface; - -namespace ui { - -class WaylandBuffer; -class WaylandInputDevice; -class WaylandScreen; - -// WaylandDisplay is a wrapper around wl_display. Once we get a valid -// wl_display, the Wayland server will send different events to register -// the Wayland compositor, shell, screens, input devices, ... -class WaylandDisplay { - public: - // Attempt to create a connection to the display. If it fails this returns - // NULL - static WaylandDisplay* Connect(char* name); - - // Get the WaylandDisplay associated with the native Wayland display - static WaylandDisplay* GetDisplay(wl_display* display); - - ~WaylandDisplay(); - - // Creates a wayland surface. This is used to create a window surface. - // The returned pointer should be deleted by the caller. - wl_surface* CreateSurface(); - - // Sets the specified buffer as the surface for the cursor. (x, y) is - // the hotspot for the cursor. - void SetCursor(WaylandBuffer* buffer, int32_t x, int32_t y); - - // Returns a pointer to the wl_display. - wl_display* display() const { return display_; } - - // Returns a list of the registered screens. - std::list<WaylandScreen*> GetScreenList() const; - - wl_shell* shell() const { return shell_; } - - wl_shm* shm() const { return shm_; } - - private: - WaylandDisplay(char* name); - - // This handler resolves all server events used in initialization. It also - // handles input device registration, screen registration. - static void DisplayHandleGlobal(wl_display* display, - uint32_t id, - const char* interface, - uint32_t version, - void* data); - - // Used when the shell requires configuration. This is called when a - // window is configured and receives its size. - // TODO(dnicoara) Need to look if there is one shell per window. Then it - // makes more sense to move this into the WaylandWindow and it would keep - // track of the shell. - static void ShellHandleConfigure(void* data, - wl_shell* shell, - uint32_t time, - uint32_t edges, - wl_surface* surface, - int32_t width, - int32_t height); - - // WaylandDisplay manages the memory of all these pointers. - wl_display* display_; - wl_compositor* compositor_; - wl_shell* shell_; - wl_shm* shm_; - std::list<WaylandScreen*> screen_list_; - std::list<WaylandInputDevice*> input_list_; - - DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_DISPLAY_H_ diff --git a/ui/wayland/wayland_input_device.cc b/ui/wayland/wayland_input_device.cc deleted file mode 100644 index 034b4a1..0000000 --- a/ui/wayland/wayland_input_device.cc +++ /dev/null @@ -1,214 +0,0 @@ -// 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 "ui/wayland/wayland_input_device.h" - -#include <X11/extensions/XKBcommon.h> -#include <wayland-client.h> - -#include "base/wayland/wayland_event.h" -#include "ui/wayland/wayland_widget.h" -#include "ui/wayland/wayland_window.h" - -using namespace base::wayland; - -namespace ui { - -WaylandInputDevice::WaylandInputDevice( - wl_display* display, - uint32_t id) - : input_device_(static_cast<wl_input_device*>( - wl_display_bind(display, id, &wl_input_device_interface))), - pointer_focus_(NULL), - keyboard_focus_(NULL), - keyboard_modifiers_(0) { - - // List of callback functions for input device events. - static const struct wl_input_device_listener kInputDeviceListener = { - WaylandInputDevice::OnMotionNotify, - WaylandInputDevice::OnButtonNotify, - WaylandInputDevice::OnKeyNotify, - WaylandInputDevice::OnPointerFocus, - WaylandInputDevice::OnKeyboardFocus, - }; - - wl_input_device_add_listener(input_device_, &kInputDeviceListener, this); - wl_input_device_set_user_data(input_device_, this); - - struct xkb_rule_names names; - names.rules = "evdev"; - names.model = "pc105"; - names.layout = "us"; - names.variant = ""; - names.options = ""; - - xkb_ = xkb_compile_keymap_from_rules(&names); -} - -WaylandInputDevice::~WaylandInputDevice() { - if (input_device_) - wl_input_device_destroy(input_device_); -} - -void WaylandInputDevice::Attach(wl_buffer* buffer, int32_t x, int32_t y) { - wl_input_device_attach(input_device_, last_event_time_, buffer, x, y); -} - -void WaylandInputDevice::OnMotionNotify(void* data, - wl_input_device* input_device, - uint32_t time, - int32_t x, - int32_t y, - int32_t sx, - int32_t sy) { - WaylandInputDevice* device = static_cast<WaylandInputDevice*>(data); - WaylandWindow* window = device->pointer_focus_; - - device->last_event_time_ = time; - device->global_position_.SetPoint(x, y); - device->surface_position_.SetPoint(sx, sy); - - WaylandEvent event; - event.type = WAYLAND_MOTION; - event.motion.time = time; - event.motion.modifiers = device->keyboard_modifiers_; - event.motion.x = sx; - event.motion.y = sy; - - window->widget()->OnMotionNotify(event); -} - -void WaylandInputDevice::OnButtonNotify(void* data, - wl_input_device* input_device, - uint32_t time, - uint32_t button, - uint32_t state) { - WaylandInputDevice* device = static_cast<WaylandInputDevice*>(data); - WaylandWindow* window = device->pointer_focus_; - - device->last_event_time_ = time; - - WaylandEvent event; - event.type = WAYLAND_BUTTON; - event.button.time = time; - event.button.button = button; - event.button.state = state; - event.button.modifiers = device->keyboard_modifiers_; - event.button.x = device->surface_position_.x(); - event.button.y = device->surface_position_.y(); - - window->widget()->OnButtonNotify(event); -} - -void WaylandInputDevice::OnKeyNotify(void* data, - wl_input_device* input_device, - uint32_t time, - uint32_t key, - uint32_t state) { - WaylandInputDevice* device = static_cast<WaylandInputDevice*>(data); - WaylandWindow* window = device->keyboard_focus_; - struct xkb_desc *xkb = device->xkb_; - - device->last_event_time_ = time; - - WaylandEvent event; - event.type = WAYLAND_KEY; - event.key.time = time; - event.key.key = key; - event.key.state = state; - - uint32_t code = key + xkb->min_key_code; - uint32_t level = 0; - if ((device->keyboard_modifiers_ & XKB_COMMON_SHIFT_MASK) && - XkbKeyGroupWidth(xkb, code, 0) > 1) { - level = 1; - } - - event.key.sym = XkbKeySymEntry(xkb, code, level, 0); - if (state) - device->keyboard_modifiers_ |= xkb->map->modmap[code]; - else - device->keyboard_modifiers_ &= ~xkb->map->modmap[code]; - - event.key.modifiers = device->keyboard_modifiers_; - - window->widget()->OnKeyNotify(event); -} - -void WaylandInputDevice::OnPointerFocus(void* data, - wl_input_device* input_device, - uint32_t time, - wl_surface* surface, - int32_t x, - int32_t y, - int32_t sx, - int32_t sy) { - WaylandInputDevice* device = static_cast<WaylandInputDevice*>(data); - WaylandWindow* window = device->pointer_focus_; - - device->last_event_time_ = time; - - WaylandEvent event; - event.type = WAYLAND_POINTER_FOCUS; - event.pointer_focus.time = time; - event.pointer_focus.x = sx; - event.pointer_focus.y = sy; - - // If we have a window, then this means it loses focus - if (window) { - event.pointer_focus.state = 0; - device->pointer_focus_ = NULL; - window->widget()->OnPointerFocus(event); - } - - // If we have a surface, then a new window is in focus - if (surface) { - event.pointer_focus.state = 1; - window = static_cast<WaylandWindow*>(wl_surface_get_user_data(surface)); - device->pointer_focus_ = window; - window->widget()->OnPointerFocus(event); - } -} - -void WaylandInputDevice::OnKeyboardFocus(void* data, - wl_input_device* input_device, - uint32_t time, - wl_surface* surface, - wl_array* keys) { - WaylandInputDevice* device = static_cast<WaylandInputDevice*>(data); - WaylandWindow* window = device->keyboard_focus_; - struct xkb_desc* xkb = device->xkb_; - - device->last_event_time_ = time; - - WaylandEvent event; - event.type = WAYLAND_KEYBOARD_FOCUS; - event.keyboard_focus.time = time; - device->keyboard_modifiers_ = 0; - - uint32_t* codes = static_cast<uint32_t*>(keys->data); - int codes_size = keys->size / sizeof(uint32_t); - for (int i = 0; i < codes_size; i++) { - uint32_t code = codes[i] + xkb->min_key_code; - device->keyboard_modifiers_ |= xkb->map->modmap[code]; - } - event.keyboard_focus.modifiers = device->keyboard_modifiers_; - - // If there is a window, then it loses focus - if (window) { - event.keyboard_focus.state = 0; - device->keyboard_focus_ = NULL; - window->widget()->OnKeyboardFocus(event); - } - - // If we have a surface, then a window gains focus - if (surface) { - event.keyboard_focus.state = 1; - window = static_cast<WaylandWindow*>(wl_surface_get_user_data(surface)); - device->keyboard_focus_ = window; - window->widget()->OnKeyboardFocus(event); - } -} - -} // namespace ui diff --git a/ui/wayland/wayland_input_device.h b/ui/wayland/wayland_input_device.h deleted file mode 100644 index 39c4f26..0000000 --- a/ui/wayland/wayland_input_device.h +++ /dev/null @@ -1,122 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_INPUT_DEVICE_H_ -#define UI_WAYLAND_WAYLAND_INPUT_DEVICE_H_ - -#include <stdint.h> - -#include "base/basictypes.h" -#include "ui/gfx/point.h" -#include "ui/wayland/wayland_widget.h" - -struct xkb_desc; -struct wl_array; -struct wl_buffer; -struct wl_display; -struct wl_input_device; -struct wl_surface; - -namespace ui { - -class WaylandWindow; - -// This class represents an input device that was registered with Wayland. -// The purpose of this class is to parse and wrap events into generic -// WaylandEvent types and dispatch the event to the appropriate WaylandWindow. -// -// How Wayland events work: -// ------------------------ -// -// When the On*Focus events are triggered, the input device receives a -// reference to the surface that just received/lost focus. Each surface is -// associated with a unique WaylandWindow. When processing the focus events we -// keep track of the currently focused window such that when we receive -// different events (mouse button press or key press) we only send the event to -// the window in focus. -class WaylandInputDevice { - public: - WaylandInputDevice(wl_display* display, uint32_t id); - ~WaylandInputDevice(); - - // Used to change the surface of the input device (normally pointer image). - void Attach(wl_buffer* buffer, int32_t x, int32_t y); - - private: - // Input device callback functions. These will create 'WaylandEvent's and - // send them to the currently focused window. - // Args: - // - data: Pointer to the WaylandInputDevice object associated with the - // 'input_device' - // - input_device: - // The input device that sent the event - // - time: The time of the event. - static void OnMotionNotify(void* data, - wl_input_device* input_device, - uint32_t time, - int32_t x, - int32_t y, - int32_t sx, - int32_t sy); - - static void OnButtonNotify(void* data, - wl_input_device* input_device, - uint32_t time, - uint32_t button, - uint32_t state); - - static void OnKeyNotify(void* data, - wl_input_device* input_device, - uint32_t time, - uint32_t key, - uint32_t state); - - // On*Focus events also have a Wayland surface associated with them. If the - // surface is NULL, then the event signifies a loss of focus. Otherwise we - // use the surface to get the WaylandWindow that receives focus. - static void OnPointerFocus(void* data, - wl_input_device* input_device, - uint32_t time, - wl_surface* surface, - int32_t x, - int32_t y, - int32_t sx, - int32_t sy); - - static void OnKeyboardFocus(void* data, - wl_input_device* input_device, - uint32_t time, - wl_surface* surface, - wl_array* keys); - - wl_input_device* input_device_; - - // These keep track of the window that's currently under focus. NULL if no - // window is under focus. - WaylandWindow* pointer_focus_; - WaylandWindow* keyboard_focus_; - - // Keeps track of the currently active keyboard modifiers. We keep this - // since we want to advertise keyboard modifiers with mouse events. - uint32_t keyboard_modifiers_; - - // Keeps track of the last position for the motion event. We want to - // publish this with events such as button notify which doesn't have a - // position associated by default. - gfx::Point global_position_; - gfx::Point surface_position_; - - // Keep track of the time of last event. Useful when we get buffer Attach - // calls and the calls wouldn't have a way of getting an event time. - uint32_t last_event_time_; - - // keymap used to transform keyboard events. - xkb_desc* xkb_; - - DISALLOW_COPY_AND_ASSIGN(WaylandInputDevice); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_INPUT_DEVICE_H_ diff --git a/ui/wayland/wayland_message_pump.cc b/ui/wayland/wayland_message_pump.cc deleted file mode 100644 index 9e7e671..0000000 --- a/ui/wayland/wayland_message_pump.cc +++ /dev/null @@ -1,78 +0,0 @@ -// 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 "ui/wayland/wayland_message_pump.h" - -#include <wayland-client.h> - -#include "ui/wayland/wayland_display.h" - -namespace ui { - -WaylandMessagePump::WaylandMessagePump(WaylandDisplay* display) - : display_(display) { - static GSourceFuncs kSourceHandlers = { - WaylandMessagePump::SourcePrepare, - WaylandMessagePump::SourceCheck, - WaylandMessagePump::SourceDispatch, - NULL - }; - - source_ = static_cast<WorkSource*>( - g_source_new(&kSourceHandlers, sizeof(WorkSource))); - source_->pump = this; - pfd_.fd = wl_display_get_fd(display_->display(), - WaylandMessagePump::SourceUpdate, - source_); - pfd_.events = G_IO_IN | G_IO_ERR; - g_source_add_poll(source_, &pfd_); - g_source_attach(source_, NULL); -} - -WaylandMessagePump::~WaylandMessagePump() { - g_source_destroy(source_); - g_source_unref(source_); -} - -int WaylandMessagePump::HandlePrepare() { - while (mask_ & WL_DISPLAY_WRITABLE) - wl_display_iterate(display_->display(), WL_DISPLAY_WRITABLE); - - return -1; -} - -bool WaylandMessagePump::HandleCheck() { - return pfd_.revents; -} - -void WaylandMessagePump::HandleDispatch() { - wl_display_iterate(display_->display(), WL_DISPLAY_READABLE); -} - -// static -gboolean WaylandMessagePump::SourcePrepare(GSource* source, gint* timeout) { - *timeout = static_cast<WorkSource*>(source)->pump->HandlePrepare(); - return FALSE; -} - -// static -gboolean WaylandMessagePump::SourceCheck(GSource* source) { - return static_cast<WorkSource*>(source)->pump->HandleCheck(); -} - -// static -gboolean WaylandMessagePump::SourceDispatch(GSource* source, - GSourceFunc callback, - gpointer data) { - static_cast<WorkSource*>(source)->pump->HandleDispatch(); - return TRUE; -} - -// static -int WaylandMessagePump::SourceUpdate(uint32_t mask, void* data) { - static_cast<WorkSource*>(data)->pump->mask_ = mask; - return 0; -} - -} // namespace ui diff --git a/ui/wayland/wayland_message_pump.h b/ui/wayland/wayland_message_pump.h deleted file mode 100644 index 8ae7a91..0000000 --- a/ui/wayland/wayland_message_pump.h +++ /dev/null @@ -1,63 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_MESSAGE_PUMP_H_ -#define UI_WAYLAND_WAYLAND_MESSAGE_PUMP_H_ - -#include <glib.h> -#include <stdint.h> - -#include "base/basictypes.h" - -namespace ui { - -class WaylandDisplay; - -// The message pump handles Wayland specific event delivery. This message -// pump uses the default glib context, so running a glib main loop with the -// default context will allow looping through Wayland events. -class WaylandMessagePump { - public: - explicit WaylandMessagePump(WaylandDisplay* display); - virtual ~WaylandMessagePump(); - - protected: - // These are used to process the pump callbacks. - // HandlePrepare: is called during glib's prepare step and returns a timeout - // that will be passed to the poll. - // HandleCheck: called after HandlePrepare and returns whether - // HandleDispatch should be called. - // HandleDispatch:is called after HandleCheck returns true and it will - // dispatch a Wayland event. - virtual int HandlePrepare(); - virtual bool HandleCheck(); - virtual void HandleDispatch(); - - private: - struct WorkSource : public GSource { - WaylandMessagePump* pump; - }; - - // Actual callbacks for glib. These functions will just call the appropriate - // Handle* functions in a WaylandMessagePump object. - static gboolean SourcePrepare(GSource* source, gint* timeout); - static gboolean SourceCheck(GSource* source); - static gboolean SourceDispatch(GSource* source, - GSourceFunc callback, - gpointer data); - // Handles updates to the Wayland mask. This is used to signal when the - // compositor is done processing writable events. - static int SourceUpdate(uint32_t mask, void* data); - - WaylandDisplay* display_; - WorkSource* source_; - GPollFD pfd_; - uint32_t mask_; - - DISALLOW_COPY_AND_ASSIGN(WaylandMessagePump); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_MESSAGE_PUMP_H_ diff --git a/ui/wayland/wayland_screen.cc b/ui/wayland/wayland_screen.cc deleted file mode 100644 index c29bc56..0000000 --- a/ui/wayland/wayland_screen.cc +++ /dev/null @@ -1,79 +0,0 @@ -// 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 "ui/wayland/wayland_screen.h" - -#include <wayland-client.h> - -#include "ui/wayland/wayland_display.h" - -namespace ui { - -WaylandScreen::WaylandScreen(WaylandDisplay* display, uint32_t id) - : output_(NULL), - display_(display) { - static const wl_output_listener kOutputListener = { - WaylandScreen::OutputHandleGeometry, - WaylandScreen::OutputHandleMode, - }; - - output_ = static_cast<wl_output*>( - wl_display_bind(display_->display(), id, &wl_output_interface)); - wl_output_add_listener(output_, &kOutputListener, this); -} - -WaylandScreen::~WaylandScreen() { - if (output_) - wl_output_destroy(output_); -} - -gfx::Rect WaylandScreen::GetAllocation() const { - gfx::Rect allocation; - allocation.set_origin(position_); - - // Find the active mode and pass its dimensions. - for (Modes::const_iterator i = modes_.begin(); i != modes_.end(); ++i) { - if ((*i).flags & WL_OUTPUT_MODE_CURRENT) { - allocation.set_width((*i).width); - allocation.set_height((*i).height); - break; - } - } - - return allocation; -} - -// static -void WaylandScreen::OutputHandleGeometry(void* data, - wl_output* output, - int32_t x, - int32_t y, - int32_t physical_width, - int32_t physical_height, - int32_t subpixel, - const char* make, - const char* model) { - WaylandScreen* screen = static_cast<WaylandScreen*>(data); - screen->position_.SetPoint(x, y); -} - -// static -void WaylandScreen::OutputHandleMode(void* data, - wl_output* wl_output, - uint32_t flags, - int32_t width, - int32_t height, - int32_t refresh) { - WaylandScreen* screen = static_cast<WaylandScreen*>(data); - - Mode mode; - mode.width = width; - mode.height = height; - mode.refresh = refresh; - mode.flags = flags; - - screen->modes_.push_back(mode); -} - -} // namespace ui diff --git a/ui/wayland/wayland_screen.h b/ui/wayland/wayland_screen.h deleted file mode 100644 index 828762f..0000000 --- a/ui/wayland/wayland_screen.h +++ /dev/null @@ -1,79 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_SCREEN_H_ -#define UI_WAYLAND_WAYLAND_SCREEN_H_ - -#include <stdint.h> - -#include <list> - -#include "base/basictypes.h" -#include "ui/gfx/point.h" -#include "ui/gfx/rect.h" - -struct wl_output; - -namespace ui { - -class WaylandDisplay; - -// WaylandScreen objects keep track of the current outputs (screens/monitors) -// that are available to the application. -class WaylandScreen { - public: - WaylandScreen(WaylandDisplay* display, uint32_t id); - ~WaylandScreen(); - - // Returns the active allocation of the screen. - gfx::Rect GetAllocation() const; - - private: - // Used to store information regarding the available modes for the current - // screen. - // - (width, height): is the resolution of the screen - // - refresh: is the refresh rate of the screen under this mode - // - flags: contains extra information regarding the mode. The most important - // is the active mode flag. - struct Mode { - int32_t width, height, refresh, flags; - }; - typedef std::list<Mode> Modes; - - // Callback functions that allows the display to initialize the screen's - // position and available modes. - static void OutputHandleGeometry(void* data, - wl_output* output, - int32_t x, - int32_t y, - int32_t physical_width, - int32_t physical_height, - int32_t subpixel, - const char* make, - const char* model); - - static void OutputHandleMode(void* data, - wl_output* wl_output, - uint32_t flags, - int32_t width, - int32_t height, - int32_t refresh); - - // The Wayland output this object wraps - wl_output* output_; - // The display that the output is associated with - WaylandDisplay* display_; - // The position of the screen. This is important in multi monitor display - // since it provides the position of the screen in the virtual screen. - gfx::Point position_; - - // List of supported modes - Modes modes_; - - DISALLOW_COPY_AND_ASSIGN(WaylandScreen); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_SCREEN_H_ diff --git a/ui/wayland/wayland_shm_buffer.cc b/ui/wayland/wayland_shm_buffer.cc deleted file mode 100644 index 7406847..0000000 --- a/ui/wayland/wayland_shm_buffer.cc +++ /dev/null @@ -1,66 +0,0 @@ -// 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 "ui/wayland/wayland_shm_buffer.h" - -#include <cairo.h> -#include <fcntl.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <unistd.h> -#include <wayland-client.h> - -#include "base/logging.h" -#include "ui/wayland/wayland_display.h" - -namespace ui { - -WaylandShmBuffer::WaylandShmBuffer(WaylandDisplay* display, - uint32_t width, - uint32_t height) - : data_surface_(NULL) { - int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); - int allocation = stride * height; - - char filename[] = "/tmp/wayland-shm-XXXXXX"; - int fd = mkstemp(filename); - if (fd < 0) { - PLOG(ERROR) << "Failed to open"; - return; - } - if (ftruncate(fd, allocation) < 0) { - PLOG(ERROR) << "Failed to ftruncate"; - close(fd); - return; - } - - unsigned char* data = static_cast<unsigned char*>( - mmap(NULL, allocation, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); - unlink(filename); - - if (data == MAP_FAILED) { - PLOG(ERROR) << "Failed to mmap /dev/zero"; - close(fd); - return; - } - data_surface_ = cairo_image_surface_create_for_data( - data, CAIRO_FORMAT_ARGB32, width, height, stride); - buffer_ = wl_shm_create_buffer(display->shm(), fd, - width, height, stride, - WL_SHM_FORMAT_PREMULTIPLIED_ARGB32); - close(fd); -} - -WaylandShmBuffer::~WaylandShmBuffer() { - if (buffer_) { - wl_buffer_destroy(buffer_); - buffer_ = NULL; - } - if (data_surface_) { - cairo_surface_destroy(data_surface_); - data_surface_ = NULL; - } -} - -} // namespace ui diff --git a/ui/wayland/wayland_shm_buffer.h b/ui/wayland/wayland_shm_buffer.h deleted file mode 100644 index 7712be3..0000000 --- a/ui/wayland/wayland_shm_buffer.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_SHM_BUFFER_H_ -#define UI_WAYLAND_WAYLAND_SHM_BUFFER_H_ - -#include <stdint.h> - -#include "base/basictypes.h" -#include "ui/wayland/wayland_buffer.h" - -typedef struct _cairo_surface cairo_surface_t; - -namespace ui { - -class WaylandDisplay; - -// A SHM implementation for the WaylandBuffer. -class WaylandShmBuffer : public WaylandBuffer { - public: - // Creates a Wayland buffer with the given width and height. - WaylandShmBuffer(WaylandDisplay* display, uint32_t width, uint32_t height); - virtual ~WaylandShmBuffer(); - - // Returns a pointer to the surface associated with the buffer. - // This object maintains ownership of the surface. - cairo_surface_t* data_surface() const { return data_surface_; } - - private: - // The surface associated with the Wayland buffer. - cairo_surface_t* data_surface_; - - DISALLOW_COPY_AND_ASSIGN(WaylandShmBuffer); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_SHM_BUFFER_H_ diff --git a/ui/wayland/wayland_widget.h b/ui/wayland/wayland_widget.h deleted file mode 100644 index 1c4e40d..0000000 --- a/ui/wayland/wayland_widget.h +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_WIDGET_H_ -#define UI_WAYLAND_WAYLAND_WIDGET_H_ - -namespace base { -namespace wayland { -union WaylandEvent; -} -} - -namespace ui { - -// WaylandWidget is an interface for processing Wayland events. -class WaylandWidget { - public: - virtual ~WaylandWidget() {} - - virtual void OnMotionNotify(base::wayland::WaylandEvent event) = 0; - virtual void OnButtonNotify(base::wayland::WaylandEvent event) = 0; - virtual void OnKeyNotify(base::wayland::WaylandEvent event) = 0; - virtual void OnPointerFocus(base::wayland::WaylandEvent event) = 0; - virtual void OnKeyboardFocus(base::wayland::WaylandEvent event) = 0; - - virtual void OnGeometryChange(base::wayland::WaylandEvent event) = 0; -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_WIDGET_H_ diff --git a/ui/wayland/wayland_window.cc b/ui/wayland/wayland_window.cc deleted file mode 100644 index cd84a45..0000000 --- a/ui/wayland/wayland_window.cc +++ /dev/null @@ -1,86 +0,0 @@ -// 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 "ui/wayland/wayland_window.h" - -#include <wayland-egl.h> - -#include "base/wayland/wayland_event.h" -#include "ui/wayland/wayland_display.h" -#include "ui/wayland/wayland_widget.h" - -using base::wayland::WaylandEvent; - -namespace ui { - -WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display) - : widget_(widget), - display_(display), - parent_window_(NULL), - relative_position_(), - surface_(display->CreateSurface()), - fullscreen_(false) { - wl_surface_set_user_data(surface_, this); -} - -WaylandWindow::WaylandWindow( - WaylandWidget* widget, - WaylandDisplay* display, - WaylandWindow* parent, - int32_t x, - int32_t y) - : widget_(widget), - display_(display), - parent_window_(parent), - relative_position_(x, y), - surface_(display->CreateSurface()), - fullscreen_(false) { - wl_surface_set_user_data(surface_, this); -} - -WaylandWindow::~WaylandWindow() { - if (surface_) - wl_surface_destroy(surface_); -} - -void WaylandWindow::SetVisible(bool visible) { - if (visible) { - if (fullscreen_) { - wl_shell_set_fullscreen(display_->shell(), surface_); - } else if (!parent_window_) { - wl_shell_set_toplevel(display_->shell(), surface_); - } else { - wl_shell_set_transient(display_->shell(), - surface_, - parent_window_->surface(), - relative_position_.x(), - relative_position_.y(), - 0); - } - } else { - // TODO(dnicoara) What is the correct way of hiding a wl_surface? - } -} - -bool WaylandWindow::IsVisible() const { - return surface_ != NULL; -} - -void WaylandWindow::Configure(uint32_t time, - uint32_t edges, - int32_t x, - int32_t y, - int32_t width, - int32_t height) { - WaylandEvent event; - event.geometry_change.time = time; - event.geometry_change.x = x; - event.geometry_change.y = y; - event.geometry_change.width = width; - event.geometry_change.height = height; - - widget_->OnGeometryChange(event); -} - -} // namespace ui diff --git a/ui/wayland/wayland_window.h b/ui/wayland/wayland_window.h deleted file mode 100644 index b3a6074..0000000 --- a/ui/wayland/wayland_window.h +++ /dev/null @@ -1,87 +0,0 @@ -// 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. - -#ifndef UI_WAYLAND_WAYLAND_WINDOW_H_ -#define UI_WAYLAND_WAYLAND_WINDOW_H_ - -#include <stdint.h> - -#include "base/basictypes.h" -#include "ui/gfx/point.h" - -struct wl_surface; - -namespace ui { - -class WaylandDisplay; -class WaylandWidget; - -// WaylandWindow wraps a wl_surface and some basic operations for the surface. -// WaylandWindow also keeps track of the WaylandWidget that will process all -// events related to the window. -class WaylandWindow { - public: - // Creates a toplevel window. - WaylandWindow(WaylandWidget* widget, WaylandDisplay* display); - // Creates a transient window with an offset of (x,y) from parent. - WaylandWindow(WaylandWidget* widget, - WaylandDisplay* display, - WaylandWindow* parent, - int32_t x, - int32_t y); - - ~WaylandWindow(); - - void SetVisible(bool visible); - bool IsVisible() const; - - // Sets the window to fullscreen if |fullscreen| is true. Otherwise it sets - // it as a normal window. - void set_fullscreen(bool fullscreen) { fullscreen_ = fullscreen; } - bool fullscreen() const { return fullscreen_; } - - // Returns a pointer to the parent window. NULL is this window doesn't have - // a parent. - WaylandWindow* parent_window() const { return parent_window_; } - - WaylandWidget* widget() const { return widget_; } - - // Returns the pointer to the surface associated with the window. - // The WaylandWindow object owns the pointer. - wl_surface* surface() const { return surface_; } - - void Configure(uint32_t time, uint32_t edges, int32_t x, int32_t y, - int32_t width, int32_t height); - - private: - // The widget that will process events for this window. This is not owned - // by the window. - WaylandWidget* widget_; - - // Pointer to the display this window is using. This doesn't own the pointer - // to the display. - WaylandDisplay* display_; - - // When creating a transient window, |parent_window_| is set to point to the - // parent of this window. We will then use |parent_window_| to align this - // window at the specified offset in |relative_position_|. - // |parent_window_| is not owned by this window. - WaylandWindow* parent_window_; - - // Position relative to parent window. This is only used by - // a transient window. - gfx::Point relative_position_; - - // The native wayland surface associated with this window. - wl_surface* surface_; - - // Whether the window is in fullscreen mode. - bool fullscreen_; - - DISALLOW_COPY_AND_ASSIGN(WaylandWindow); -}; - -} // namespace ui - -#endif // UI_WAYLAND_WAYLAND_WINDOW_H_ |