Commit 3580aaf3 authored by ccameron@chromium.org's avatar ccameron@chromium.org

Make aura_demo work on Mac

Fix a few instances where !Windows is assumed to be Linux.

Chang many instances of !USE_GTK_MESSAGE_PUMP &&
!OS_MACOSX && !OS_ANDROID to just USE_AURA (they are
equivalent now).

Add a very minimal RootWindowHostMac.

Of note is that building with Aura requires running
"gyp_chromium --no-circular-check" (the circular
check is only enabled on Mac, and doesn't work with
Aura).

Also note that the demo does not work properly unless BGRA
support is disabled (in FeatureInfo::InitializeBasicState these
extensions can be disabled).

BUG=331669

Review URL: https://codereview.chromium.org/110283005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243392 0039d316-1c4b-4281-b951-d872f2087c98
parent 60e91436
......@@ -96,11 +96,11 @@ class WaitableEvent;
class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
public:
#if defined(USE_GTK_MESSAGE_PUMP)
typedef MessagePumpGdkObserver Observer;
#elif !defined(OS_MACOSX) && !defined(OS_ANDROID)
#if defined(USE_AURA)
typedef MessagePumpDispatcher Dispatcher;
typedef MessagePumpObserver Observer;
#elif defined(USE_GTK_MESSAGE_PUMP)
typedef MessagePumpGdkObserver Observer;
#endif
// A MessageLoop has a particular type, which indicates the set of
......
......@@ -17,14 +17,12 @@ RunLoop::RunLoop()
running_(false),
quit_when_idle_received_(false),
weak_factory_(this) {
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
#if defined(USE_AURA)
dispatcher_ = NULL;
#endif
}
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
#if defined(USE_AURA)
RunLoop::RunLoop(MessageLoop::Dispatcher* dispatcher)
: loop_(MessageLoop::current()),
previous_run_loop_(NULL),
......
......@@ -27,14 +27,12 @@ class MessagePumpUIApplication;
class BASE_EXPORT RunLoop {
public:
RunLoop();
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
#if defined(USE_AURA)
explicit RunLoop(MessageLoop::Dispatcher* dispatcher);
#endif
~RunLoop();
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
#if defined(USE_AURA)
void set_dispatcher(MessageLoop::Dispatcher* dispatcher) {
dispatcher_ = dispatcher;
}
......@@ -97,8 +95,7 @@ class BASE_EXPORT RunLoop {
// Parent RunLoop or NULL if this is the top-most RunLoop.
RunLoop* previous_run_loop_;
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
#if defined(USE_AURA)
MessageLoop::Dispatcher* dispatcher_;
#endif
......
......@@ -631,7 +631,7 @@
</if>
</if>
</if>
<if expr="is_macosx or is_ios">
<if expr="(is_macosx or is_ios) and not pp_ifdef('toolkit_views')">
<structure type="chrome_scaled_image" name="IDR_OTR_ICON" file="mac/otr_icon.png" />
</if>
<if expr="context.startswith('default_')">
......@@ -944,7 +944,7 @@
<structure type="chrome_scaled_image" name="IDR_TAB_ACTIVE_LEFT" file="common/tab_active_left.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_ACTIVE_RIGHT" file="common/tab_active_right.png" />
</if>
<if expr="is_macosx or is_ios">
<if expr="(is_macosx or is_ios) and not pp_ifdef('toolkit_views')">
<structure type="chrome_scaled_image" name="IDR_TAB_ACTIVE_CENTER" file="mac/tab_active_center.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_ACTIVE_LEFT" file="mac/tab_active_left.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_ACTIVE_RIGHT" file="mac/tab_active_right.png" />
......@@ -963,7 +963,7 @@
<structure type="chrome_scaled_image" name="IDR_TAB_ALPHA_LEFT" file="common/tab_alpha_left.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_ALPHA_RIGHT" file="common/tab_alpha_right.png" />
</if>
<if expr="is_macosx or is_ios">
<if expr="(is_macosx or is_ios) and not pp_ifdef('toolkit_views')">
<structure type="chrome_scaled_image" name="IDR_TAB_ALPHA_LEFT" file="mac/tab_alpha_left.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_ALPHA_RIGHT" file="mac/tab_alpha_right.png" />
</if>
......@@ -985,7 +985,7 @@
<structure type="chrome_scaled_image" name="IDR_TAB_INACTIVE_LEFT" file="common/tab_inactive_left.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_INACTIVE_RIGHT" file="common/tab_inactive_right.png" />
</if>
<if expr="is_macosx or is_ios">
<if expr="(is_macosx or is_ios) and not pp_ifdef('toolkit_views')">
<structure type="chrome_scaled_image" name="IDR_TAB_INACTIVE_CENTER" file="mac/tab_inactive_center.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_INACTIVE_LEFT" file="mac/tab_inactive_left.png" />
<structure type="chrome_scaled_image" name="IDR_TAB_INACTIVE_RIGHT" file="mac/tab_inactive_right.png" />
......
......@@ -3347,10 +3347,6 @@
'conditions': [
['use_aura==1', {
'dependencies': [
'../build/linux/system.gyp:dbus',
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:x11',
'../dbus/dbus.gyp:dbus',
'../ui/views/controls/webview/webview.gyp:webview',
'../ui/views/views.gyp:views',
],
......@@ -3359,17 +3355,10 @@
'<(INTERMEDIATE_DIR)/chrome',
],
'sources/': [
['exclude', '^browser/platform_util_common_linux.cc'],
['include', '^browser/printing/print_dialog_cloud.cc'],
['include', '^browser/printing/print_dialog_cloud.h'],
],
}],
# GTK build only
['toolkit_uses_gtk==1', {
'sources/': [
['exclude', '^browser/lifetime/application_lifetime_stub.cc'],
],
}],
['gcc_version == 45', {
# Avoid gcc 4.5 miscompilation of template_url.cc
# as per http://crbug.com/41887
......@@ -3379,6 +3368,27 @@
}],
],
}],
['OS=="linux"', {
'conditions': [
['use_aura==1', {
'dependencies': [
'../build/linux/system.gyp:dbus',
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:x11',
'../dbus/dbus.gyp:dbus',
],
'sources/': [
['exclude', '^browser/platform_util_common_linux.cc'],
],
}],
# GTK build only
['toolkit_uses_gtk==1', {
'sources/': [
['exclude', '^browser/lifetime/application_lifetime_stub.cc'],
],
}],
],
}],
['enable_plugin_installation==0', {
'sources!': [
'browser/plugins/plugin_installer.cc',
......
......@@ -3273,12 +3273,8 @@
['exclude', '^browser/ui/webui/set_as_default_browser_ui.h'],
],
'conditions': [
['use_aura==1',{
['use_aura==1', {
'dependencies': [
'../build/linux/system.gyp:dbus',
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:x11',
'../dbus/dbus.gyp:dbus',
'../ui/views/controls/webview/webview.gyp:webview',
'../ui/views/views.gyp:views',
],
......@@ -3287,6 +3283,7 @@
'<(INTERMEDIATE_DIR)/chrome',
],
'sources/': [
['exclude', '^browser/ui/cocoa/*'],
['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.cc'],
['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.h'],
['exclude', '^browser/ui/views/uninstall_view.cc'],
......@@ -3303,6 +3300,18 @@
['exclude', '^browser/ui/views/'],
]
}],
],
}],
['OS=="linux"', {
'conditions': [
['use_aura==1', {
'dependencies': [
'../build/linux/system.gyp:dbus',
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:x11',
'../dbus/dbus.gyp:dbus',
],
}],
# GTK build only
['toolkit_uses_gtk==1', {
'sources/': [
......
......@@ -93,6 +93,8 @@
'layout_manager.h',
'remote_root_window_host_win.cc',
'remote_root_window_host_win.h',
'root_window_host_mac.mm',
'root_window_host_mac.h',
'root_window_host_ozone.cc',
'root_window_host_ozone.h',
'root_window_host_win.cc',
......
......@@ -5,6 +5,7 @@
#include "ui/aura/env.h"
#include "base/command_line.h"
#include "base/message_loop/message_pump_dispatcher.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/input_state_lookup.h"
#include "ui/aura/window.h"
......@@ -75,8 +76,6 @@ bool Env::IsMouseButtonDown() const {
mouse_button_flags_ != 0;
}
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
base::MessageLoop::Dispatcher* Env::GetDispatcher() {
#if defined(USE_X11)
return base::MessagePumpX11::Current();
......@@ -84,7 +83,6 @@ base::MessageLoop::Dispatcher* Env::GetDispatcher() {
return dispatcher_.get();
#endif
}
#endif
void Env::RootWindowActivated(RootWindow* root_window) {
FOR_EACH_OBSERVER(EnvObserver, observers_,
......
......@@ -28,10 +28,8 @@ class InputStateLookup;
class RootWindow;
class Window;
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(USE_X11)
// Creates a platform-specific native event dispatcher.
base::MessageLoop::Dispatcher* CreateDispatcher();
#endif
// A singleton object that tracks general state within Aura.
// TODO(beng): manage RootWindows.
......@@ -68,10 +66,7 @@ class AURA_EXPORT Env : public ui::EventTarget {
// Returns the native event dispatcher. The result should only be passed to
// base::RunLoop(dispatcher), or used to dispatch an event by
// |Dispatch(const NativeEvent&)| on it. It must never be stored.
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(USE_GTK_MESSAGE_PUMP)
base::MessageLoop::Dispatcher* GetDispatcher();
#endif
// Invoked by RootWindow when its host is activated.
void RootWindowActivated(RootWindow* root_window);
......@@ -96,9 +91,7 @@ class AURA_EXPORT Env : public ui::EventTarget {
virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
ObserverList<EnvObserver> observers_;
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(USE_X11)
scoped_ptr<base::MessageLoop::Dispatcher> dispatcher_;
#endif
static Env* instance_;
int mouse_button_flags_;
......
// Copyright 2014 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_AURA_ROOT_WINDOW_HOST_MAC_H_
#define UI_AURA_ROOT_WINDOW_HOST_MAC_H_
#include <vector>
#include "base/mac/scoped_nsobject.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/window_tree_host.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect.h"
namespace ui {
class MouseEvent;
}
namespace aura {
namespace internal {
class TouchEventCalibrate;
}
class AURA_EXPORT RootWindowHostMac : public RootWindowHost {
public:
explicit RootWindowHostMac(const gfx::Rect& bounds);
virtual ~RootWindowHostMac();
private:
// RootWindowHost Overrides.
virtual RootWindow* GetRootWindow() OVERRIDE;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
virtual void ToggleFullScreen() OVERRIDE;
virtual gfx::Rect GetBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual gfx::Insets GetInsets() const OVERRIDE;
virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE;
virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual bool ConfineCursorToRootWindow() OVERRIDE;
virtual void UnConfineCursor() OVERRIDE;
virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void PrepareForShutdown() OVERRIDE;
private:
base::scoped_nsobject<NSWindow> window_;
DISALLOW_COPY_AND_ASSIGN(RootWindowHostMac);
};
} // namespace aura
#endif // UI_AURA_ROOT_WINDOW_HOST_MAC_H_
// Copyright 2014 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 <Cocoa/Cocoa.h>
#include "ui/aura/root_window_host_mac.h"
#include "ui/aura/window_tree_host.h"
#include "ui/aura/window_tree_host_delegate.h"
namespace aura {
RootWindowHostMac::RootWindowHostMac(const gfx::Rect& bounds) {
window_.reset(
[[NSWindow alloc]
initWithContentRect:NSRectFromCGRect(bounds.ToCGRect())
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]);
CreateCompositor(GetAcceleratedWidget());
}
RootWindowHostMac::~RootWindowHostMac() {
}
RootWindow* RootWindowHostMac::GetRootWindow() {
return delegate_->AsRootWindow();
}
gfx::AcceleratedWidget RootWindowHostMac::GetAcceleratedWidget() {
return [window_ contentView];
}
void RootWindowHostMac::Show() {
[window_ makeKeyAndOrderFront:nil];
}
void RootWindowHostMac::Hide() {
[window_ orderOut:nil];
}
void RootWindowHostMac::ToggleFullScreen() {
}
gfx::Rect RootWindowHostMac::GetBounds() const {
return gfx::Rect(NSRectToCGRect([window_ frame]));
}
void RootWindowHostMac::SetBounds(const gfx::Rect& bounds) {
[window_ setFrame:NSRectFromCGRect(bounds.ToCGRect()) display:YES animate:NO];
}
gfx::Insets RootWindowHostMac::GetInsets() const {
NOTIMPLEMENTED();
return gfx::Insets();
}
void RootWindowHostMac::SetInsets(const gfx::Insets& insets) {
NOTIMPLEMENTED();
}
gfx::Point RootWindowHostMac::GetLocationOnNativeScreen() const {
NOTIMPLEMENTED();
return gfx::Point(0, 0);
}
void RootWindowHostMac::SetCapture() {
NOTIMPLEMENTED();
}
void RootWindowHostMac::ReleaseCapture() {
NOTIMPLEMENTED();
}
void RootWindowHostMac::SetCursor(gfx::NativeCursor cursor_type) {
NOTIMPLEMENTED();
}
bool RootWindowHostMac::QueryMouseLocation(gfx::Point* location_return) {
NOTIMPLEMENTED();
return false;
}
bool RootWindowHostMac::ConfineCursorToRootWindow() {
return false;
}
void RootWindowHostMac::UnConfineCursor() {
NOTIMPLEMENTED();
}
void RootWindowHostMac::OnCursorVisibilityChanged(bool show) {
NOTIMPLEMENTED();
}
void RootWindowHostMac::MoveCursorTo(const gfx::Point& location) {
NOTIMPLEMENTED();
}
void RootWindowHostMac::PostNativeEvent(const base::NativeEvent& event) {
NOTIMPLEMENTED();
}
void RootWindowHostMac::OnDeviceScaleFactorChanged(float device_scale_factor) {
NOTIMPLEMENTED();
}
void RootWindowHostMac::PrepareForShutdown() {
NOTIMPLEMENTED();
}
// static
RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
return new RootWindowHostMac(bounds);
}
// static
gfx::Size RootWindowHost::GetNativeScreenSize() {
NOTIMPLEMENTED();
return gfx::Size(1024, 768);
}
} // namespace aura
......@@ -7,6 +7,7 @@
#include <vector>
#include "base/event_types.h"
#include "base/message_loop/message_loop.h"
#include "ui/aura/aura_export.h"
#include "ui/base/cursor/cursor.h"
......
......@@ -90,12 +90,12 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
#if defined(OS_WIN)
const FORMATETC& ToFormatEtc() const { return data_; }
#elif defined(USE_AURA)
const std::string& ToString() const { return data_; }
#elif defined(OS_MACOSX)
// Custom copy and assignment constructor to handle NSString.
FormatType(const FormatType& other);
FormatType& operator=(const FormatType& other);
#elif defined(USE_AURA)
const std::string& ToString() const { return data_; }
#endif
private:
......@@ -116,13 +116,13 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
FormatType(UINT native_format, LONG index);
UINT ToUINT() const { return data_.cfFormat; }
FORMATETC data_;
#elif defined(USE_AURA)
explicit FormatType(const std::string& native_format);
std::string data_;
#elif defined(OS_MACOSX)
explicit FormatType(NSString* native_format);
NSString* ToNSString() const { return data_; }
NSString* data_;
#elif defined(USE_AURA)
explicit FormatType(const std::string& native_format);
std::string data_;
#elif defined(TOOLKIT_GTK)
explicit FormatType(const std::string& native_format);
explicit FormatType(const GdkAtom& native_format);
......
......@@ -47,7 +47,7 @@ class ClipboardData {
virtual ~ClipboardData() {}
// Bitmask of AuraClipboardFormat types.
const int format() const { return format_; }
int format() const { return format_; }
const std::string& text() const { return text_; }
void set_text(const std::string& text) {
......
......@@ -28,7 +28,7 @@ class NSString;
namespace ui {
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) && !defined(USE_AURA)
UI_BASE_EXPORT extern NSString* const kWebCustomDataPboardType;
#elif (!defined(OS_WIN) && defined(USE_AURA)) || defined(TOOLKIT_GTK)
UI_BASE_EXPORT extern const char kMimeTypeWebCustomData[];
......
......@@ -9,6 +9,10 @@
namespace ui {
// TODO(dcheng): This name is temporary. See crbug.com/106449.
#if defined(USE_AURA)
const char kMimeTypeWebCustomData[] = "chromium/x-web-custom-data";
#else
NSString* const kWebCustomDataPboardType = @"org.chromium.web-custom-data";
#endif
} // namespace ui
// Copyright 2014 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/cursor/cursor.h"
namespace ui {
void Cursor::RefCustomCursor() {
// TODO(macguru):
}
void Cursor::UnrefCustomCursor() {
// TODO(macguru):
}
} // namespace ui
......@@ -10,7 +10,7 @@
#include "ui/base/ui_base_export.h"
#include "ui/gfx/native_widget_types.h"
#if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(USE_AURA))
#if !defined(OS_WIN) && !defined(USE_AURA)
#error view_prop.h is only for windows and aura builds.
#endif
......
......@@ -154,7 +154,10 @@ class ScreenMac : public gfx::Screen {
virtual gfx::Display GetDisplayNearestWindow(
gfx::NativeView view) const OVERRIDE {
NSWindow* window = [view window];
NSWindow* window = nil;
#if !defined(USE_AURA)
window = [view window];
#endif
if (!window)
return GetPrimaryDisplay();
NSScreen* match_screen = [window screen];
......@@ -209,8 +212,10 @@ class ScreenMac : public gfx::Screen {
namespace gfx {
#if !defined(USE_AURA)
Screen* CreateNativeScreen() {
return new ScreenMac;
}
#endif
}
......@@ -306,7 +306,7 @@
<structure type="chrome_scaled_image" name="IDR_MENU_HIERARCHY_ARROW" file="common/menu_hierarchy_arrow.png" />
<structure type="chrome_scaled_image" name="IDR_MENU_HIERARCHY_ARROW_DARK_BACKGROUND" file="common/menu_hierarchy_arrow_white.png" />
</if>
<if expr="is_macosx or is_ios">
<if expr="(is_macosx or is_ios) and not pp_ifdef('toolkit_views')">
<structure type="chrome_scaled_image" name="IDR_MENU_HIERARCHY_ARROW" file="mac/menu_hierarchy_arrow.png" />
</if>
<if expr="pp_ifdef('toolkit_views')">
......
......@@ -133,6 +133,7 @@
'base/cursor/cursor_loader_x11.cc',
'base/cursor/cursor_loader_x11.h',
'base/cursor/cursor_null.cc',
'base/cursor/cursor_mac.mm',
'base/cursor/cursor_win.cc',
'base/cursor/cursor_x11.cc',
'base/cursor/cursors_aura.cc',
......@@ -356,6 +357,8 @@
}],
['use_aura==1', {
'sources/': [
['exclude', 'base/clipboard/clipboard_mac.mm'],
['exclude', 'base/layout_mac.mm'],
['exclude', 'base/work_area_watcher_observer.h'],
['exclude', 'base/x/active_window_watcher_x.cc'],
['exclude', 'base/x/active_window_watcher_x.h'],
......@@ -374,6 +377,7 @@
'base/cursor/cursor.h',
'base/cursor/cursor_loader_x11.cc',
'base/cursor/cursor_loader_x11.h',
'base/cursor/cursor_mac.mm',
'base/cursor/cursor_win.cc',
'base/cursor/cursor_x11.cc',
'base/x/selection_owner.cc',
......
......@@ -54,6 +54,7 @@
}],
['use_aura==1', {
'sources!': [
'base/test/ui_controls_mac.mm',
'base/test/ui_controls_win.cc',
],
}],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment