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