From 8285d6b3c0e19b94803b48340ad12286a528b65d Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Wed, 28 Sep 2005 21:12:38 +0000 Subject: [PATCH] * implemented/fixed RootLayer::SetActiveWorkspace() under NEW_INPUT_HANDLING define. * added Layer/WinBorder::WorkspaceActivated() git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14270 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Layer.cpp | 5 +++ src/servers/app/Layer.h | 1 + src/servers/app/RootLayer.cpp | 71 ++++++++++++++++++++++++++--------- src/servers/app/RootLayer.h | 2 +- src/servers/app/WinBorder.cpp | 11 ++++++ src/servers/app/WinBorder.h | 1 + 6 files changed, 72 insertions(+), 19 deletions(-) diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 688c2c8a64..6df3e7d904 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -1150,6 +1150,11 @@ Layer::MouseMoved(const PointerEvent& evt, uint32 transit) Window()->SendMessageToClient(&movemsg, fViewToken, false); } } +void +Layer::WorkspaceActivated(int32 index, bool active) +{ + // Empty +} #endif // BoundsOrigin BPoint diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 07b1677a72..ad52219fa4 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -169,6 +169,7 @@ class Layer { virtual void MouseDown(const PointerEvent& evt); virtual void MouseUp(const PointerEvent& evt); virtual void MouseMoved(const PointerEvent& evt, uint32 transit); + virtual void WorkspaceActivated(int32 index, bool active); #endif BPoint BoundsOrigin() const; // BoundsFrameDiff()? float Scale() const; diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index abba824b26..10c2cbe6e3 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -77,7 +77,6 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount, fDesktop(desktop), fDragMessage(NULL), fLastLayerUnderMouse(this), - fMouseTargetWinBorder(NULL), fViewAction(B_ENTERED_VIEW), fNotifyLayer(NULL), fSavedEventMask(0), @@ -101,6 +100,7 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount, fWinBorderListLength(64), fWinBorderList2((WinBorder**)malloc(fWinBorderListLength * sizeof(WinBorder*))), fWinBorderList((WinBorder**)malloc(fWinBorderListLength * sizeof(WinBorder*))), + fMouseTargetWinBorder(NULL), #else fWMState(), #endif @@ -723,10 +723,22 @@ bool RootLayer::SetActiveWorkspace(int32 index) if (index >= fWsCount || index == fActiveWksIndex || index < 0) return false; - // you cannot switch workspaces on R5 if there is an event mask layer - if (fNotifyLayer) + // you cannot switch workspaces on R5 if there is an event mask BView + if (fNotifyLayer && fNotifyLayer->Owner()) return false; + // if you're dragging something you are allowed to change workspaces only if + // the Layer being dragged is a B_NORMAL_WINDOW_FEEL WinBorder. + WinBorder *draggedWinBorder = dynamic_cast(fNotifyLayer); + if (fNotifyLayer) { + if (draggedWinBorder) { + if (draggedWinBorder->Feel() != B_NORMAL_WINDOW_FEEL) + return false; + } + else + return false; + } + // if fWorkspace[index] object does not exist, create and add allowed WinBorders if (!fWorkspace[index]) { // TODO: we NEED datas from a file!!! @@ -759,6 +771,7 @@ bool RootLayer::SetActiveWorkspace(int32 index) fLayerData->SetHighColor(RGBColor(255, 255, 255)); fLayerData->SetLowColor(fWorkspace[index]->BGColor()); + // save some datas int32 exIndex = ActiveWorkspaceIndex(); #ifdef NEW_INPUT_HANDLING Workspace::State oldWMState; @@ -766,27 +779,48 @@ bool RootLayer::SetActiveWorkspace(int32 index) #endif // send the workspace changed message for the old workspace { +#ifndef NEW_INPUT_HANDLING BMessage activatedMsg(B_WORKSPACE_ACTIVATED); activatedMsg.AddInt64("when", real_time_clock_usecs()); activatedMsg.AddInt32("workspace", fActiveWksIndex); activatedMsg.AddBool("active", false); -#ifndef NEW_INPUT_HANDLING for (int32 i = 0; i < fWinBorderCount; i++) fWinBorderList[i]->Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false); #else Layer *layer; - WinBorder *winBorder; for (int32 i = 0; (layer = static_cast(fWMState.WindowList.ItemAt(i++))); ) { - winBorder = dynamic_cast(layer); - if (winBorder) - winBorder->Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false); + layer->WorkspaceActivated(fActiveWksIndex, false); } #endif } fActiveWksIndex = index; +#ifdef NEW_INPUT_HANDLING + if (draggedWinBorder && !ActiveWorkspace()->HasWinBorder(draggedWinBorder)) { + // Workspace class expects a window to be hidden when it's about to be removed. + // As we surely know this windows is visible, we simply set fHidden to true and then + // change it back when adding winBorder to the current workspace. + draggedWinBorder->fHidden = true; + fWorkspace[exIndex]->HideWinBorder(draggedWinBorder); + fWorkspace[exIndex]->RemoveWinBorder(draggedWinBorder); + draggedWinBorder->fHidden = false; + ActiveWorkspace()->AddWinBorder(draggedWinBorder); + ActiveWorkspace()->ShowWinBorder(draggedWinBorder); + + // TODO: can you call SetWinBorderWorskpaces() instead of this? + uint32 wks = draggedWinBorder->Workspaces(); + BMessage changedMsg(B_WORKSPACES_CHANGED); + changedMsg.AddInt64("when", real_time_clock_usecs()); + changedMsg.AddInt32("old", wks); + wks &= ~(0x00000001 << exIndex); + wks |= (0x00000001 << fActiveWksIndex); + changedMsg.AddInt32("new", wks); + draggedWinBorder->QuietlySetWorkspaces(wks); + draggedWinBorder->Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false); + } +#else if (fMouseTargetWinBorder) { // if (fMovingWindow && fNotifyLayer) { // WinBorder *movingWinBorder = (WinBorder*)fNotifyLayer; @@ -839,9 +873,9 @@ bool RootLayer::SetActiveWorkspace(int32 index) fMovingWindow = false; fResizingWindow = false; }*/ - - fHaveWinBorderList = true; +#endif #ifndef NEW_INPUT_HANDLING + fHaveWinBorderList = true; get_workspace_windows(); if (WorkspacesLayer() != NULL) @@ -857,21 +891,18 @@ bool RootLayer::SetActiveWorkspace(int32 index) // send the workspace changed message for the new workspace { +#ifndef NEW_INPUT_HANDLING BMessage activatedMsg(B_WORKSPACE_ACTIVATED); activatedMsg.AddInt64("when", real_time_clock_usecs()); activatedMsg.AddInt32("workspace", fActiveWksIndex); activatedMsg.AddBool("active", true); -#ifndef NEW_INPUT_HANDLING for (int32 i = 0; i < fWinBorderCount; i++) fWinBorderList[i]->Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false); #else Layer *layer; - WinBorder *winBorder; for (int32 i = 0; (layer = static_cast(fWMState.WindowList.ItemAt(i++))); ) { - winBorder = dynamic_cast(layer); - if (winBorder) - winBorder->Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false); + layer->WorkspaceActivated(fActiveWksIndex, true); } #endif @@ -885,6 +916,10 @@ bool RootLayer::SetActiveWorkspace(int32 index) void RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldWksIndex, uint32 newWksIndex) { +#ifdef NEW_INPUT_HANDLING + printf("RootLayer::SetWinBorderWorskpaces() UNIMPLEMENTED\n"); + return; +#endif // you *cannot* set workspaces index for a window other than a normal one! // Note: See ServerWindow class. if (winBorder->Feel() != B_NORMAL_WINDOW_FEEL) @@ -1223,7 +1258,6 @@ RootLayer::_ProcessMouseMovedEvent(PointerEvent &evt) // change focus in FFM mode WinBorder* winBorderTarget = dynamic_cast(target); if (winBorderTarget) { - // TODO: figure out what other mouse modes are for!!! DesktopSettings ds(gDesktop); // TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!! WinBorder* exFocus = Focus(); @@ -2095,7 +2129,7 @@ RootLayer::SetNotifyLayer(Layer *lay, uint32 mask, uint32 options) Lock(); -#if NEW_INPUT_HANDLING // to be removed when the new "event" stuff is ready +#ifdef NEW_INPUT_HANDLING fNotifyLayer = lay; fSavedEventMask = lay->EventMask(); fSavedEventOptions = lay->EventOptions(); @@ -2149,9 +2183,10 @@ RootLayer::LayerRemoved(Layer* layer) if (layer == fLastLayerUnderMouse) fLastLayerUnderMouse = NULL; - +#ifndef NEW_INPUT_HANDLING if (layer == fMouseTargetWinBorder) fMouseTargetWinBorder = NULL; +#endif } diff --git a/src/servers/app/RootLayer.h b/src/servers/app/RootLayer.h index ee8a3cd763..a6d2779e6b 100644 --- a/src/servers/app/RootLayer.h +++ b/src/servers/app/RootLayer.h @@ -186,7 +186,6 @@ friend class WinBorder; // temporarily, I need invalidate_layer() Desktop* fDesktop; BMessage* fDragMessage; Layer* fLastLayerUnderMouse; - WinBorder* fMouseTargetWinBorder; int32 fViewAction; Layer* fNotifyLayer; @@ -215,6 +214,7 @@ friend class WinBorder; // temporarily, I need invalidate_layer() int32 fWinBorderListLength; WinBorder** fWinBorderList2; WinBorder** fWinBorderList; + WinBorder* fMouseTargetWinBorder; #else // TODO: fWMState MUST be associated with a surface. This is the case now // with RootLayer, but after Axel's refractoring this should go in diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 3f517b1009..c2f799d7d4 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -626,6 +626,17 @@ WinBorder::MouseMoved(const PointerEvent& event, uint32 transit) fLastMousePosition = event.where; } +void +WinBorder::WorkspaceActivated(int32 index, bool active) +{ + BMessage activatedMsg(B_WORKSPACE_ACTIVATED); + activatedMsg.AddInt64("when", real_time_clock_usecs()); + activatedMsg.AddInt32("workspace", index); + activatedMsg.AddBool("active", active); + + Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false); +} + #else /*! \brief Handles B_MOUSE_DOWN events and takes appropriate actions diff --git a/src/servers/app/WinBorder.h b/src/servers/app/WinBorder.h index 93926a5997..de5250ffa5 100644 --- a/src/servers/app/WinBorder.h +++ b/src/servers/app/WinBorder.h @@ -87,6 +87,7 @@ class WinBorder : public Layer { virtual void MouseMoved(const PointerEvent& evt, uint32 transit); click_type ActionFor(const PointerEvent& evt) { return _ActionFor(evt); } + virtual void WorkspaceActivated(int32 index, bool active); #else click_type MouseDown(const PointerEvent& evt); void MouseMoved(const PointerEvent& evt);