| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ui/app_list/cocoa/app_list_window_controller.h" | |
| 6 | |
| 7 #include "ui/app_list/app_list_view_delegate.h" | |
| 8 #import "ui/app_list/cocoa/app_list_view_controller.h" | |
| 9 #import "ui/app_list/cocoa/apps_grid_controller.h" | |
| 10 #import "ui/app_list/cocoa/apps_search_box_controller.h" | |
| 11 #include "ui/base/cocoa/window_size_constants.h" | |
| 12 | |
| 13 @interface AppListWindow : NSWindow; | |
| 14 @end | |
| 15 | |
| 16 @implementation AppListWindow | |
| 17 | |
| 18 // If we initialize a window with NSBorderlessWindowMask, it will not accept key | |
| 19 // events (among other things) unless canBecomeKeyWindow is overridden. | |
| 20 - (BOOL)canBecomeKeyWindow { | |
| 21 return YES; | |
| 22 } | |
| 23 | |
| 24 - (BOOL)canBecomeMainWindow { | |
| 25 return YES; | |
| 26 } | |
| 27 | |
| 28 // On Mavericks with the "Displays have separate Spaces" option, OSX has stopped | |
| 29 // switching out of the fullscreen space when activating a window in the non- | |
| 30 // active application, other than by clicking its Dock icon. Since the app | |
| 31 // launcher Dock icon is not Chrome, this can leave a user in fullscreen with | |
| 32 // the app launcher window obscured. Overriding this private method allows the | |
| 33 // app launcher to appear on top of other applications in fullscreen. Then, | |
| 34 // since clicking that window will make Chrome active, subsequent window | |
| 35 // activations will successfully switch the user out of the fullscreen space. | |
| 36 - (BOOL)_allowedInOtherAppsFullScreenSpaceWithCollectionBehavior: | |
| 37 (NSUInteger)collectionBehavior { | |
| 38 return YES; | |
| 39 } | |
| 40 | |
| 41 @end | |
| 42 | |
| 43 @implementation AppListWindowController; | |
| 44 | |
| 45 - (id)init { | |
| 46 base::scoped_nsobject<NSWindow> controlledWindow( | |
| 47 [[AppListWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater | |
| 48 styleMask:NSBorderlessWindowMask | |
| 49 backing:NSBackingStoreBuffered | |
| 50 defer:NO]); | |
| 51 [controlledWindow setReleasedWhenClosed:NO]; | |
| 52 [controlledWindow setBackgroundColor:[NSColor clearColor]]; | |
| 53 [controlledWindow setOpaque:NO]; | |
| 54 [controlledWindow setHasShadow:YES]; | |
| 55 [controlledWindow setLevel:NSDockWindowLevel]; | |
| 56 [controlledWindow | |
| 57 setCollectionBehavior:NSWindowCollectionBehaviorMoveToActiveSpace]; | |
| 58 | |
| 59 if ((self = [super initWithWindow:controlledWindow])) { | |
| 60 appListViewController_.reset([[AppListViewController alloc] init]); | |
| 61 [[self window] setFrame:[[appListViewController_ view] bounds] | |
| 62 display:NO]; | |
| 63 [[self window] setContentView:[appListViewController_ view]]; | |
| 64 [[self window] setDelegate:self]; | |
| 65 } | |
| 66 return self; | |
| 67 } | |
| 68 | |
| 69 - (AppListViewController*)appListViewController { | |
| 70 return appListViewController_; | |
| 71 } | |
| 72 | |
| 73 - (void)windowDidResignMain:(NSNotification*)notification { | |
| 74 if ([appListViewController_ delegate]) | |
| 75 [appListViewController_ delegate]->Dismiss(); | |
| 76 } | |
| 77 | |
| 78 - (void)windowWillClose:(NSNotification*)notification { | |
| 79 [[appListViewController_ searchBoxController] clearSearch]; | |
| 80 } | |
| 81 | |
| 82 @end | |
| OLD | NEW |