* 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:
@@ -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);
|
||||||
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
|
bool windowModifier
|
||||||
| B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
|
= (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;
|
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,115 +89,104 @@ 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
|
if (!fWindow->IsFocus() && !fWindow->IsFloating()
|
||||||
if (!fWindow->IsFocus() && !fWindow->IsFloating()
|
&& action != CLICK_MOVE_TO_BACK
|
||||||
&& action != CLICK_MOVE_TO_BACK
|
&& action != CLICK_RESIZE && action != CLICK_SLIDE_TAB)
|
||||||
&& action != CLICK_RESIZE && action != CLICK_SLIDE_TAB)
|
action = CLICK_DRAG;
|
||||||
action = CLICK_DRAG;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set decorator internals
|
// set decorator internals
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case CLICK_CLOSE:
|
case CLICK_CLOSE:
|
||||||
fIsClosing = true;
|
fIsClosing = true;
|
||||||
STRACE_CLICK(("===> CLICK_CLOSE\n"));
|
STRACE_CLICK(("===> CLICK_CLOSE\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLICK_ZOOM:
|
case CLICK_ZOOM:
|
||||||
fIsZooming = true;
|
fIsZooming = true;
|
||||||
STRACE_CLICK(("===> CLICK_ZOOM\n"));
|
STRACE_CLICK(("===> CLICK_ZOOM\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLICK_MINIMIZE:
|
case CLICK_MINIMIZE:
|
||||||
if ((fWindow->Flags() & B_NOT_MINIMIZABLE) == 0) {
|
if ((fWindow->Flags() & B_NOT_MINIMIZABLE) == 0) {
|
||||||
fIsMinimizing = true;
|
fIsMinimizing = true;
|
||||||
STRACE_CLICK(("===> CLICK_MINIMIZE\n"));
|
STRACE_CLICK(("===> CLICK_MINIMIZE\n"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLICK_DRAG:
|
case CLICK_DRAG:
|
||||||
fIsDragging = true;
|
fIsDragging = true;
|
||||||
fLastMousePosition = where;
|
fLastMousePosition = where;
|
||||||
STRACE_CLICK(("===> CLICK_DRAG\n"));
|
STRACE_CLICK(("===> CLICK_DRAG\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLICK_RESIZE:
|
case CLICK_RESIZE:
|
||||||
fIsResizing = true;
|
fIsResizing = true;
|
||||||
fLastMousePosition = where;
|
fLastMousePosition = where;
|
||||||
STRACE_CLICK(("===> CLICK_RESIZE\n"));
|
STRACE_CLICK(("===> CLICK_RESIZE\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLICK_SLIDE_TAB:
|
case CLICK_SLIDE_TAB:
|
||||||
fIsSlidingTab = true;
|
fIsSlidingTab = true;
|
||||||
fLastMousePosition = where;
|
fLastMousePosition = where;
|
||||||
STRACE_CLICK(("===> CLICK_SLIDE_TAB\n"));
|
STRACE_CLICK(("===> CLICK_SLIDE_TAB\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decorator != NULL) {
|
if (decorator != NULL) {
|
||||||
// redraw decorator
|
// redraw decorator
|
||||||
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
|
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
|
||||||
fWindow->GetBorderRegion(visibleBorder);
|
fWindow->GetBorderRegion(visibleBorder);
|
||||||
visibleBorder->IntersectWith(&fWindow->VisibleRegion());
|
visibleBorder->IntersectWith(&fWindow->VisibleRegion());
|
||||||
|
|
||||||
DrawingEngine* engine = decorator->GetDrawingEngine();
|
DrawingEngine* engine = decorator->GetDrawingEngine();
|
||||||
engine->LockParallelAccess();
|
engine->LockParallelAccess();
|
||||||
engine->ConstrainClippingRegion(visibleBorder);
|
engine->ConstrainClippingRegion(visibleBorder);
|
||||||
|
|
||||||
if (fIsZooming)
|
if (fIsZooming)
|
||||||
decorator->SetZoom(true);
|
decorator->SetZoom(true);
|
||||||
else if (fIsClosing)
|
else if (fIsClosing)
|
||||||
decorator->SetClose(true);
|
decorator->SetClose(true);
|
||||||
else if (fIsMinimizing)
|
else if (fIsMinimizing)
|
||||||
decorator->SetMinimize(true);
|
decorator->SetMinimize(true);
|
||||||
|
|
||||||
engine->UnlockParallelAccess();
|
engine->UnlockParallelAccess();
|
||||||
|
|
||||||
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) {
|
fDesktop->SendWindowBehind(fWindow);
|
||||||
bool covered = true;
|
else {
|
||||||
BRegion fullRegion;
|
fDesktop->SetMouseEventWindow(fWindow);
|
||||||
fWindow->GetFullRegion(&fullRegion);
|
|
||||||
if (fullRegion == fWindow->VisibleRegion()) {
|
|
||||||
// window is overlapped.
|
|
||||||
covered = false;
|
|
||||||
}
|
|
||||||
if (fWindow != fDesktop->FrontWindow() && covered)
|
|
||||||
fDesktop->ActivateWindow(fWindow);
|
|
||||||
else
|
|
||||||
fDesktop->SendWindowBehind(fWindow);
|
|
||||||
} else
|
|
||||||
fDesktop->SendWindowBehind(fWindow);
|
|
||||||
} else {
|
|
||||||
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
|
||||||
if (desktopSettings.MouseMode() == B_NORMAL_MOUSE)
|
if (desktopSettings.MouseMode() == B_NORMAL_MOUSE)
|
||||||
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();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user