* added Layer/WinBorder::WorkspaceChanged() hook.

* make RootLayer::SetWinBorderWorkspaces() work under NEW_INPUT_HANDLING
define. Soon I think I'll move this method under WinBorder's hood.
* RootLayer::change_winBorder_feel() is also working under this define

** NEW_INPUT_HANDLING define is active.
   If someone discovers something bad happening after this checkin please
notify me on app_server list. If in one week no major problems appear,
I'll remove this define and the old code.
   Thanks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14288 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2005-10-01 10:03:43 +00:00
parent a7c2985541
commit bbf8c95b5a
6 changed files with 85 additions and 60 deletions
+6
View File
@@ -1155,6 +1155,12 @@ Layer::WorkspaceActivated(int32 index, bool active)
{ {
// Empty // Empty
} }
void
Layer::WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces)
{
// Empty
}
#endif #endif
// BoundsOrigin // BoundsOrigin
BPoint BPoint
+2 -1
View File
@@ -42,7 +42,7 @@
#include "ServerWindow.h" #include "ServerWindow.h"
//#define NEW_CLIPPING 1 //#define NEW_CLIPPING 1
//#define NEW_INPUT_HANDLING 1 #define NEW_INPUT_HANDLING 1
enum { enum {
B_LAYER_NONE = 1, B_LAYER_NONE = 1,
@@ -170,6 +170,7 @@ class Layer {
virtual void MouseUp(const PointerEvent& evt); virtual void MouseUp(const PointerEvent& evt);
virtual void MouseMoved(const PointerEvent& evt, uint32 transit); virtual void MouseMoved(const PointerEvent& evt, uint32 transit);
virtual void WorkspaceActivated(int32 index, bool active); virtual void WorkspaceActivated(int32 index, bool active);
virtual void WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces);
#endif #endif
BPoint BoundsOrigin() const; // BoundsFrameDiff()? BPoint BoundsOrigin() const; // BoundsFrameDiff()?
float Scale() const; float Scale() const;
+58 -54
View File
@@ -756,10 +756,11 @@ bool RootLayer::SetActiveWorkspace(int32 index)
if (ptrWin[i]->Workspaces() & (0x00000001UL << index)) { if (ptrWin[i]->Workspaces() & (0x00000001UL << index)) {
fWorkspace[index]->AddWinBorder(ptrWin[i]); fWorkspace[index]->AddWinBorder(ptrWin[i]);
if (!ptrWin[i]->IsHidden()) if (!ptrWin[i]->IsHidden()) {
fWorkspace[index]->ShowWinBorder(ptrWin[i]); fWorkspace[index]->ShowWinBorder(ptrWin[i]);
} }
} }
}
fDesktop->Unlock(); fDesktop->Unlock();
} }
@@ -914,19 +915,30 @@ bool RootLayer::SetActiveWorkspace(int32 index)
void void
RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldWksIndex, uint32 newWksIndex) RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldIndex, uint32 newIndex)
{ {
#ifdef NEW_INPUT_HANDLING // if the active notify Layer is somehow related to winBorder, then
printf("RootLayer::SetWinBorderWorskpaces() UNIMPLEMENTED\n"); // this window/WinBorder is not allowed to leave this workspace.
return; if (fNotifyLayer && (fNotifyLayer == winBorder || fNotifyLayer->Owner() == winBorder)) {
#endif newIndex |= (0x00000001UL << fActiveWksIndex);
// you *cannot* set workspaces index for a window other than a normal one! }
// Note: See ServerWindow class.
if (winBorder->Feel() != B_NORMAL_WINDOW_FEEL)
return;
uint32 localOldIndex = oldIndex;
uint32 localNewIndex = newIndex;
bool invalidate = false; bool invalidate = false;
bool invalid; bool invalid;
// if we're in the current workspace only, reflect that in the workspace index
if (localOldIndex == 0UL)
localOldIndex |= (0x00000001UL << fActiveWksIndex);
if (localNewIndex == 0UL)
localNewIndex |= (0x00000001UL << fActiveWksIndex);
// you *cannot* set workspaces index for a window other than a normal one!
// Note: See ServerWindow class.
if (winBorder->Feel() != B_NORMAL_WINDOW_FEEL || localOldIndex == localNewIndex)
return;
#ifndef NEW_INPUT_HANDLING #ifndef NEW_INPUT_HANDLING
WinBorder* exFocus = Focus(); WinBorder* exFocus = Focus();
WinBorder* exActive = Active(); WinBorder* exActive = Active();
@@ -939,8 +951,7 @@ RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldWksIndex, uint
if (fWorkspace[i]) { if (fWorkspace[i]) {
invalid = false; invalid = false;
if (fWorkspace[i]->HasWinBorder(winBorder) if (!(localNewIndex & (0x00000001UL << i)) && fWorkspace[i]->HasWinBorder(winBorder)) {
&& !(newWksIndex & (0x00000001UL << i))) {
if (!winBorder->IsHidden()) { if (!winBorder->IsHidden()) {
// a little trick to force Workspace to properly pick the next front. // a little trick to force Workspace to properly pick the next front.
winBorder->fHidden = true; winBorder->fHidden = true;
@@ -948,14 +959,12 @@ RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldWksIndex, uint
winBorder->fHidden = false; winBorder->fHidden = false;
} }
fWorkspace[i]->RemoveWinBorder(winBorder); fWorkspace[i]->RemoveWinBorder(winBorder);
} else if (newWksIndex & (0x00000001UL << i) }
&& !(oldWksIndex & (0x00000001UL << i))) {
if ((localNewIndex & (0x00000001UL << i)) && !fWorkspace[i]->HasWinBorder(winBorder)) {
fWorkspace[i]->AddWinBorder(winBorder); fWorkspace[i]->AddWinBorder(winBorder);
if (!winBorder->IsHidden()) if (!winBorder->IsHidden())
invalid = fWorkspace[i]->ShowWinBorder(winBorder); invalid = fWorkspace[i]->ShowWinBorder(winBorder);
} else {
// do nothing. winBorder was, and it still is a member of this workspace
// OR, winBorder wasn't and it will not be in this workspace
} }
if (fActiveWksIndex == i) if (fActiveWksIndex == i)
@@ -963,29 +972,16 @@ RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldWksIndex, uint
} }
} }
// TODO: look into this... #ifndef NEW_INPUT_HANDLING
if (fNotifyLayer) {
WinBorder* wb = fNotifyLayer->fOwner ?
fNotifyLayer->fOwner : (WinBorder*)fNotifyLayer;
if (!fWorkspace[fActiveWksIndex]->HasWinBorder(wb)) {
/* if (wb == fNotifyLayer)
{
fMovingWindow = false;
fResizingWindow = false;
wb->MouseUp(DEC_NONE);
}*/
fNotifyLayer = NULL;
}
}
BMessage changedMsg(B_WORKSPACES_CHANGED); BMessage changedMsg(B_WORKSPACES_CHANGED);
changedMsg.AddInt64("when", real_time_clock_usecs()); changedMsg.AddInt64("when", real_time_clock_usecs());
changedMsg.AddInt32("old", oldWksIndex); changedMsg.AddInt32("old", oldIndex);
changedMsg.AddInt32("new", newWksIndex); changedMsg.AddInt32("new", newIndex);
winBorder->QuietlySetWorkspaces(newWksIndex); winBorder->QuietlySetWorkspaces(newIndex);
winBorder->Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false); winBorder->Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false);
#else
winBorder->WorkspacesChanged(oldIndex, newIndex);
#endif
if (invalidate) if (invalidate)
#ifndef NEW_INPUT_HANDLING #ifndef NEW_INPUT_HANDLING
show_final_scene(exFocus, exActive); show_final_scene(exFocus, exActive);
@@ -2321,8 +2317,14 @@ RootLayer::hide_winBorder(WinBorder *winBorder)
void void
RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel) RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
{ {
// if the notify Layer is somehow related to winBorder, then
// this window/WinBorder is not allowed to change feel.
if (fNotifyLayer && (fNotifyLayer == winBorder || fNotifyLayer->Owner() == winBorder)) {
return;
}
bool isVisible = false; bool isVisible = false;
bool wasVisibleInActiveWorkspace = false; bool isVisibleInActiveWorkspace = false;
#ifndef NEW_INPUT_HANDLING #ifndef NEW_INPUT_HANDLING
WinBorder* exFocus = Focus(); WinBorder* exFocus = Focus();
@@ -2334,31 +2336,33 @@ RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
if (!winBorder->IsHidden()) { if (!winBorder->IsHidden()) {
isVisible = true; isVisible = true;
wasVisibleInActiveWorkspace = ActiveWorkspace()->HasWinBorder(winBorder); isVisibleInActiveWorkspace = ActiveWorkspace()->HasWinBorder(winBorder);
// just hide, don't invalidate
winBorder->Hide(false); winBorder->Hide(false);
// all workspaces must be up-to-date with this change of feel.
for (int32 i = 0; i < kMaxWorkspaceCount; i++) {
if (fWorkspace[i]) {
fWorkspace[i]->HideWinBorder(winBorder);
fWorkspace[i]->RemoveWinBorder(winBorder);
}
}
} }
gDesktop->SetWinBorderFeel(winBorder, newFeel); gDesktop->SetWinBorderFeel(winBorder, newFeel);
if (isVisible) if (isVisible)
{ {
if (fNotifyLayer) // just show, don't invalidate
{ winBorder->Show(false);
// TODO: What was this supposed to do?!? // all workspaces must be up-to-date with this change of feel.
/* WinBorder *wb = fNotifyLayer->fOwner? for (int32 i = 0; i < kMaxWorkspaceCount; i++) {
fNotifyLayer->fOwner: if (fWorkspace[i]) {
(WinBorder*)fNotifyLayer; fWorkspace[i]->AddWinBorder(winBorder);
if (wb == fNotifyLayer) fWorkspace[i]->ShowWinBorder(winBorder);
{ }
fMovingWindow = false;
fResizingWindow = false;
wb->MouseUp(DEC_NONE);
}*/
fNotifyLayer = NULL;
} }
winBorder->Show(false); if (isVisibleInActiveWorkspace)
if (wasVisibleInActiveWorkspace || ActiveWorkspace()->HasWinBorder(winBorder))
#ifndef NEW_INPUT_HANDLING #ifndef NEW_INPUT_HANDLING
show_final_scene(exFocus, exActive); show_final_scene(exFocus, exActive);
#else #else
+2 -2
View File
@@ -84,8 +84,8 @@ public:
void HideWinBorder(WinBorder* winBorder); void HideWinBorder(WinBorder* winBorder);
void ShowWinBorder(WinBorder* winBorder); void ShowWinBorder(WinBorder* winBorder);
void SetWinBorderWorskpaces(WinBorder *winBorder, void SetWinBorderWorskpaces(WinBorder *winBorder,
uint32 oldWksIndex, uint32 oldIndex,
uint32 newWksIndex); uint32 newIndex);
WinBorder* WinBorderAt(const BPoint& pt) const; WinBorder* WinBorderAt(const BPoint& pt) const;
#ifdef NEW_INPUT_HANDLING #ifdef NEW_INPUT_HANDLING
void RevealNewWMState(Workspace::State &oldWMState); void RevealNewWMState(Workspace::State &oldWMState);
+13
View File
@@ -637,6 +637,19 @@ WinBorder::WorkspaceActivated(int32 index, bool active)
Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false); Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false);
} }
void
WinBorder::WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces)
{
fWorkspaces = newWorkspaces;
BMessage changedMsg(B_WORKSPACES_CHANGED);
changedMsg.AddInt64("when", real_time_clock_usecs());
changedMsg.AddInt32("old", oldWorkspaces);
changedMsg.AddInt32("new", newWorkspaces);
Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false);
}
#else #else
/*! /*!
\brief Handles B_MOUSE_DOWN events and takes appropriate actions \brief Handles B_MOUSE_DOWN events and takes appropriate actions
+1
View File
@@ -88,6 +88,7 @@ class WinBorder : public Layer {
click_type ActionFor(const PointerEvent& evt) click_type ActionFor(const PointerEvent& evt)
{ return _ActionFor(evt); } { return _ActionFor(evt); }
virtual void WorkspaceActivated(int32 index, bool active); virtual void WorkspaceActivated(int32 index, bool active);
virtual void WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces);
#else #else
click_type MouseDown(const PointerEvent& evt); click_type MouseDown(const PointerEvent& evt);
void MouseMoved(const PointerEvent& evt); void MouseMoved(const PointerEvent& evt);