* Implemented changing the "click to focus" mode as suggested in ticket #6419.

* It feels much better, but maybe raising the window should only happen on the
  second click instead?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-08-04 08:11:32 +00:00
parent 2248e30f11
commit f91f6b6285
+28 -40
View File
@@ -20,7 +20,6 @@
//#define DEBUG_WINDOW_CLICK //#define DEBUG_WINDOW_CLICK
#ifdef DEBUG_WINDOW_CLICK #ifdef DEBUG_WINDOW_CLICK
# define STRACE_CLICK(x) printf x # define STRACE_CLICK(x) printf x
#else #else
@@ -28,6 +27,9 @@
#endif #endif
static const bigtime_t kWindowActivationTimeout = 500000LL;
DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window) DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
: :
fWindow(window), fWindow(window),
@@ -49,31 +51,27 @@ DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
DefaultWindowBehaviour::~DefaultWindowBehaviour() DefaultWindowBehaviour::~DefaultWindowBehaviour()
{ {
} }
static const bigtime_t kWindowActivationTimeout = 500000LL;
bool bool
DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where) DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
{ {
Decorator* decorator = fWindow->Decorator(); Decorator* decorator = fWindow->Decorator();
int32 modifiers = _ExtractModifiers(message);
bool inBorderRegion = false; bool inBorderRegion = false;
if (fWindow->Decorator()) if (decorator != NULL)
inBorderRegion = decorator->GetFootprint().Contains(where); inBorderRegion = decorator->GetFootprint().Contains(where);
bool windowModifier =
(fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0 int32 modifiers = _ExtractModifiers(message);
bool windowModifier
= (fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY && (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
| B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY); | B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
click_type action = CLICK_NONE; click_type action = CLICK_NONE;
if (windowModifier || inBorderRegion) { if (windowModifier || inBorderRegion) {
// clicking Window visible area // Click on the window border or we have the window modifier keys held
int32 buttons = _ExtractButtons(message); int32 buttons = _ExtractButtons(message);
if (inBorderRegion) if (inBorderRegion)
@@ -91,8 +89,12 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
} }
} }
if (!windowModifier && !inBorderRegion) {
// This is a click inside the window's contents
return false;
}
DesktopSettings desktopSettings(fDesktop); DesktopSettings desktopSettings(fDesktop);
if (windowModifier || inBorderRegion) {
if (!desktopSettings.AcceptFirstClick()) { if (!desktopSettings.AcceptFirstClick()) {
// Ignore clicks on decorator buttons if the // Ignore clicks on decorator buttons if the
// non-floating window doesn't have focus // non-floating window doesn't have focus
@@ -165,22 +167,9 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
fWindow->RegionPool()->Recycle(visibleBorder); fWindow->RegionPool()->Recycle(visibleBorder);
} }
if (action == CLICK_MOVE_TO_BACK) { if (action == CLICK_MOVE_TO_BACK)
if (desktopSettings.MouseMode() == B_CLICK_TO_FOCUS_MOUSE) {
bool covered = true;
BRegion fullRegion;
fWindow->GetFullRegion(&fullRegion);
if (fullRegion == fWindow->VisibleRegion()) {
// window is overlapped.
covered = false;
}
if (fWindow != fDesktop->FrontWindow() && covered)
fDesktop->ActivateWindow(fWindow);
else
fDesktop->SendWindowBehind(fWindow); fDesktop->SendWindowBehind(fWindow);
} else else {
fDesktop->SendWindowBehind(fWindow);
} else {
fDesktop->SetMouseEventWindow(fWindow); fDesktop->SetMouseEventWindow(fWindow);
// activate window if in click to activate mode, else only focus it // activate window if in click to activate mode, else only focus it
@@ -188,8 +177,8 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
fDesktop->ActivateWindow(fWindow); fDesktop->ActivateWindow(fWindow);
else { else {
fDesktop->SetFocusWindow(fWindow); fDesktop->SetFocusWindow(fWindow);
if (desktopSettings.MouseMode() == B_FOCUS_FOLLOWS_MOUSE
&& (action == CLICK_DRAG || action == CLICK_RESIZE)) { if (action == CLICK_DRAG || action == CLICK_RESIZE) {
fActivateOnMouseUp = true; fActivateOnMouseUp = true;
fMouseMoveDistance = 0.0f; fMouseMoveDistance = 0.0f;
fLastMoveTime = system_time(); fLastMoveTime = system_time();
@@ -199,8 +188,6 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
return true; return true;
} }
return false;
}
void void
@@ -209,7 +196,9 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
Decorator* decorator = fWindow->Decorator(); Decorator* decorator = fWindow->Decorator();
bool invalidate = false; bool invalidate = false;
if (decorator) { // TODO: not used - can it be removed?
if (decorator != NULL) {
click_type action = _ActionFor(message); click_type action = _ActionFor(message);
// redraw decorator // redraw decorator
@@ -411,9 +400,10 @@ int32
DefaultWindowBehaviour::_ExtractButtons(const BMessage* message) const DefaultWindowBehaviour::_ExtractButtons(const BMessage* message) const
{ {
int32 buttons; int32 buttons;
if (message->FindInt32("buttons", &buttons) != B_OK) if (message->FindInt32("buttons", &buttons) == B_OK)
buttons = 0;
return buttons; return buttons;
return 0;
} }
@@ -421,18 +411,17 @@ int32
DefaultWindowBehaviour::_ExtractModifiers(const BMessage* message) const DefaultWindowBehaviour::_ExtractModifiers(const BMessage* message) const
{ {
int32 modifiers; int32 modifiers;
if (message->FindInt32("modifiers", &modifiers) != B_OK) if (message->FindInt32("modifiers", &modifiers) == B_OK)
modifiers = 0;
return modifiers; return modifiers;
return 0;
} }
click_type click_type
DefaultWindowBehaviour::_ActionFor(const BMessage* message) const DefaultWindowBehaviour::_ActionFor(const BMessage* message) const
{ {
Decorator* decorator = fWindow->Decorator(); if (fWindow->Decorator() == NULL)
if (decorator == NULL)
return CLICK_NONE; return CLICK_NONE;
int32 buttons = _ExtractButtons(message); int32 buttons = _ExtractButtons(message);
@@ -446,7 +435,6 @@ DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons,
int32 modifiers) const int32 modifiers) const
{ {
Decorator* decorator = fWindow->Decorator(); Decorator* decorator = fWindow->Decorator();
if (decorator == NULL) if (decorator == NULL)
return CLICK_NONE; return CLICK_NONE;