Quick fix for the broken focus changing I introduced earlier.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15096 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-23 21:52:36 +00:00
parent bb4de4057b
commit a8d44b6fea
6 changed files with 123 additions and 167 deletions
+4 -4
View File
@@ -833,25 +833,25 @@ Layer::CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset)
void void
Layer::MouseDown(const BMessage *msg) Layer::MouseDown(BMessage *msg, BPoint where)
{ {
} }
void void
Layer::MouseUp(const BMessage *msg) Layer::MouseUp(BMessage *msg, BPoint where)
{ {
} }
void void
Layer::MouseMoved(const BMessage *msg) Layer::MouseMoved(BMessage *msg, BPoint where)
{ {
} }
void void
Layer::MouseWheelChanged(const BMessage *msg) Layer::MouseWheelChanged(BMessage *msg, BPoint where)
{ {
} }
+4 -4
View File
@@ -154,10 +154,10 @@ class Layer {
int32 xOffset, int32 yOffset); int32 xOffset, int32 yOffset);
// input handling // input handling
virtual void MouseDown(const BMessage *msg); virtual void MouseDown(BMessage *msg, BPoint where);
virtual void MouseUp(const BMessage *msg); virtual void MouseUp(BMessage *msg, BPoint where);
virtual void MouseMoved(const BMessage *msg); virtual void MouseMoved(BMessage *msg, BPoint where);
virtual void MouseWheelChanged(const BMessage *msg); virtual void MouseWheelChanged(BMessage *msg, BPoint where);
virtual void WorkspaceActivated(int32 index, bool active); virtual void WorkspaceActivated(int32 index, bool active);
virtual void WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces); virtual void WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces);
+30 -67
View File
@@ -13,19 +13,11 @@
/** Class used for the top layer of each workspace's Layer tree */ /** Class used for the top layer of each workspace's Layer tree */
#include <stdio.h>
#include <Window.h>
#include <List.h>
#include <Message.h>
//#include <Entry.h>
#include <File.h>
#include <PortLink.h>
#include "Decorator.h" #include "Decorator.h"
#include "DrawingEngine.h" #include "DrawingEngine.h"
#include "HWInterface.h" #include "HWInterface.h"
#include "Layer.h" #include "Layer.h"
#include "RootLayer.h"
#include "ServerApp.h" #include "ServerApp.h"
#include "ServerConfig.h" #include "ServerConfig.h"
#include "ServerProtocol.h" #include "ServerProtocol.h"
@@ -35,7 +27,13 @@
#include "Workspace.h" #include "Workspace.h"
#include "WorkspacesLayer.h" #include "WorkspacesLayer.h"
#include "RootLayer.h" #include <File.h>
#include <List.h>
#include <Message.h>
#include <PortLink.h>
#include <Window.h>
#include <stdio.h>
#if DISPLAY_HAIKU_LOGO #if DISPLAY_HAIKU_LOGO
#include "ServerBitmap.h" #include "ServerBitmap.h"
@@ -234,20 +232,15 @@ RootLayer::AddWinBorder(WinBorder* winBorder)
// Subset modals also need to have a main window before appearing in workspace list. // Subset modals also need to have a main window before appearing in workspace list.
int32 feel = winBorder->Feel(); int32 feel = winBorder->Feel();
if (feel != B_FLOATING_SUBSET_WINDOW_FEEL && feel != B_MODAL_SUBSET_WINDOW_FEEL) if (feel != B_FLOATING_SUBSET_WINDOW_FEEL && feel != B_MODAL_SUBSET_WINDOW_FEEL) {
{ uint32 workspaces = winBorder->Workspaces();
uint32 wks = winBorder->Workspaces();
// add to current workspace // add to current workspace
if (wks == 0) if (workspaces == 0)
{
fWorkspace[fActiveWksIndex]->AddWinBorder(winBorder); fWorkspace[fActiveWksIndex]->AddWinBorder(winBorder);
} else {
// add to desired workspaces // add to desired workspaces
else for (int32 i = 0; i < fWsCount; i++) {
{ if (fWorkspace[i] && (workspaces & (0x00000001UL << i)))
for (int32 i = 0; i < fWsCount; i++)
{
if (fWorkspace[i] && (wks & (0x00000001UL << i)))
fWorkspace[i]->AddWinBorder(winBorder); fWorkspace[i]->AddWinBorder(winBorder);
} }
} }
@@ -850,29 +843,6 @@ RootLayer::SetActive(WinBorder* newActive, bool activate)
// #pragma mark - Input related methods // #pragma mark - Input related methods
void
RootLayer::_ProcessMouseMovedEvent(BMessage *msg, BPoint where, Layer* target)
{
// change focus in FFM mode
WinBorder* winBorderTarget = dynamic_cast<WinBorder*>(target);
if (winBorderTarget) {
DesktopSettings desktopSettings(fDesktop);
// TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!!
WinBorder* exFocus = Focus();
if (desktopSettings.MouseMode() != B_NORMAL_MOUSE && exFocus != winBorderTarget) {
ActiveWorkspace()->AttemptToSetFocus(winBorderTarget);
// Workspace::SetFocus() *attempts* to set a new focus WinBorder, it may not succeed
if (exFocus != Focus()) {
// TODO: invalidate border area and send message to client for the widgets to light up
// What message? Is there a message on Focus change?
}
}
}
target->MouseMoved(msg);
}
void void
RootLayer::MouseEventHandler(BMessage *event) RootLayer::MouseEventHandler(BMessage *event)
{ {
@@ -882,30 +852,23 @@ RootLayer::MouseEventHandler(BMessage *event)
Layer* layer = fMouseEventLayer; Layer* layer = fMouseEventLayer;
if (layer == NULL) { if (layer == NULL) {
if (fWMState.Focus != NULL) { layer = LayerAt(where, false);
layer = fWMState.Focus->LayerAt(where); if (layer == NULL)
if (layer != NULL) return;
event->AddInt32("_view_token", layer->ViewToken());
}
if (layer == NULL) {
layer = LayerAt(where);
if (layer == NULL)
return;
}
} }
switch (event->what) { switch (event->what) {
case B_MOUSE_DOWN: case B_MOUSE_DOWN:
layer->MouseDown(event); layer->MouseDown(event, where);
break; break;
case B_MOUSE_UP: case B_MOUSE_UP:
layer->MouseUp(event); layer->MouseUp(event, where);
SetMouseEventLayer(NULL); SetMouseEventLayer(NULL);
break; break;
case B_MOUSE_MOVED: case B_MOUSE_MOVED:
_ProcessMouseMovedEvent(event, where, layer); layer->MouseMoved(event, where);
break; break;
} }
} }
@@ -961,15 +924,15 @@ RootLayer::show_winBorder(WinBorder *winBorder)
for (int32 i = 0; i < fWsCount; i++) { for (int32 i = 0; i < fWsCount; i++) {
invalid = false; invalid = false;
if (fWorkspace[i] && if (fWorkspace[i]
(fWorkspace[i]->HasWinBorder(winBorder) || && (fWorkspace[i]->HasWinBorder(winBorder)
// subset modals are a bit like floating windows, they are being added || winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL
// and removed from workspace when there's at least a normal window // subset modals are a bit like floating windows, they are being added
// that uses them. // and removed from workspace when there's at least a normal window
winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL || // that uses them.
// floating windows are inserted/removed on-the-fly so this window, || winBorder->Level() == B_FLOATING_APP))
// although needed may not be in workspace's list. // floating windows are inserted/removed on-the-fly so this window,
winBorder->Level() == B_FLOATING_APP)) // although needed may not be in workspace's list.
{ {
invalid = fWorkspace[i]->ShowWinBorder(winBorder); invalid = fWorkspace[i]->ShowWinBorder(winBorder);
-2
View File
@@ -132,9 +132,7 @@ friend class Desktop;
void change_winBorder_feel(WinBorder *winBorder, int32 newFeel); void change_winBorder_feel(WinBorder *winBorder, int32 newFeel);
// Input related methods
void MouseEventHandler(BMessage *msg); void MouseEventHandler(BMessage *msg);
void _ProcessMouseMovedEvent(BMessage *msg, BPoint where, Layer* target);
Desktop* fDesktop; Desktop* fDesktop;
BMessage* fDragMessage; BMessage* fDragMessage;
+82 -87
View File
@@ -410,107 +410,93 @@ WinBorder::GetSizeLimits(float* minWidth, float* maxWidth,
void void
WinBorder::MouseDown(const BMessage *msg) WinBorder::MouseDown(BMessage *msg, BPoint where)
{ {
DesktopSettings desktopSettings(GetRootLayer()->GetDesktop()); // default action is to drag the WinBorder
BPoint where(0, 0); Layer *target = LayerAt(where);
if (target == this) {
// clicking WinBorder visible area
msg->FindPoint("where", &where); click_type action = DEC_DRAG;
// not in FFM mode? if (fDecorator)
if (desktopSettings.MouseMode() == B_NORMAL_MOUSE) { action = _ActionFor(msg);
// default action is to drag the WinBorder
Layer *target = LayerAt(where);
if (target == this) {
// clicking WinBorder visible area
winBorderAreaHandle:
click_type action = DEC_DRAG; // deactivate border buttons on first click(select)
if (GetRootLayer()->Focus() != this && action != DEC_MOVETOBACK
&& action != DEC_RESIZE && action != DEC_SLIDETAB)
action = DEC_DRAG;
if (fDecorator) // set decorator internals
action = _ActionFor(msg); switch (action) {
case DEC_CLOSE:
fIsClosing = true;
fDecorator->SetClose(true);
STRACE_CLICK(("===> DEC_CLOSE\n"));
break;
// deactivate border buttons on first click(select) case DEC_ZOOM:
if (GetRootLayer()->Focus() != this && action != DEC_MOVETOBACK fIsZooming = true;
&& action != DEC_RESIZE && action != DEC_SLIDETAB) fDecorator->SetZoom(true);
action = DEC_DRAG; STRACE_CLICK(("===> DEC_ZOOM\n"));
break;
// set decorator internals case DEC_MINIMIZE:
switch (action) { fIsMinimizing = true;
case DEC_CLOSE: fDecorator->SetMinimize(true);
fIsClosing = true; STRACE_CLICK(("===> DEC_MINIMIZE\n"));
fDecorator->SetClose(true); break;
STRACE_CLICK(("===> DEC_CLOSE\n"));
break;
case DEC_ZOOM:
fIsZooming = true;
fDecorator->SetZoom(true);
STRACE_CLICK(("===> DEC_ZOOM\n"));
break;
case DEC_MINIMIZE:
fIsMinimizing = true;
fDecorator->SetMinimize(true);
STRACE_CLICK(("===> DEC_MINIMIZE\n"));
break;
case DEC_DRAG: case DEC_DRAG:
fIsDragging = true; fIsDragging = true;
fLastMousePosition = where; fLastMousePosition = where;
STRACE_CLICK(("===> DEC_DRAG\n")); STRACE_CLICK(("===> DEC_DRAG\n"));
break; break;
case DEC_RESIZE: case DEC_RESIZE:
fIsResizing = true; fIsResizing = true;
fLastMousePosition = where; fLastMousePosition = where;
STRACE_CLICK(("===> DEC_RESIZE\n")); STRACE_CLICK(("===> DEC_RESIZE\n"));
break; break;
case DEC_SLIDETAB: case DEC_SLIDETAB:
fIsSlidingTab = true; fIsSlidingTab = true;
fLastMousePosition = where; fLastMousePosition = where;
STRACE_CLICK(("===> DEC_SLIDETAB\n")); STRACE_CLICK(("===> DEC_SLIDETAB\n"));
break; break;
default: default:
break; break;
} }
// based on what the Decorator returned, properly place this window. // based on what the Decorator returned, properly place this window.
if (action == DEC_MOVETOBACK) { if (action == DEC_MOVETOBACK) {
GetRootLayer()->SetActive(this, false); GetRootLayer()->SetActive(this, false);
} else { } else {
GetRootLayer()->SetMouseEventLayer(this); GetRootLayer()->SetMouseEventLayer(this);
GetRootLayer()->SetActive(this);
}
} else if (target != NULL) {
// clicking a simple Layer.
if (GetRootLayer()->ActiveWorkspace()->Active() != this) {
DesktopSettings desktopSettings(GetRootLayer()->GetDesktop());
// not in FFM mode?
if (desktopSettings.MouseMode() == B_NORMAL_MOUSE)
GetRootLayer()->SetActive(this); GetRootLayer()->SetActive(this);
}
} else if (target != NULL) { if ((WindowFlags() & B_WILL_ACCEPT_FIRST_CLICK) == 0)
// clicking a simple Layer. return;
if (GetRootLayer()->ActiveWorkspace()->Active() == this) {
target->MouseDown(msg);
} else {
if (WindowFlags() & B_WILL_ACCEPT_FIRST_CLICK)
target->MouseDown(msg);
else
GetRootLayer()->SetActive(this);
}
}
} else {
// in FFM mode
Layer *target = LayerAt(where);
if (target == this) {
// clicking inside our visible area.
goto winBorderAreaHandle;
} else if (target != NULL) {
// clicking a simple Layer; forward event.
target->MouseDown(msg);
} }
msg->AddInt32("_view_token", target->ViewToken());
target->MouseDown(msg, where);
} }
} }
void void
WinBorder::MouseUp(const BMessage *msg) WinBorder::MouseUp(BMessage *msg, BPoint where)
{ {
bool invalidate = false; bool invalidate = false;
if (fDecorator) { if (fDecorator) {
@@ -552,12 +538,8 @@ WinBorder::MouseUp(const BMessage *msg)
void void
WinBorder::MouseMoved(const BMessage *msg) WinBorder::MouseMoved(BMessage *msg, BPoint where)
{ {
BPoint where(0,0);
msg->FindPoint("where", &where);
if (fDecorator) { if (fDecorator) {
// TODO: present behavior is not fine! // TODO: present behavior is not fine!
// Decorator's Set*() methods _actualy draw_! on screen, not // Decorator's Set*() methods _actualy draw_! on screen, not
@@ -586,6 +568,19 @@ WinBorder::MouseMoved(const BMessage *msg)
} }
fLastMousePosition = where; fLastMousePosition = where;
// change focus in FFM mode
DesktopSettings desktopSettings(GetRootLayer()->GetDesktop());
// TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!!
WinBorder* exFocus = GetRootLayer()->Focus();
if (desktopSettings.MouseMode() != B_NORMAL_MOUSE && exFocus != this) {
GetRootLayer()->ActiveWorkspace()->AttemptToSetFocus(this);
// Workspace::SetFocus() *attempts* to set a new focus WinBorder, it may not succeed
// if (exFocus != Focus()) {
// TODO: invalidate border area and send message to client for the widgets to light up
// What message? Is there a message on Focus change?
// }
}
} }
+3 -3
View File
@@ -81,9 +81,9 @@ class WinBorder : public Layer {
float* minHeight, float* minHeight,
float* maxHeight) const; float* maxHeight) const;
virtual void MouseDown(const BMessage *msg); virtual void MouseDown(BMessage *msg, BPoint where);
virtual void MouseUp(const BMessage *msg); virtual void MouseUp(BMessage *msg, BPoint where);
virtual void MouseMoved(const BMessage *msg); virtual void MouseMoved(BMessage *msg, BPoint where);
// click_type ActionFor(const BMessage *msg) // click_type ActionFor(const BMessage *msg)
// { return _ActionFor(evt); } // { return _ActionFor(evt); }