* 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:
parent
2248e30f11
commit
f91f6b6285
|
@ -20,7 +20,6 @@
|
|||
|
||||
|
||||
//#define DEBUG_WINDOW_CLICK
|
||||
|
||||
#ifdef DEBUG_WINDOW_CLICK
|
||||
# define STRACE_CLICK(x) printf x
|
||||
#else
|
||||
|
@ -28,6 +27,9 @@
|
|||
#endif
|
||||
|
||||
|
||||
static const bigtime_t kWindowActivationTimeout = 500000LL;
|
||||
|
||||
|
||||
DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
|
||||
:
|
||||
fWindow(window),
|
||||
|
@ -49,31 +51,27 @@ DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
|
|||
|
||||
DefaultWindowBehaviour::~DefaultWindowBehaviour()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static const bigtime_t kWindowActivationTimeout = 500000LL;
|
||||
|
||||
|
||||
bool
|
||||
DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||
{
|
||||
Decorator* decorator = fWindow->Decorator();
|
||||
|
||||
int32 modifiers = _ExtractModifiers(message);
|
||||
bool inBorderRegion = false;
|
||||
if (fWindow->Decorator())
|
||||
if (decorator != NULL)
|
||||
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
|
||||
| B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
|
||||
click_type action = CLICK_NONE;
|
||||
|
||||
if (windowModifier || inBorderRegion) {
|
||||
// clicking Window visible area
|
||||
|
||||
// Click on the window border or we have the window modifier keys held
|
||||
int32 buttons = _ExtractButtons(message);
|
||||
|
||||
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);
|
||||
if (windowModifier || inBorderRegion) {
|
||||
if (!desktopSettings.AcceptFirstClick()) {
|
||||
// Ignore clicks on decorator buttons if the
|
||||
// non-floating window doesn't have focus
|
||||
|
@ -165,22 +167,9 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
|||
fWindow->RegionPool()->Recycle(visibleBorder);
|
||||
}
|
||||
|
||||
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
|
||||
if (action == CLICK_MOVE_TO_BACK)
|
||||
fDesktop->SendWindowBehind(fWindow);
|
||||
} else
|
||||
fDesktop->SendWindowBehind(fWindow);
|
||||
} else {
|
||||
else {
|
||||
fDesktop->SetMouseEventWindow(fWindow);
|
||||
|
||||
// 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);
|
||||
else {
|
||||
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;
|
||||
fMouseMoveDistance = 0.0f;
|
||||
fLastMoveTime = system_time();
|
||||
|
@ -199,8 +188,6 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
|||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
@ -209,7 +196,9 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
|
|||
Decorator* decorator = fWindow->Decorator();
|
||||
|
||||
bool invalidate = false;
|
||||
if (decorator) {
|
||||
// TODO: not used - can it be removed?
|
||||
|
||||
if (decorator != NULL) {
|
||||
click_type action = _ActionFor(message);
|
||||
|
||||
// redraw decorator
|
||||
|
@ -411,9 +400,10 @@ int32
|
|||
DefaultWindowBehaviour::_ExtractButtons(const BMessage* message) const
|
||||
{
|
||||
int32 buttons;
|
||||
if (message->FindInt32("buttons", &buttons) != B_OK)
|
||||
buttons = 0;
|
||||
if (message->FindInt32("buttons", &buttons) == B_OK)
|
||||
return buttons;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -421,18 +411,17 @@ int32
|
|||
DefaultWindowBehaviour::_ExtractModifiers(const BMessage* message) const
|
||||
{
|
||||
int32 modifiers;
|
||||
if (message->FindInt32("modifiers", &modifiers) != B_OK)
|
||||
modifiers = 0;
|
||||
if (message->FindInt32("modifiers", &modifiers) == B_OK)
|
||||
return modifiers;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
click_type
|
||||
DefaultWindowBehaviour::_ActionFor(const BMessage* message) const
|
||||
{
|
||||
Decorator* decorator = fWindow->Decorator();
|
||||
|
||||
if (decorator == NULL)
|
||||
if (fWindow->Decorator() == NULL)
|
||||
return CLICK_NONE;
|
||||
|
||||
int32 buttons = _ExtractButtons(message);
|
||||
|
@ -446,7 +435,6 @@ DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons,
|
|||
int32 modifiers) const
|
||||
{
|
||||
Decorator* decorator = fWindow->Decorator();
|
||||
|
||||
if (decorator == NULL)
|
||||
return CLICK_NONE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue