From 6f637730a38de10a1173f05e48271483d27b648d Mon Sep 17 00:00:00 2001 From: "dhollowa@chromium.org" Date: Thu, 19 Jan 2012 03:15:34 +0000 Subject: Aura Shell needs to exist on Mac Adds first cut at "Aura Shell.app" on Mac. The 'ash_shell' is extended to generate a Cocoa application. This application brings up a single window containing the Aura desktop. The main view of this window provides an accelerated surface to Aura in which it can composite and draw its results. What works: - The application launches and renders the Aura desktop and background - Mouse movement, clicking, double-clicking, and interactions with Aura windows and widgets - Text buttons render with Skia text (needs improvement) - Non-modal transient window button - Window-modal window button - System-modal window button - Example Widgets button (checkboxes, radios, buttons) - Lock Screen button - Create Non-Resizable window button - Create Pointy Bubble button - Create Widow button - Switcher and Taskbar What doesn't work: - Open Views Examples Window button - Views menus - Views scrollbars - Views accelerators - Views tooltips - Drag and drop - Anything involving MessageLoop dispatcher logic - Mouse movement doesn't pass through to Aura when mouse button is up Note: Required .gyp flags are: 'use_aura': 1, 'use_webkit_compositor': 1, BUG=109946 TEST=Manual tests. R=sky@chromium.org, thakis@chromium.org Review URL: https://chromiumcodereview.appspot.com/9232028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118222 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/ash.gyp | 24 + ash/drag_drop/drag_drop_controller.cc | 3 + ash/launcher/launcher_view.cc | 2 + ash/launcher/launcher_view.h | 2 + ash/shell/app_list.cc | 2 + ash/shell/cocoa/app-Info.plist | 34 + ash/shell/cocoa/app.icns | Bin 0 -> 147653 bytes ash/shell/cocoa/nibs/MainMenu.xib | 2163 ++++++++++++++++++++++++++++++++ ash/shell/cocoa/nibs/RootWindow.xib | 169 +++ ash/shell/window_type_launcher.cc | 13 +- ash/shell/window_type_launcher.h | 11 +- ash/wm/toplevel_window_event_filter.cc | 2 + chrome/chrome_repack_chrome.gypi | 4 +- ui/aura/aura.gyp | 7 +- ui/aura/root_window.cc | 6 +- ui/aura/root_window.h | 2 + ui/aura/root_window_host.h | 6 + ui/aura/root_window_host_mac.h | 30 + ui/aura/root_window_host_mac.mm | 189 +++ ui/aura/root_window_mac.h | 38 + ui/aura/root_window_mac.mm | 35 + ui/aura/root_window_view_mac.h | 22 + ui/aura/root_window_view_mac.mm | 16 + ui/aura/test/aura_test_base.cc | 4 +- ui/aura/test/test_activation_client.h | 4 +- ui/base/clipboard/clipboard.h | 18 +- ui/base/clipboard/custom_data_helper.h | 8 +- ui/base/cocoa/events_mac.mm | 6 + ui/base/theme_provider.h | 4 +- ui/gfx/canvas_skia.h | 3 + ui/views/focus/accelerator_handler.h | 8 +- ui/views/view.cc | 2 + ui/views/views.gyp | 11 + ui/views/widget/drop_helper.cc | 4 +- ui/views/widget/native_widget_aura.cc | 2 + ui/views/widget/widget.cc | 7 +- 36 files changed, 2832 insertions(+), 29 deletions(-) create mode 100644 ash/shell/cocoa/app-Info.plist create mode 100644 ash/shell/cocoa/app.icns create mode 100644 ash/shell/cocoa/nibs/MainMenu.xib create mode 100644 ash/shell/cocoa/nibs/RootWindow.xib create mode 100644 ui/aura/root_window_host_mac.h create mode 100644 ui/aura/root_window_host_mac.mm create mode 100644 ui/aura/root_window_mac.h create mode 100644 ui/aura/root_window_mac.mm create mode 100644 ui/aura/root_window_view_mac.h create mode 100644 ui/aura/root_window_view_mac.mm diff --git a/ash/ash.gyp b/ash/ash.gyp index 4b95c66..8c97177 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -5,6 +5,7 @@ { 'variables': { 'chromium_code': 1, + 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', }, 'targets': [ @@ -293,6 +294,29 @@ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc', '../ui/views/test/test_views_delegate.cc', ], + 'conditions': [ + ['OS=="mac"', { + 'product_name': 'AuraShell', + 'mac_bundle': 1, + 'sources/': [ + ['exclude', 'shell/shell_main_parts.cc'], + ], + 'mac_bundle_resources': [ + 'shell/cocoa/app.icns', + 'shell/cocoa/app-Info.plist', + 'shell/cocoa/nibs/MainMenu.xib', + 'shell/cocoa/nibs/RootWindow.xib', + '<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak', + 'last_mouse_location(); +#if !defined(OS_MACOSX) if (should_block_during_drag_drop_) { MessageLoopForUI::current()->RunWithDispatcher( RootWindow::GetInstance()->GetDispatcher()); } +#endif // !defined(OS_MACOSX) + return drag_operation_; } diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index b2ffb02..9d5a913 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -412,6 +412,7 @@ void LauncherView::GetOverflowWindows(std::vector* names) { } void LauncherView::ShowOverflowMenu() { +#if !defined(OS_MACOSX) std::vector windows; GetOverflowWindows(&windows); if (windows.empty()) @@ -442,6 +443,7 @@ void LauncherView::ShowOverflowMenu() { if (!delegate) return; delegate->LauncherItemClicked(*window_iter); +#endif // !defined(OS_MACOSX) } void LauncherView::CancelDrag(views::View* deleted_view) { diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index 8d0db48..afe2679 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -138,7 +138,9 @@ class LauncherView : public views::WidgetDelegateView, // Index |drag_view_| was initially at. int start_drag_index_; +#if !defined(OS_MACOSX) scoped_ptr overflow_menu_runner_; +#endif // Used to handle cycling among windows. scoped_ptr cycler_; diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc index 0a908f9..eaa4ffa 100644 --- a/ash/shell/app_list.cc +++ b/ash/shell/app_list.cc @@ -90,7 +90,9 @@ class WindowTypeLauncherItem : public ash::AppListItemModel { break; } case EXAMPLES_WINDOW: { +#if !defined(OS_MACOSX) views::examples::ShowExamplesWindow(false); +#endif break; } default: diff --git a/ash/shell/cocoa/app-Info.plist b/ash/shell/cocoa/app-Info.plist new file mode 100644 index 0000000..8c70f98 --- /dev/null +++ b/ash/shell/cocoa/app-Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + app.icns + CFBundleIdentifier + org.chromium.AuraShell + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + Ash8 + CFBundleVersion + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSHumanReadableCopyright + Copyright © 2012 Google Inc. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/ash/shell/cocoa/app.icns b/ash/shell/cocoa/app.icns new file mode 100644 index 0000000..055e46b Binary files /dev/null and b/ash/shell/cocoa/app.icns differ diff --git a/ash/shell/cocoa/nibs/MainMenu.xib b/ash/shell/cocoa/nibs/MainMenu.xib new file mode 100644 index 0000000..9190616 --- /dev/null +++ b/ash/shell/cocoa/nibs/MainMenu.xib @@ -0,0 +1,2163 @@ + + + + 1070 + 11C74 + 1900 + 1138.23 + 567.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1900 + + + YES + NSMenu + NSMenuItem + NSCustomObject + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + YES + + + Aura Shell + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + Aura Shell + + YES + + + About Aura Shell + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide Aura Shell + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit Aura Shell + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + YES + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + YES + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save… + s + 1048576 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + YES + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Paste and Match Style + V + 1572864 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + YES + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find and Replace… + f + 1572864 + 2147483647 + + + 12 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + YES + + + Show Spelling and Grammar + : + 1048576 + 2147483647 + + + + + + Check Document Now + ; + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + Correct Spelling Automatically + + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + YES + + + Show Substitutions + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Dashes + + 2147483647 + + + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + Text Replacement + + 2147483647 + + + + + + + + + Transformations + + 2147483647 + + + submenuAction: + + Transformations + + YES + + + Make Upper Case + + 2147483647 + + + + + + Make Lower Case + + 2147483647 + + + + + + Capitalize + + 2147483647 + + + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + YES + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + YES + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + YES + + + Aura Shell Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + + + YES + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + saveDocument: + + + + 362 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + terminate: + + + + 449 + + + + toggleAutomaticSpellingCorrection: + + + + 456 + + + + orderFrontSubstitutionsPanel: + + + + 458 + + + + toggleAutomaticDashSubstitution: + + + + 461 + + + + toggleAutomaticTextReplacement: + + + + 463 + + + + uppercaseWord: + + + + 464 + + + + capitalizeWord: + + + + 467 + + + + lowercaseWord: + + + + 468 + + + + pasteAsPlainText: + + + + 486 + + + + performFindPanelAction: + + + + 487 + + + + performFindPanelAction: + + + + 488 + + + + performFindPanelAction: + + + + 489 + + + + showHelp: + + + + 493 + + + + performFindPanelAction: + + + + 535 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + + + + + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 217 + + + YES + + + + + + 83 + + + YES + + + + + + 81 + + + YES + + + + + + + + + + + + + + + 75 + + + + + 78 + + + + + 72 + + + + + 82 + + + + + 124 + + + YES + + + + + + 77 + + + + + 73 + + + + + 79 + + + + + 112 + + + + + 74 + + + + + 125 + + + YES + + + + + + 126 + + + + + 205 + + + YES + + + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + YES + + + + + + 216 + + + YES + + + + + + 200 + + + YES + + + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + YES + + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 57 + + + YES + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + YES + + + + + + 296 + + + YES + + + + + + + 297 + + + + + 298 + + + + + 211 + + + YES + + + + + + 212 + + + YES + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + YES + + + + + + 349 + + + YES + + + + + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 450 + + + YES + + + + + + 451 + + + YES + + + + + + + + 452 + + + + + 453 + + + + + 454 + + + + + 457 + + + + + 459 + + + + + 460 + + + + + 462 + + + + + 465 + + + + + 466 + + + + + 485 + + + + + 490 + + + YES + + + + + + 491 + + + YES + + + + + + 492 + + + + + 534 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 112.IBPluginDependency + 124.IBPluginDependency + 125.IBPluginDependency + 126.IBPluginDependency + 129.IBPluginDependency + 130.IBPluginDependency + 131.IBPluginDependency + 134.IBPluginDependency + 136.IBPluginDependency + 143.IBPluginDependency + 144.IBPluginDependency + 145.IBPluginDependency + 149.IBPluginDependency + 150.IBPluginDependency + 19.IBPluginDependency + 195.IBPluginDependency + 196.IBPluginDependency + 197.IBPluginDependency + 198.IBPluginDependency + 199.IBPluginDependency + 200.IBPluginDependency + 201.IBPluginDependency + 202.IBPluginDependency + 203.IBPluginDependency + 204.IBPluginDependency + 205.IBPluginDependency + 206.IBPluginDependency + 207.IBPluginDependency + 208.IBPluginDependency + 209.IBPluginDependency + 210.IBPluginDependency + 211.IBPluginDependency + 212.IBPluginDependency + 213.IBPluginDependency + 214.IBPluginDependency + 215.IBPluginDependency + 216.IBPluginDependency + 217.IBPluginDependency + 218.IBPluginDependency + 219.IBPluginDependency + 220.IBPluginDependency + 221.IBPluginDependency + 23.IBPluginDependency + 236.IBPluginDependency + 239.IBPluginDependency + 24.IBPluginDependency + 29.IBPluginDependency + 295.IBPluginDependency + 296.IBPluginDependency + 297.IBPluginDependency + 298.IBPluginDependency + 346.IBPluginDependency + 348.IBPluginDependency + 349.IBPluginDependency + 350.IBPluginDependency + 351.IBPluginDependency + 354.IBPluginDependency + 450.IBPluginDependency + 451.IBPluginDependency + 452.IBPluginDependency + 453.IBPluginDependency + 454.IBPluginDependency + 457.IBPluginDependency + 459.IBPluginDependency + 460.IBPluginDependency + 462.IBPluginDependency + 465.IBPluginDependency + 466.IBPluginDependency + 485.IBPluginDependency + 490.IBPluginDependency + 491.IBPluginDependency + 492.IBPluginDependency + 5.IBPluginDependency + 534.IBPluginDependency + 56.IBPluginDependency + 57.IBPluginDependency + 58.IBPluginDependency + 72.IBPluginDependency + 73.IBPluginDependency + 74.IBPluginDependency + 75.IBPluginDependency + 77.IBPluginDependency + 78.IBPluginDependency + 79.IBPluginDependency + 81.IBPluginDependency + 82.IBPluginDependency + 83.IBPluginDependency + 92.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 535 + + + + YES + + NSDocument + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + id + id + id + id + id + id + + + + YES + + YES + printDocument: + revertDocumentToSaved: + runPageLayout: + saveDocument: + saveDocumentAs: + saveDocumentTo: + + + YES + + printDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + + + IBProjectSource + ./Classes/NSDocument.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/ash/shell/cocoa/nibs/RootWindow.xib b/ash/shell/cocoa/nibs/RootWindow.xib new file mode 100644 index 0000000..8ed2100 --- /dev/null +++ b/ash/shell/cocoa/nibs/RootWindow.xib @@ -0,0 +1,169 @@ + + + + 1070 + 11C74 + 1900 + 1138.23 + 567.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1900 + + + YES + NSWindowTemplate + NSView + NSCustomObject + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSWindowController + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{196, 240}, {672, 666}} + 544735232 + Aura Shell + RootWindowMac + + + + + 256 + {672, 666} + + + + + {{0, 0}, {1680, 1028}} + {10000000000000, 10000000000000} + YES + + + + + YES + + + window + + + + 5 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 2.CustomClassName + 2.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{357, 418}, {480, 270}} + + RootWindowView + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 5 + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc index 46a26fc..b7424da 100644 --- a/ash/shell/window_type_launcher.cc +++ b/ash/shell/window_type_launcher.cc @@ -149,7 +149,7 @@ void InitWindowTypeLauncher() { gfx::Rect(120, 150, 400, 400)); widget->GetNativeView()->SetName("WindowTypeLauncher"); ash::internal::SetShadowType(widget->GetNativeView(), - ash::internal::SHADOW_TYPE_NONE); + ash::internal::SHADOW_TYPE_NONE); widget->Show(); } @@ -188,7 +188,9 @@ WindowTypeLauncher::WindowTypeLauncher() AddChildView(window_modal_button_); AddChildView(transient_button_); AddChildView(examples_button_); +#if !defined(OS_MACOSX) set_context_menu_controller(this); +#endif } WindowTypeLauncher::~WindowTypeLauncher() { @@ -290,11 +292,15 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender, ui::MODAL_TYPE_WINDOW); } else if (sender == transient_button_) { NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); - } else if (sender == examples_button_) { + } +#if !defined(OS_MACOSX) + else if (sender == examples_button_) { views::examples::ShowExamplesWindow(false); } +#endif // !defined(OS_MACOSX) } +#if !defined(OS_MACOSX) void WindowTypeLauncher::ExecuteCommand(int id) { switch (id) { case COMMAND_NEW_WINDOW: @@ -307,7 +313,9 @@ void WindowTypeLauncher::ExecuteCommand(int id) { break; } } +#endif // !defined(OS_MACOSX) +#if !defined(OS_MACOSX) void WindowTypeLauncher::ShowContextMenuForView(views::View* source, const gfx::Point& p, bool is_mouse_gesture) { @@ -325,6 +333,7 @@ void WindowTypeLauncher::ShowContextMenuForView(views::View* source, MenuRunner::HAS_MNEMONICS) == MenuRunner::MENU_DELETED) return; } +#endif // !defined(OS_MACOSX) } // namespace shell } // namespace ash diff --git a/ash/shell/window_type_launcher.h b/ash/shell/window_type_launcher.h index 08ebf22..190e37b 100644 --- a/ash/shell/window_type_launcher.h +++ b/ash/shell/window_type_launcher.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. @@ -21,10 +21,15 @@ namespace shell { // The contents view/delegate of a window that shows some buttons that create // various window types. +#if defined(OS_MACOSX) +class WindowTypeLauncher : public views::WidgetDelegateView, + public views::ButtonListener { +#else class WindowTypeLauncher : public views::WidgetDelegateView, public views::ButtonListener, public views::MenuDelegate, public views::ContextMenuController { +#endif // defined(OS_MACOSX) public: WindowTypeLauncher(); virtual ~WindowTypeLauncher(); @@ -52,6 +57,7 @@ class WindowTypeLauncher : public views::WidgetDelegateView, virtual void ButtonPressed(views::Button* sender, const views::Event& event) OVERRIDE; +#if !defined(OS_MACOSX) // Overridden from views::MenuDelegate: virtual void ExecuteCommand(int id) OVERRIDE; @@ -59,6 +65,7 @@ class WindowTypeLauncher : public views::WidgetDelegateView, virtual void ShowContextMenuForView(views::View* source, const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; +#endif // !defined(OS_MACOSX) views::NativeTextButton* create_button_; views::NativeTextButton* create_nonresizable_button_; @@ -69,7 +76,9 @@ class WindowTypeLauncher : public views::WidgetDelegateView, views::NativeTextButton* window_modal_button_; views::NativeTextButton* transient_button_; views::NativeTextButton* examples_button_; +#if !defined(OS_MACOSX) scoped_ptr menu_runner_; +#endif DISALLOW_COPY_AND_ASSIGN(WindowTypeLauncher); }; diff --git a/ash/wm/toplevel_window_event_filter.cc b/ash/wm/toplevel_window_event_filter.cc index 3396eed..fb50148 100644 --- a/ash/wm/toplevel_window_event_filter.cc +++ b/ash/wm/toplevel_window_event_filter.cc @@ -238,8 +238,10 @@ void ToplevelWindowEventFilter::RunMoveLoop(aura::Window* source) { aura::Window::ConvertPointToWindow( aura::RootWindow::GetInstance(), source, &source_mouse_location); UpdateMouseDownLocation(source, source_mouse_location); +#if !defined(OS_MACOSX) MessageLoopForUI::current()->RunWithDispatcher( aura::RootWindow::GetInstance()->GetDispatcher()); +#endif // !defined(OS_MACOSX) in_move_loop_ = false; } diff --git a/chrome/chrome_repack_chrome.gypi b/chrome/chrome_repack_chrome.gypi index 915a22a..5381dfd 100644 --- a/chrome/chrome_repack_chrome.gypi +++ b/chrome/chrome_repack_chrome.gypi @@ -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. { @@ -19,7 +19,7 @@ '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak', ], 'conditions': [ - ['OS != "mac"', { + ['OS != "mac" or use_aura==1', { 'pak_inputs': [ '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.pak', ] diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index db1ad70..073133f 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -48,8 +48,14 @@ 'gestures/gesture_recognizer.h', 'root_window_host.h', 'root_window_host_linux.cc', + 'root_window_host_mac.h', + 'root_window_host_mac.mm', 'root_window_host_win.cc', 'root_window_host_win.h', + 'root_window_mac.h', + 'root_window_mac.mm', + 'root_window_view_mac.h', + 'root_window_view_mac.mm', 'root_window.cc', 'root_window.h', 'event.cc', @@ -159,7 +165,6 @@ '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc', ], - # osmesa GL implementation is used on linux. 'conditions': [ # osmesa GL implementation is used on linux. ['OS=="linux"', { diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 7909239..685c0b9 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -293,9 +293,11 @@ void RootWindow::WindowDestroying(Window* window) { gesture_handler_ = NULL; } +#if !defined(OS_MACOSX) MessageLoop::Dispatcher* RootWindow::GetDispatcher() { return host_.get(); } +#endif // !defined(OS_MACOSX) void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) { observers_.AddObserver(observer); @@ -310,7 +312,9 @@ bool RootWindow::IsMouseButtonDown() const { } void RootWindow::PostNativeEvent(const base::NativeEvent& native_event) { +#if !defined(OS_MACOSX) host_->PostNativeEvent(native_event); +#endif } void RootWindow::ConvertPointToNativeScreen(gfx::Point* point) const { @@ -385,7 +389,6 @@ RootWindow::RootWindow() gesture_recognizer_(GestureRecognizer::GetInstance()) { SetName("RootWindow"); gfx::Screen::SetInstance(screen_); - host_->SetRootWindow(this); last_mouse_location_ = host_->QueryMouseLocation(); if (ui::Compositor::compositor_factory()) { @@ -631,6 +634,7 @@ void RootWindow::Init() { SetBounds(gfx::Rect(host_->GetSize())); Show(); compositor()->SetRootLayer(layer()); + host_->SetRootWindow(this); } gfx::Rect RootWindow::GetInitialHostWindowBounds() const { diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 8e59c4f..7e64a59 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -120,7 +120,9 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, // MessageLoopForUI::RunWithDispatcher() or // MessageLoopForUI::RunAllPendingWithDispatcher(), or used to dispatch // an event by |Dispatch(const NativeEvent&)| on it. It must never be stored. +#if !defined(OS_MACOSX) MessageLoop::Dispatcher* GetDispatcher(); +#endif // Add/remove observer. void AddRootWindowObserver(RootWindowObserver* observer); diff --git a/ui/aura/root_window_host.h b/ui/aura/root_window_host.h index 83edcbd..ad28ca0 100644 --- a/ui/aura/root_window_host.h +++ b/ui/aura/root_window_host.h @@ -23,7 +23,11 @@ class RootWindow; // RootWindowHost bridges between a native window and the embedded RootWindow. // It provides the accelerated widget and maps events from the native os to // aura. +#if defined(OS_MACOSX) +class RootWindowHost { +#else class RootWindowHost : public MessageLoop::Dispatcher { +#endif // defined(OS_MACOSX) public: virtual ~RootWindowHost() {} @@ -72,7 +76,9 @@ class RootWindowHost : public MessageLoop::Dispatcher { virtual void MoveCursorTo(const gfx::Point& location) = 0; // Posts |native_event| to the platform's event queue. +#if !defined(OS_MACOSX) virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0; +#endif }; } // namespace aura diff --git a/ui/aura/root_window_host_mac.h b/ui/aura/root_window_host_mac.h new file mode 100644 index 0000000..4150608 --- /dev/null +++ b/ui/aura/root_window_host_mac.h @@ -0,0 +1,30 @@ +// 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. + +#ifndef UI_AURA_ROOT_WINDOW_HOST_MAC_H_ +#define UI_AURA_ROOT_WINDOW_HOST_MAC_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/event_types.h" + +namespace aura { + +// An interface establishing event dispatch from the Mac native window and the +// Aura host. +class RootWindowHostMacDelegate { + public: + RootWindowHostMacDelegate(); + virtual ~RootWindowHostMacDelegate(); + + // Route events from platform code to the RootWindowHost. + virtual void SendEvent(const base::NativeEvent& native_event) = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(RootWindowHostMacDelegate); +}; + +} // namespace aura + +#endif // UI_AURA_ROOT_WINDOW_HOST_MAC_H_ diff --git a/ui/aura/root_window_host_mac.mm b/ui/aura/root_window_host_mac.mm new file mode 100644 index 0000000..0660a8d --- /dev/null +++ b/ui/aura/root_window_host_mac.mm @@ -0,0 +1,189 @@ +// 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. + +#include "ui/aura/root_window_host_mac.h" + +#import + +#include "base/compiler_specific.h" +#include "base/memory/scoped_nsobject.h" +#include "ui/aura/event.h" +#include "ui/aura/root_window.h" +#include "ui/aura/root_window_host.h" +#include "ui/aura/root_window_mac.h" +#include "ui/aura/root_window_view_mac.h" +#include "ui/gfx/point.h" + +namespace aura { + +// The Mac-specific implementation of the RootWindowHost interface. This class +// acts at an intermediary between the Aura shell and an NSWindow. The +// association between the Aura compositor and the native window's view is +// established with this class as is the association between the native window's +// event dispatch and the Aura event processing. +class RootWindowHostMac : public RootWindowHost, + public RootWindowHostMacDelegate { + public: + explicit RootWindowHostMac(const gfx::Rect& bounds); + virtual ~RootWindowHostMac(); + + // RootWindowHost: + virtual void SetRootWindow(RootWindow* root_window) OVERRIDE; + virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; + virtual void Show() OVERRIDE; + virtual void ToggleFullScreen() OVERRIDE; + virtual gfx::Size GetSize() const OVERRIDE; + virtual void SetSize(const gfx::Size& size) OVERRIDE; + virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; + virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; + virtual void ShowCursor(bool show) OVERRIDE; + virtual gfx::Point QueryMouseLocation() OVERRIDE; + virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; + + // RootWindowHostMacDelegate: + virtual void SendEvent(const base::NativeEvent& native_event) OVERRIDE; + + // Set the initial location of the root window. The origin of |bounds| is + // top-left. This gets converted to bottom-left to match Mac coordinates on + // the main screen. + void SetLocation(const gfx::Rect& bounds); + + private: + // Weak reference. + RootWindow* root_window_; + + // The bounds of the Aura desktop. Relative to Aura's coordinate system. + // This is currently used only for size information, not location. + gfx::Rect bounds_; + + // An NSWindowController for the root window. Controls the actual Cocoa + // window on Mac. + scoped_nsobject controller_; + + DISALLOW_COPY_AND_ASSIGN(RootWindowHostMac); +}; + +RootWindowHostMacDelegate::RootWindowHostMacDelegate() { +} + +RootWindowHostMacDelegate::~RootWindowHostMacDelegate() { +} + +RootWindowHostMac::RootWindowHostMac(const gfx::Rect& bounds) + : root_window_(NULL), bounds_(bounds) { + controller_.reset([[NSWindowController alloc] + initWithWindowNibName:@"RootWindow"]); + SetSize(bounds.size()); + SetLocation(bounds); +} + +RootWindowHostMac::~RootWindowHostMac() { +} + +// static +RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { + return new RootWindowHostMac(bounds); +} + +// static +gfx::Size RootWindowHost::GetNativeScreenSize() { + NSRect screen = [[NSScreen mainScreen] visibleFrame]; + return gfx::Size(NSSizeToCGSize(screen.size)); +} + +void RootWindowHostMac::SetRootWindow(RootWindow* root_window) { + root_window_ = root_window; + + RootWindowView* view = [[controller_ window] contentView]; + DCHECK([view respondsToSelector:@selector(setCompositor:)]); + [view setCompositor:root_window->compositor()]; + + RootWindowMac* window = static_cast([controller_ window]); + DCHECK([window respondsToSelector:@selector(setHostDelegate:)]); + [window setHostDelegate:this]; +} + +gfx::AcceleratedWidget RootWindowHostMac::GetAcceleratedWidget() { + return [[controller_ window] contentView]; +} + +void RootWindowHostMac::Show() { + [controller_ showWindow:controller_]; +} + +void RootWindowHostMac::ToggleFullScreen() { +} + +gfx::Size RootWindowHostMac::GetSize() const { + NSSize size = [[[controller_ window] contentView] bounds].size; + return gfx::Size(NSSizeToCGSize(size)); +} + +void RootWindowHostMac::SetSize(const gfx::Size& size) { + NSSize nssize = NSSizeFromCGSize(size.ToCGSize()); + [[controller_ window] setContentSize:nssize]; + [[controller_ window] setContentMaxSize:nssize]; + [[controller_ window] setContentMinSize:nssize]; +} + +gfx::Point RootWindowHostMac::GetLocationOnNativeScreen() const { + return gfx::Point(); +} + +void RootWindowHostMac::SetCursor(gfx::NativeCursor cursor) { +} + +void RootWindowHostMac::ShowCursor(bool show) { +} + +gfx::Point RootWindowHostMac::QueryMouseLocation() { + return gfx::Point(); +} + +void RootWindowHostMac::MoveCursorTo(const gfx::Point& location) { +} + +void RootWindowHostMac::SendEvent(const base::NativeEvent& native_event) { + ui::EventType type = ui::EventTypeFromNative(native_event); + switch (type) { + case ui::ET_MOUSE_PRESSED: + case ui::ET_MOUSE_DRAGGED: + case ui::ET_MOUSE_RELEASED: + case ui::ET_MOUSE_MOVED: + case ui::ET_MOUSE_ENTERED: + case ui::ET_MOUSE_EXITED: { + MouseEvent mouse_event(native_event); + root_window_->DispatchMouseEvent(&mouse_event); + break; + } + case ui::ET_KEY_PRESSED: + case ui::ET_KEY_RELEASED: { + KeyEvent key_event(native_event, false); + root_window_->DispatchKeyEvent(&key_event); + break; + } + case ui::ET_MOUSEWHEEL: + case ui::ET_TOUCH_RELEASED: + case ui::ET_TOUCH_PRESSED: + case ui::ET_TOUCH_MOVED: + case ui::ET_TOUCH_STATIONARY: + case ui::ET_TOUCH_CANCELLED: + case ui::ET_DROP_TARGET_EVENT: + case ui::ET_FOCUS_CHANGE: + case ui::ET_SCROLL: + case ui::ET_UNKNOWN: + default: + break; + } +} + +void RootWindowHostMac::SetLocation(const gfx::Rect& bounds) { + NSRect screen = [[NSScreen mainScreen] visibleFrame]; + NSPoint origin = NSMakePoint(screen.origin.x + bounds.x(), + screen.origin.y + screen.size.height - + bounds.y() - bounds.height()); + [[controller_ window] setFrameOrigin:origin]; +} + +} // namespace aura diff --git a/ui/aura/root_window_mac.h b/ui/aura/root_window_mac.h new file mode 100644 index 0000000..6ad8ca3 --- /dev/null +++ b/ui/aura/root_window_mac.h @@ -0,0 +1,38 @@ +// 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. + +#ifndef UI_AURA_ROOT_WINDOW_MAC_H_ +#define UI_AURA_ROOT_WINDOW_MAC_H_ +#pragma once + +#import + +namespace aura { +class RootWindowHostMacDelegate; +} // aura + +// RootWindow routes NSWindow events back to the RootWindowHost for dispatch +// to the Aura event handling system. +@interface RootWindowMac : NSWindow { + @private + // Weak. May be NULL. The host delegate acts as a conduit for event routing + // back to the host. + aura::RootWindowHostMacDelegate* hostDelegate_; +} + +// Designated initializer. +- (id)initWithContentRect:(NSRect)contentRect + styleMask:(NSUInteger)windowStyle + backing:(NSBackingStoreType)bufferingType + defer:(BOOL)deferCreation; + +// Sets the |hostDelegate_| +- (void)setHostDelegate:(aura::RootWindowHostMacDelegate*)hostDelegate; + +// Overrides main event dispatch to route NSWindow events to host delegate. +- (void)sendEvent:(NSEvent*)event; + +@end + +#endif // UI_AURA_ROOT_WINDOW_MAC_H_ diff --git a/ui/aura/root_window_mac.mm b/ui/aura/root_window_mac.mm new file mode 100644 index 0000000..32e42b7 --- /dev/null +++ b/ui/aura/root_window_mac.mm @@ -0,0 +1,35 @@ +// 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. + +#import "ui/aura/root_window_mac.h" + +#include "ui/aura/root_window_host_mac.h" + +@implementation RootWindowMac + +- (id)initWithContentRect:(NSRect)contentRect + styleMask:(NSUInteger)windowStyle + backing:(NSBackingStoreType)bufferingType + defer:(BOOL)deferCreation { + if ((self = [super initWithContentRect:contentRect + styleMask:windowStyle + backing:bufferingType + defer:deferCreation])) { + hostDelegate_ = NULL; + } + return self; +} + +- (void)setHostDelegate:(aura::RootWindowHostMacDelegate*)hostDelegate { + hostDelegate_ = hostDelegate; +} + +- (void)sendEvent:(NSEvent*)event { + // Allow both the Cocoa machinery and the Aura machinery to handle the event. + [super sendEvent:event]; + if (hostDelegate_) + hostDelegate_->SendEvent(event); +} + +@end diff --git a/ui/aura/root_window_view_mac.h b/ui/aura/root_window_view_mac.h new file mode 100644 index 0000000..b34f2d4 --- /dev/null +++ b/ui/aura/root_window_view_mac.h @@ -0,0 +1,22 @@ +// 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. + +#ifndef UI_AURA_ROOT_WINDOW_VIEW_MAC_H_ +#define UI_AURA_ROOT_WINDOW_VIEW_MAC_H_ +#pragma once + +#import + +#include "ui/gfx/compositor/compositor.h" + +// RootWindowView provides an NSView class that delegates drawing to a +// ui::Compositor delegate, setting up the NSOpenGLContext as required. +@interface RootWindowView : NSView { + @private + scoped_refptr compositor_; +} +-(void)setCompositor:(scoped_refptr)compositor; +@end + +#endif // UI_AURA_ROOT_WINDOW_VIEW_MAC_H_ diff --git a/ui/aura/root_window_view_mac.mm b/ui/aura/root_window_view_mac.mm new file mode 100644 index 0000000..64c3e00 --- /dev/null +++ b/ui/aura/root_window_view_mac.mm @@ -0,0 +1,16 @@ +// 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. + +#import "ui/aura/root_window_view_mac.h" + +@implementation RootWindowView +-(void)setCompositor:(scoped_refptr)compositor { + compositor_ = compositor; +} + +- (void)drawRect:(NSRect)rect { + if (compositor_) + compositor_->Draw(false); +} +@end diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc index 0a7460c..70d33f5 100644 --- a/ui/aura/test/aura_test_base.cc +++ b/ui/aura/test/aura_test_base.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. @@ -53,8 +53,10 @@ void AuraTestBase::TearDown() { } void AuraTestBase::RunAllPendingInMessageLoop() { +#if !defined(OS_MACOSX) message_loop_.RunAllPendingWithDispatcher( RootWindow::GetInstance()->GetDispatcher()); +#endif } } // namespace test diff --git a/ui/aura/test/test_activation_client.h b/ui/aura/test/test_activation_client.h index a0454ca..8dd7e98b 100644 --- a/ui/aura/test/test_activation_client.h +++ b/ui/aura/test/test_activation_client.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. @@ -42,4 +42,4 @@ class TestActivationClient : public client::ActivationClient, } // namespace test } // namespace aura -#endif // UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ \ No newline at end of file +#endif // UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h index be8d460..4dc7a38 100644 --- a/ui/base/clipboard/clipboard.h +++ b/ui/base/clipboard/clipboard.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. @@ -58,6 +58,14 @@ class UI_EXPORT Clipboard { explicit FormatType(UINT native_format); UINT ToUINT() const { return data_; } UINT data_; +#elif defined(OS_MACOSX) + public: + FormatType(const FormatType& other); + FormatType& operator=(const FormatType& other); + private: + explicit FormatType(NSString* native_format); + NSString* ToNSString() const { return data_; } + NSString* data_; #elif defined(USE_AURA) explicit FormatType(const std::string& native_format); const std::string& ToString() const { return data_; } @@ -67,14 +75,6 @@ class UI_EXPORT Clipboard { explicit FormatType(const GdkAtom& native_format); const GdkAtom& ToGdkAtom() const { return data_; } GdkAtom data_; -#elif defined(OS_MACOSX) - public: - FormatType(const FormatType& other); - FormatType& operator=(const FormatType& other); - private: - explicit FormatType(NSString* native_format); - NSString* ToNSString() const { return data_; } - NSString* data_; #else #error No FormatType definition. #endif diff --git a/ui/base/clipboard/custom_data_helper.h b/ui/base/clipboard/custom_data_helper.h index 3b9e0e1..0bc2405 100644 --- a/ui/base/clipboard/custom_data_helper.h +++ b/ui/base/clipboard/custom_data_helper.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. // @@ -29,10 +29,10 @@ class NSString; namespace ui { -#if (!defined(OS_WIN) && defined(USE_AURA)) || defined(TOOLKIT_USES_GTK) -UI_EXPORT extern const char kMimeTypeWebCustomData[]; -#elif defined(OS_MACOSX) +#if defined(OS_MACOSX) UI_EXPORT extern NSString* const kWebCustomDataPboardType; +#elif (!defined(OS_WIN) && defined(USE_AURA)) || defined(TOOLKIT_USES_GTK) +UI_EXPORT extern const char kMimeTypeWebCustomData[]; #endif UI_EXPORT void ReadCustomDataTypes(const void* data, diff --git a/ui/base/cocoa/events_mac.mm b/ui/base/cocoa/events_mac.mm index 807c92c..f40d755 100644 --- a/ui/base/cocoa/events_mac.mm +++ b/ui/base/cocoa/events_mac.mm @@ -173,6 +173,12 @@ float GetTouchForce(const base::NativeEvent& native_event) { return 0.0; } +bool GetScrollOffsets(const base::NativeEvent& native_event, + float* x_offset, + float* y_offset) { + return false; +} + base::NativeEvent CreateNoopEvent() { return [NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint diff --git a/ui/base/theme_provider.h b/ui/base/theme_provider.h index ded4d1a..a6a5dd9 100644 --- a/ui/base/theme_provider.h +++ b/ui/base/theme_provider.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. @@ -72,7 +72,7 @@ class UI_EXPORT ThemeProvider { // implementations of ThemeProvider. Returns NULL on error. virtual RefCountedMemory* GetRawData(int id) const = 0; -#if defined(OS_MACOSX) +#if defined(OS_MACOSX) && !defined(TOOLKIT_VIEWS) // Gets the NSImage with the specified |id|. // // The bitmap is not assumed to exist. If a theme does not provide an image, diff --git a/ui/gfx/canvas_skia.h b/ui/gfx/canvas_skia.h index 3ccbb60..263b823 100644 --- a/ui/gfx/canvas_skia.h +++ b/ui/gfx/canvas_skia.h @@ -90,6 +90,9 @@ class UI_EXPORT CanvasSkia : public Canvas { // we don't do any fancy blurring. // On Linux, text with halo is created by stroking it with 2px |halo_color| // then filling it with |text_color|. + // On Mac, NOTIMPLEMENTED. + // TODO(dhollowa): Skia-native implementation is underway. Cut over to + // that when ready. http::/crbug.com/109946 void DrawStringWithHalo(const string16& text, const gfx::Font& font, const SkColor& text_color, diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h index d70c4bc..c8644a3 100644 --- a/ui/views/focus/accelerator_handler.h +++ b/ui/views/focus/accelerator_handler.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. @@ -29,7 +29,11 @@ bool VIEWS_EXPORT DispatchXEvent(XEvent* xevent); // This class delegates the key messages to the associated FocusManager class // for the window that is receiving these messages for accelerator processing. +#if defined(OS_MACOSX) +class VIEWS_EXPORT AcceleratorHandler { +#else class VIEWS_EXPORT AcceleratorHandler : public MessageLoop::Dispatcher { +#endif // defined(OS_MACOSX) public: AcceleratorHandler(); @@ -40,6 +44,8 @@ class VIEWS_EXPORT AcceleratorHandler : public MessageLoop::Dispatcher { #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) virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( XEvent* xev) OVERRIDE; diff --git a/ui/views/view.cc b/ui/views/view.cc index b358ef3..510d0e5 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -2039,6 +2039,7 @@ void View::UpdateTooltip() { // Drag and drop --------------------------------------------------------------- void View::DoDrag(const MouseEvent& event, const gfx::Point& press_pt) { +#if !defined(OS_MACOSX) int drag_operations = GetDragOperations(press_pt); if (drag_operations == ui::DragDropTypes::DRAG_NONE) return; @@ -2049,6 +2050,7 @@ void View::DoDrag(const MouseEvent& event, const gfx::Point& press_pt) { // Message the RootView to do the drag and drop. That way if we're removed // the RootView can detect it and avoid calling us back. GetWidget()->RunShellDrag(this, data, drag_operations); +#endif // !defined(OS_MACOSX) } } // namespace views diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 64171c6..0687baf 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -408,6 +408,17 @@ 'widget/child_window_message_processor.cc', 'widget/child_window_message_processor.h', ], + 'conditions': [ + ['OS=="mac"', { + 'sources/': [ + ['exclude', 'mouse_watcher.cc'], + ['exclude', 'controls/menu/*'], + ['exclude', 'controls/scrollbar/*'], + ['exclude', 'focus/accelerator_handler_aura.cc'], + ['exclude', 'widget/tooltip_manager_views.cc'], + ], + }], + ], }], ['toolkit_uses_gtk == 1', { 'dependencies': [ diff --git a/ui/views/widget/drop_helper.cc b/ui/views/widget/drop_helper.cc index 1582351..04305e2 100644 --- a/ui/views/widget/drop_helper.cc +++ b/ui/views/widget/drop_helper.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. @@ -99,7 +99,7 @@ View* DropHelper::CalculateTargetViewImpl( (!view->enabled() || !view->CanDrop(data))) { view = view->parent(); } -#else +#elif !defined(OS_MACOSX) int formats = 0; std::set custom_formats; while (view && view != target_view_) { diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 13632fa..7c637df 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -191,9 +191,11 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); can_activate_ = params.can_activate; DCHECK(GetWidget()->GetRootView()); +#if !defined(OS_MACOSX) if (params.type != Widget::InitParams::TYPE_TOOLTIP) { tooltip_manager_.reset(new views::TooltipManagerAura(this)); } +#endif // !defined(OS_MACOSX) drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); if (params.type != Widget::InitParams::TYPE_TOOLTIP && diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index b9be13b4..3a77c69 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -13,7 +13,6 @@ #include "ui/gfx/compositor/compositor.h" #include "ui/gfx/compositor/layer.h" #include "ui/gfx/screen.h" -#include "ui/views/controls/menu/menu_controller.h" #include "ui/views/focus/focus_manager.h" #include "ui/views/focus/focus_manager_factory.h" #include "ui/views/focus/view_storage.h" @@ -27,6 +26,10 @@ #include "ui/views/widget/widget_delegate.h" #include "ui/views/window/custom_frame_view.h" +#if !defined(OS_MACOSX) +#include "ui/views/controls/menu/menu_controller.h" +#endif + namespace { // Set to true if a pure Views implementation is preferred @@ -885,10 +888,12 @@ void Widget::OnNativeWidgetActivationChanged(bool active) { if (!active) { SaveWindowPlacement(); +#if !defined(OS_MACOSX) // Close any open menus. MenuController* menu_controller = MenuController::GetActiveInstance(); if (menu_controller) menu_controller->OnWidgetActivationChanged(); +#endif // !defined(OS_MACOSX) } FOR_EACH_OBSERVER(Observer, observers_, -- cgit v1.1