Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 10106008: Change Panel titlebars to activate the panel on click (rather than minimize). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_window_controller_cocoa.mm
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
index 4acf8259e7146d0876ef8f4c3f69416fe6821f53..c33af17214a1292560d32b4a10197c88f248d862 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
@@ -6,13 +6,11 @@
#import <Cocoa/Cocoa.h>
-#include "base/auto_reset.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/sys_string_conversions.h"
-#include "base/time.h"
#include "chrome/app/chrome_command_ids.h" // IDC_*
#include "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/browser/profiles/profile.h"
@@ -36,8 +34,6 @@
#import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
#import "chrome/browser/ui/panels/panel_utils_cocoa.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "grit/ui_resources.h"
@@ -84,12 +80,21 @@ enum {
}
// Prevent panel window from becoming key - for example when it is minimized.
+// Panel windows use a higher priority NSWindowLevel to ensure they are always
+// visible, causing the OS to prefer panel windows when selecting a window
+// to make the key window. To counter this preference, we override
+// -[NSWindow:canBecomeKeyWindow] to restrict when the panel can become the
+// key window to a limited set of scenarios, such as when cycling through
+// windows, when panels are the only remaining windows, when an event
+// triggers window activation, etc. The panel may also be prevented from
+// becoming the key window, regardless of the above scenarios, such as when
+// a panel is minimized.
- (BOOL)canBecomeKeyWindow {
// Give precedence to controller preventing activation of the window.
PanelWindowControllerCocoa* controller =
base::mac::ObjCCast<PanelWindowControllerCocoa>([self windowController]);
if (![controller canBecomeKeyWindow])
- return false;
+ return NO;
BrowserCrApplication* app = base::mac::ObjCCast<BrowserCrApplication>(
[BrowserCrApplication sharedApplication]);
@@ -97,18 +102,12 @@ enum {
// A Panel window can become the key window only in limited scenarios.
// This prevents the system from always preferring a Panel window due
// to its higher priority NSWindowLevel when selecting a window to make key.
- return canBecomeKey_ ||
+ return ([app isHandlingSendEvent] && [[app currentEvent] window] == self) ||
[controller activationRequestedByBrowser] ||
[app isCyclingWindows] ||
[app previousKeyWindow] == self ||
[[app windows] count] == static_cast<NSUInteger>([controller numPanels]);
}
-
-- (void)sendEvent:(NSEvent*)anEvent {
- // Allow the panel to become key in response to a mouse click.
- AutoReset<BOOL> pin(&canBecomeKey_, YES);
- [super sendEvent:anEvent];
-}
@end
// Transparent view covering the whole panel in order to intercept mouse
@@ -858,29 +857,8 @@ enum {
- (void)onTitlebarMouseClicked:(int)modifierFlags {
Panel* panel = windowShim_->panel();
- if (modifierFlags & NSShiftKeyMask) {
- panel->OnTitlebarClicked(panel::APPLY_TO_ALL);
- return;
- }
-
- // TODO(jennb): Move remaining titlebar click handling out of here.
- // (http://crbug.com/118431)
- PanelStrip* panelStrip = panel->panel_strip();
- if (!panelStrip)
- return;
- if (panelStrip->type() == PanelStrip::DOCKED &&
- panel->expansion_state() == Panel::EXPANDED) {
- if ([[self titlebarView] isDrawingAttention]) {
- // Do not minimize if the Panel is drawing attention since user
- // most likely simply wants to reset the 'draw attention' status.
- panel->Activate();
- return;
- }
- panel->SetExpansionState(Panel::MINIMIZED);
- // The Panel class ensures deactivation when it is minimized.
- } else {
- panel->Activate();
- }
+ panel->OnTitlebarClicked((modifierFlags & NSShiftKeyMask) ?
+ panel::APPLY_TO_ALL : panel::NO_MODIFIER);
}
- (int)titlebarHeightInScreenCoordinates {
@@ -913,18 +891,7 @@ enum {
rwhv->SetActive(true);
}
- // If the window becomes key, lets make sure it is expanded and stop
- // drawing attention - since it is ready to accept input, it already has
- // user's attention.
- if ([[self titlebarView] isDrawingAttention]) {
- [[self titlebarView] stopDrawingAttention];
- }
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
- content::Source<Panel>(windowShim_->panel()),
- content::NotificationService::NoDetails());
- windowShim_->panel()->OnActiveStateChanged();
+ windowShim_->panel()->OnActiveStateChanged(true);
}
- (void)windowDidResignKey:(NSNotification*)notification {
@@ -943,11 +910,7 @@ enum {
rwhv->SetActive(false);
}
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
- content::Source<Panel>(windowShim_->panel()),
- content::NotificationService::NoDetails());
- windowShim_->panel()->OnActiveStateChanged();
+ windowShim_->panel()->OnActiveStateChanged(false);
}
- (void)deactivate {
@@ -1034,8 +997,4 @@ enum {
[[self window] invalidateCursorRectsForView:overlayView_];
}
-- (BOOL)isActivationByClickingTitlebarEnabled {
- return !windowShim_->panel()->always_on_top();
-}
-
@end
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698