127f5d579SClemens Zeidler /* 2*fb6ab24aSJohn Scipione * Copyright 2010-2014 Haiku, Inc. All rights reserved. 327f5d579SClemens Zeidler * Distributed under the terms of the MIT License. 427f5d579SClemens Zeidler * 527f5d579SClemens Zeidler * Authors: 6*fb6ab24aSJohn Scipione * John Scipione, jscipione@gmail.com 7*fb6ab24aSJohn Scipione * Clemens Zeidler, haiku@clemens-zeidler.de 827f5d579SClemens Zeidler */ 927f5d579SClemens Zeidler #ifndef STACK_AND_TILE_H 1027f5d579SClemens Zeidler #define STACK_AND_TILE_H 1127f5d579SClemens Zeidler 1227f5d579SClemens Zeidler 1327f5d579SClemens Zeidler #include <map> 1427f5d579SClemens Zeidler 1527f5d579SClemens Zeidler #include <Message.h> 1627f5d579SClemens Zeidler #include <MessageFilter.h> 1727f5d579SClemens Zeidler 1827f5d579SClemens Zeidler #include "DesktopListener.h" 1927f5d579SClemens Zeidler #include "ObjectList.h" 2027f5d579SClemens Zeidler #include "WindowList.h" 2127f5d579SClemens Zeidler 2227f5d579SClemens Zeidler 2301d68c97SClemens Zeidler //#define DEBUG_STACK_AND_TILE 2427f5d579SClemens Zeidler 2527f5d579SClemens Zeidler #ifdef DEBUG_STACK_AND_TILE 2627f5d579SClemens Zeidler # define STRACE_SAT(x...) debug_printf("SAT: "x) 2727f5d579SClemens Zeidler #else 2827f5d579SClemens Zeidler # define STRACE_SAT(x...) ; 2927f5d579SClemens Zeidler #endif 3027f5d579SClemens Zeidler 3127f5d579SClemens Zeidler 3227f5d579SClemens Zeidler class SATGroup; 3327f5d579SClemens Zeidler class SATWindow; 3427f5d579SClemens Zeidler class Window; 3527f5d579SClemens Zeidler class WindowArea; 3627f5d579SClemens Zeidler 3727f5d579SClemens Zeidler 3827f5d579SClemens Zeidler typedef std::map<Window*, SATWindow*> SATWindowMap; 3927f5d579SClemens Zeidler 4027f5d579SClemens Zeidler 4127f5d579SClemens Zeidler class StackAndTile : public DesktopListener { 4227f5d579SClemens Zeidler public: 4327f5d579SClemens Zeidler StackAndTile(); 4427f5d579SClemens Zeidler virtual ~StackAndTile(); 4527f5d579SClemens Zeidler 4627f5d579SClemens Zeidler virtual int32 Identifier(); 4727f5d579SClemens Zeidler 4827f5d579SClemens Zeidler // DesktopListener hooks 4927f5d579SClemens Zeidler virtual void ListenerRegistered(Desktop* desktop); 5027f5d579SClemens Zeidler virtual void ListenerUnregistered(); 5127f5d579SClemens Zeidler 5227f5d579SClemens Zeidler virtual bool HandleMessage(Window* sender, 5327f5d579SClemens Zeidler BPrivate::LinkReceiver& link, 5427f5d579SClemens Zeidler BPrivate::LinkSender& reply); 5527f5d579SClemens Zeidler 5627f5d579SClemens Zeidler virtual void WindowAdded(Window* window); 5727f5d579SClemens Zeidler virtual void WindowRemoved(Window* window); 5827f5d579SClemens Zeidler 5927f5d579SClemens Zeidler virtual bool KeyPressed(uint32 what, int32 key, 6027f5d579SClemens Zeidler int32 modifiers); MouseEvent(BMessage * message)6127f5d579SClemens Zeidler virtual void MouseEvent(BMessage* message) {} 6227f5d579SClemens Zeidler virtual void MouseDown(Window* window, BMessage* message, 6327f5d579SClemens Zeidler const BPoint& where); 6427f5d579SClemens Zeidler virtual void MouseUp(Window* window, BMessage* message, 6527f5d579SClemens Zeidler const BPoint& where); MouseMoved(Window * window,BMessage * message,const BPoint & where)6627f5d579SClemens Zeidler virtual void MouseMoved(Window* window, BMessage* message, 6727f5d579SClemens Zeidler const BPoint& where) {} 6827f5d579SClemens Zeidler 6927f5d579SClemens Zeidler virtual void WindowMoved(Window* window); 7027f5d579SClemens Zeidler virtual void WindowResized(Window* window); 7127b76737SJohn Scipione virtual void WindowActivated(Window* window); 7227f5d579SClemens Zeidler virtual void WindowSentBehind(Window* window, 7327f5d579SClemens Zeidler Window* behindOf); 7427f5d579SClemens Zeidler virtual void WindowWorkspacesChanged(Window* window, 7527f5d579SClemens Zeidler uint32 workspaces); 76cd67c205SClemens Zeidler virtual void WindowHidden(Window* window, bool fromMinimize); 7727f5d579SClemens Zeidler virtual void WindowMinimized(Window* window, bool minimize); 7827f5d579SClemens Zeidler 7927f5d579SClemens Zeidler virtual void WindowTabLocationChanged(Window* window, 8027f5d579SClemens Zeidler float location, bool isShifting); 8127f5d579SClemens Zeidler virtual void SizeLimitsChanged(Window* window, 8227f5d579SClemens Zeidler int32 minWidth, int32 maxWidth, 8327f5d579SClemens Zeidler int32 minHeight, int32 maxHeight); 8427f5d579SClemens Zeidler virtual void WindowLookChanged(Window* window, 8527f5d579SClemens Zeidler window_look look); 8627f5d579SClemens Zeidler virtual void WindowFeelChanged(Window* window, 8727f5d579SClemens Zeidler window_feel feel); 8827f5d579SClemens Zeidler 8927f5d579SClemens Zeidler virtual bool SetDecoratorSettings(Window* window, 9027f5d579SClemens Zeidler const BMessage& settings); 9127f5d579SClemens Zeidler virtual void GetDecoratorSettings(Window* window, 9227f5d579SClemens Zeidler BMessage& settings); 9327f5d579SClemens Zeidler SATKeyPressed()9427f5d579SClemens Zeidler bool SATKeyPressed() 9527f5d579SClemens Zeidler { return fSATKeyPressed; } 9627f5d579SClemens Zeidler 9727f5d579SClemens Zeidler SATWindow* GetSATWindow(Window* window); 9827f5d579SClemens Zeidler SATWindow* FindSATWindow(uint64 id); 9927f5d579SClemens Zeidler 10027f5d579SClemens Zeidler private: 10127f5d579SClemens Zeidler void _StartSAT(); 10227f5d579SClemens Zeidler void _StopSAT(); 10327f5d579SClemens Zeidler void _ActivateWindow(SATWindow* window); 10427f5d579SClemens Zeidler bool _HandleMessage(BPrivate::LinkReceiver& link, 10527f5d579SClemens Zeidler BPrivate::LinkSender& reply); 10694d4c319SJohn Scipione SATGroup* _GetSATGroup(SATWindow* window); 10727f5d579SClemens Zeidler 10827f5d579SClemens Zeidler Desktop* fDesktop; 10927f5d579SClemens Zeidler 11027f5d579SClemens Zeidler bool fSATKeyPressed; 11127f5d579SClemens Zeidler 11227f5d579SClemens Zeidler SATWindowMap fSATWindowMap; 11327f5d579SClemens Zeidler BObjectList<SATWindow> fGrouplessWindows; 11427f5d579SClemens Zeidler 11527f5d579SClemens Zeidler SATWindow* fCurrentSATWindow; 11627f5d579SClemens Zeidler }; 11727f5d579SClemens Zeidler 11827f5d579SClemens Zeidler 11927f5d579SClemens Zeidler class GroupIterator { 12027f5d579SClemens Zeidler public: 12127f5d579SClemens Zeidler GroupIterator(StackAndTile* sat, 12227f5d579SClemens Zeidler Desktop* desktop); 12327f5d579SClemens Zeidler CurrentGroup(void)12494d4c319SJohn Scipione SATGroup* CurrentGroup(void) const 12594d4c319SJohn Scipione { return fCurrentGroup; }; SetCurrentGroup(SATGroup * group)12694d4c319SJohn Scipione void SetCurrentGroup(SATGroup* group) 12794d4c319SJohn Scipione { fCurrentGroup = group; }; 12894d4c319SJohn Scipione 12927f5d579SClemens Zeidler void RewindToFront(); 13027f5d579SClemens Zeidler SATGroup* NextGroup(); 13127f5d579SClemens Zeidler 13227f5d579SClemens Zeidler private: 13327f5d579SClemens Zeidler StackAndTile* fStackAndTile; 13427f5d579SClemens Zeidler Desktop* fDesktop; 13527f5d579SClemens Zeidler Window* fCurrentWindow; 13627f5d579SClemens Zeidler SATGroup* fCurrentGroup; 13727f5d579SClemens Zeidler }; 13827f5d579SClemens Zeidler 13927f5d579SClemens Zeidler 14027f5d579SClemens Zeidler class WindowIterator { 14127f5d579SClemens Zeidler public: 14227f5d579SClemens Zeidler WindowIterator(SATGroup* group, 14327f5d579SClemens Zeidler bool reverseLayerOrder = false); 14427f5d579SClemens Zeidler 14527f5d579SClemens Zeidler void Rewind(); 14627f5d579SClemens Zeidler /*! Iterates over all areas in the group and return the windows in 14727f5d579SClemens Zeidler the areas. Within one area the windows are ordered by their layer 14827f5d579SClemens Zeidler position. If reverseLayerOrder is false the bottommost window comes 14927f5d579SClemens Zeidler first. */ 15027f5d579SClemens Zeidler SATWindow* NextWindow(); 15127f5d579SClemens Zeidler 15227f5d579SClemens Zeidler private: 15327f5d579SClemens Zeidler SATWindow* _ReverseNextWindow(); 15427f5d579SClemens Zeidler void _ReverseRewind(); 15527f5d579SClemens Zeidler 15627f5d579SClemens Zeidler SATGroup* fGroup; 15727f5d579SClemens Zeidler bool fReverseLayerOrder; 15827f5d579SClemens Zeidler 15927f5d579SClemens Zeidler WindowArea* fCurrentArea; 16027f5d579SClemens Zeidler int32 fAreaIndex; 16127f5d579SClemens Zeidler int32 fWindowIndex; 16227f5d579SClemens Zeidler }; 16327f5d579SClemens Zeidler 16427f5d579SClemens Zeidler 16527f5d579SClemens Zeidler class SATSnappingBehaviour { 16627f5d579SClemens Zeidler public: ~SATSnappingBehaviour()167cdffe361SJohn Scipione virtual ~SATSnappingBehaviour() {}; 16827f5d579SClemens Zeidler 16927f5d579SClemens Zeidler /*! Find all window candidates which possibly can join the group. Found 17027f5d579SClemens Zeidler candidates are marked here visual. */ 17127f5d579SClemens Zeidler virtual bool FindSnappingCandidates(SATGroup* group) = 0; 17227f5d579SClemens Zeidler /*! Join all candidates found in FindSnappingCandidates to the group. 17327f5d579SClemens Zeidler Previously visually mark should be removed here. \return true if 17427f5d579SClemens Zeidler integration has been succeed. */ 17527f5d579SClemens Zeidler virtual bool JoinCandidates() = 0; 17627f5d579SClemens Zeidler /*! Update the window tab values, solve the layout and move all windows in 17727f5d579SClemens Zeidler the group accordantly. */ RemovedFromArea(WindowArea * area)17827f5d579SClemens Zeidler virtual void RemovedFromArea(WindowArea* area) {} WindowLookChanged(window_look look)17927f5d579SClemens Zeidler virtual void WindowLookChanged(window_look look) {} 18027f5d579SClemens Zeidler }; 18127f5d579SClemens Zeidler 18227f5d579SClemens Zeidler 18327f5d579SClemens Zeidler typedef BObjectList<SATSnappingBehaviour> SATSnappingBehaviourList; 18427f5d579SClemens Zeidler 18527f5d579SClemens Zeidler 18627f5d579SClemens Zeidler #endif 187