1*27f5d579SClemens Zeidler /* 2*27f5d579SClemens Zeidler * Copyright 2010, Haiku. 3*27f5d579SClemens Zeidler * Distributed under the terms of the MIT License. 4*27f5d579SClemens Zeidler * 5*27f5d579SClemens Zeidler * Authors: 6*27f5d579SClemens Zeidler * Clemens Zeidler <haiku@clemens-zeidler.de> 7*27f5d579SClemens Zeidler */ 8*27f5d579SClemens Zeidler #ifndef STACK_AND_TILE_H 9*27f5d579SClemens Zeidler #define STACK_AND_TILE_H 10*27f5d579SClemens Zeidler 11*27f5d579SClemens Zeidler 12*27f5d579SClemens Zeidler #include <map> 13*27f5d579SClemens Zeidler 14*27f5d579SClemens Zeidler #include <Message.h> 15*27f5d579SClemens Zeidler #include <MessageFilter.h> 16*27f5d579SClemens Zeidler 17*27f5d579SClemens Zeidler #include "DesktopListener.h" 18*27f5d579SClemens Zeidler #include "ObjectList.h" 19*27f5d579SClemens Zeidler #include "WindowList.h" 20*27f5d579SClemens Zeidler 21*27f5d579SClemens Zeidler 22*27f5d579SClemens Zeidler #define DEBUG_STACK_AND_TILE 23*27f5d579SClemens Zeidler 24*27f5d579SClemens Zeidler #ifdef DEBUG_STACK_AND_TILE 25*27f5d579SClemens Zeidler # define STRACE_SAT(x...) debug_printf("SAT: "x) 26*27f5d579SClemens Zeidler #else 27*27f5d579SClemens Zeidler # define STRACE_SAT(x...) ; 28*27f5d579SClemens Zeidler #endif 29*27f5d579SClemens Zeidler 30*27f5d579SClemens Zeidler 31*27f5d579SClemens Zeidler class SATGroup; 32*27f5d579SClemens Zeidler class SATWindow; 33*27f5d579SClemens Zeidler class Window; 34*27f5d579SClemens Zeidler class WindowArea; 35*27f5d579SClemens Zeidler 36*27f5d579SClemens Zeidler 37*27f5d579SClemens Zeidler typedef std::map<Window*, SATWindow*> SATWindowMap; 38*27f5d579SClemens Zeidler 39*27f5d579SClemens Zeidler 40*27f5d579SClemens Zeidler class StackAndTile : public DesktopListener { 41*27f5d579SClemens Zeidler public: 42*27f5d579SClemens Zeidler StackAndTile(); 43*27f5d579SClemens Zeidler virtual ~StackAndTile(); 44*27f5d579SClemens Zeidler 45*27f5d579SClemens Zeidler virtual int32 Identifier(); 46*27f5d579SClemens Zeidler 47*27f5d579SClemens Zeidler // DesktopListener hooks 48*27f5d579SClemens Zeidler virtual void ListenerRegistered(Desktop* desktop); 49*27f5d579SClemens Zeidler virtual void ListenerUnregistered(); 50*27f5d579SClemens Zeidler 51*27f5d579SClemens Zeidler virtual bool HandleMessage(Window* sender, 52*27f5d579SClemens Zeidler BPrivate::LinkReceiver& link, 53*27f5d579SClemens Zeidler BPrivate::LinkSender& reply); 54*27f5d579SClemens Zeidler 55*27f5d579SClemens Zeidler virtual void WindowAdded(Window* window); 56*27f5d579SClemens Zeidler virtual void WindowRemoved(Window* window); 57*27f5d579SClemens Zeidler 58*27f5d579SClemens Zeidler virtual bool KeyPressed(uint32 what, int32 key, 59*27f5d579SClemens Zeidler int32 modifiers); 60*27f5d579SClemens Zeidler virtual void MouseEvent(BMessage* message) {} 61*27f5d579SClemens Zeidler virtual void MouseDown(Window* window, BMessage* message, 62*27f5d579SClemens Zeidler const BPoint& where); 63*27f5d579SClemens Zeidler virtual void MouseUp(Window* window, BMessage* message, 64*27f5d579SClemens Zeidler const BPoint& where); 65*27f5d579SClemens Zeidler virtual void MouseMoved(Window* window, BMessage* message, 66*27f5d579SClemens Zeidler const BPoint& where) {} 67*27f5d579SClemens Zeidler 68*27f5d579SClemens Zeidler virtual void WindowMoved(Window* window); 69*27f5d579SClemens Zeidler virtual void WindowResized(Window* window); 70*27f5d579SClemens Zeidler virtual void WindowActitvated(Window* window); 71*27f5d579SClemens Zeidler virtual void WindowSentBehind(Window* window, 72*27f5d579SClemens Zeidler Window* behindOf); 73*27f5d579SClemens Zeidler virtual void WindowWorkspacesChanged(Window* window, 74*27f5d579SClemens Zeidler uint32 workspaces); 75*27f5d579SClemens Zeidler virtual void WindowMinimized(Window* window, bool minimize); 76*27f5d579SClemens Zeidler 77*27f5d579SClemens Zeidler virtual void WindowTabLocationChanged(Window* window, 78*27f5d579SClemens Zeidler float location, bool isShifting); 79*27f5d579SClemens Zeidler virtual void SizeLimitsChanged(Window* window, 80*27f5d579SClemens Zeidler int32 minWidth, int32 maxWidth, 81*27f5d579SClemens Zeidler int32 minHeight, int32 maxHeight); 82*27f5d579SClemens Zeidler virtual void WindowLookChanged(Window* window, 83*27f5d579SClemens Zeidler window_look look); 84*27f5d579SClemens Zeidler virtual void WindowFeelChanged(Window* window, 85*27f5d579SClemens Zeidler window_feel feel); 86*27f5d579SClemens Zeidler 87*27f5d579SClemens Zeidler virtual bool SetDecoratorSettings(Window* window, 88*27f5d579SClemens Zeidler const BMessage& settings); 89*27f5d579SClemens Zeidler virtual void GetDecoratorSettings(Window* window, 90*27f5d579SClemens Zeidler BMessage& settings); 91*27f5d579SClemens Zeidler 92*27f5d579SClemens Zeidler bool SATKeyPressed() 93*27f5d579SClemens Zeidler { return fSATKeyPressed; } 94*27f5d579SClemens Zeidler 95*27f5d579SClemens Zeidler SATWindow* GetSATWindow(Window* window); 96*27f5d579SClemens Zeidler SATWindow* FindSATWindow(uint64 id); 97*27f5d579SClemens Zeidler 98*27f5d579SClemens Zeidler private: 99*27f5d579SClemens Zeidler void _StartSAT(); 100*27f5d579SClemens Zeidler void _StopSAT(); 101*27f5d579SClemens Zeidler void _ActivateWindow(SATWindow* window); 102*27f5d579SClemens Zeidler bool _HandleMessage(BPrivate::LinkReceiver& link, 103*27f5d579SClemens Zeidler BPrivate::LinkSender& reply); 104*27f5d579SClemens Zeidler 105*27f5d579SClemens Zeidler Desktop* fDesktop; 106*27f5d579SClemens Zeidler 107*27f5d579SClemens Zeidler bool fSATKeyPressed; 108*27f5d579SClemens Zeidler 109*27f5d579SClemens Zeidler SATWindowMap fSATWindowMap; 110*27f5d579SClemens Zeidler BObjectList<SATWindow> fGrouplessWindows; 111*27f5d579SClemens Zeidler 112*27f5d579SClemens Zeidler SATWindow* fCurrentSATWindow; 113*27f5d579SClemens Zeidler }; 114*27f5d579SClemens Zeidler 115*27f5d579SClemens Zeidler 116*27f5d579SClemens Zeidler class GroupIterator { 117*27f5d579SClemens Zeidler public: 118*27f5d579SClemens Zeidler GroupIterator(StackAndTile* sat, 119*27f5d579SClemens Zeidler Desktop* desktop); 120*27f5d579SClemens Zeidler 121*27f5d579SClemens Zeidler void RewindToFront(); 122*27f5d579SClemens Zeidler SATGroup* NextGroup(); 123*27f5d579SClemens Zeidler 124*27f5d579SClemens Zeidler private: 125*27f5d579SClemens Zeidler StackAndTile* fStackAndTile; 126*27f5d579SClemens Zeidler Desktop* fDesktop; 127*27f5d579SClemens Zeidler Window* fCurrentWindow; 128*27f5d579SClemens Zeidler SATGroup* fCurrentGroup; 129*27f5d579SClemens Zeidler }; 130*27f5d579SClemens Zeidler 131*27f5d579SClemens Zeidler 132*27f5d579SClemens Zeidler class WindowIterator { 133*27f5d579SClemens Zeidler public: 134*27f5d579SClemens Zeidler WindowIterator(SATGroup* group, 135*27f5d579SClemens Zeidler bool reverseLayerOrder = false); 136*27f5d579SClemens Zeidler 137*27f5d579SClemens Zeidler void Rewind(); 138*27f5d579SClemens Zeidler /*! Iterates over all areas in the group and return the windows in 139*27f5d579SClemens Zeidler the areas. Within one area the windows are ordered by their layer 140*27f5d579SClemens Zeidler position. If reverseLayerOrder is false the bottommost window comes 141*27f5d579SClemens Zeidler first. */ 142*27f5d579SClemens Zeidler SATWindow* NextWindow(); 143*27f5d579SClemens Zeidler 144*27f5d579SClemens Zeidler 145*27f5d579SClemens Zeidler private: 146*27f5d579SClemens Zeidler SATWindow* _ReverseNextWindow(); 147*27f5d579SClemens Zeidler void _ReverseRewind(); 148*27f5d579SClemens Zeidler 149*27f5d579SClemens Zeidler SATGroup* fGroup; 150*27f5d579SClemens Zeidler bool fReverseLayerOrder; 151*27f5d579SClemens Zeidler 152*27f5d579SClemens Zeidler WindowArea* fCurrentArea; 153*27f5d579SClemens Zeidler int32 fAreaIndex; 154*27f5d579SClemens Zeidler int32 fWindowIndex; 155*27f5d579SClemens Zeidler }; 156*27f5d579SClemens Zeidler 157*27f5d579SClemens Zeidler 158*27f5d579SClemens Zeidler class SATSnappingBehaviour { 159*27f5d579SClemens Zeidler public: 160*27f5d579SClemens Zeidler virtual ~SATSnappingBehaviour(); 161*27f5d579SClemens Zeidler 162*27f5d579SClemens Zeidler /*! Find all window candidates which possibly can join the group. Found 163*27f5d579SClemens Zeidler candidates are marked here visual. */ 164*27f5d579SClemens Zeidler virtual bool FindSnappingCandidates(SATGroup* group) = 0; 165*27f5d579SClemens Zeidler /*! Join all candidates found in FindSnappingCandidates to the group. 166*27f5d579SClemens Zeidler Previously visually mark should be removed here. \return true if 167*27f5d579SClemens Zeidler integration has been succeed. */ 168*27f5d579SClemens Zeidler virtual bool JoinCandidates() = 0; 169*27f5d579SClemens Zeidler /*! Update the window tab values, solve the layout and move all windows in 170*27f5d579SClemens Zeidler the group accordantly. */ 171*27f5d579SClemens Zeidler virtual void RemovedFromArea(WindowArea* area) {} 172*27f5d579SClemens Zeidler virtual void WindowLookChanged(window_look look) {} 173*27f5d579SClemens Zeidler }; 174*27f5d579SClemens Zeidler 175*27f5d579SClemens Zeidler 176*27f5d579SClemens Zeidler typedef BObjectList<SATSnappingBehaviour> SATSnappingBehaviourList; 177*27f5d579SClemens Zeidler 178*27f5d579SClemens Zeidler 179*27f5d579SClemens Zeidler #endif 180