xref: /haiku/src/servers/app/DesktopListener.h (revision 32a2294fdc40a8ef9e3360aa85d0b7efb0c930b9)
1 /*
2  * Copyright 2010, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Clemens Zeidler <haiku@clemens-zeidler.de>
7  */
8 #ifndef DESKTOP_LISTENER_H
9 #define DESKTOP_LISTENER_H
10 
11 
12 #include <util/DoublyLinkedList.h>
13 
14 #include <Point.h>
15 
16 #include <ServerLink.h>
17 
18 
19 class BMessage;
20 class Desktop;
21 class Window;
22 
23 
24 class DesktopListener : public DoublyLinkedListLinkImpl<DesktopListener> {
25 public:
26 	virtual						~DesktopListener();
27 
28 	virtual int32				Identifier() = 0;
29 
30 	virtual	void				ListenerRegistered(Desktop* desktop) = 0;
31 	virtual	void				ListenerUnregistered() = 0;
32 
33 	virtual bool				HandleMessage(Window* sender,
34 									BPrivate::ServerLink& link) = 0;
35 
36 	virtual void				WindowAdded(Window* window) = 0;
37 	virtual void				WindowRemoved(Window* window) = 0;
38 
39 	virtual void				KeyPressed(uint32 what, int32 key,
40 									int32 modifiers) = 0;
41 	virtual void				MouseEvent(BMessage* message) = 0;
42 	virtual void				MouseDown(Window* window, BMessage* message,
43 									const BPoint& where) = 0;
44 	virtual void				MouseUp(Window* window, BMessage* message,
45 									const BPoint& where) = 0;
46 	virtual void				MouseMoved(Window* window, BMessage* message,
47 									const BPoint& where) = 0;
48 
49 	virtual void				WindowMoved(Window* window) = 0;
50 	virtual void				WindowResized(Window* window) = 0;
51 	virtual void				WindowActitvated(Window* window) = 0;
52 	virtual void				WindowSentBehind(Window* window,
53 									Window* behindOf) = 0;
54 	virtual void				WindowWorkspacesChanged(Window* window,
55 									uint32 workspaces) = 0;
56 	virtual void				WindowMinimized(Window* window,
57 									bool minimize) = 0;
58 
59 	virtual void				WindowTabLocationChanged(Window* window,
60 									float location) = 0;
61 
62 	virtual bool				SetDecoratorSettings(Window* window,
63 									const BMessage& settings) = 0;
64 	virtual void				GetDecoratorSettings(Window* window,
65 									BMessage& settings) = 0;
66 };
67 
68 
69 typedef DoublyLinkedList<DesktopListener> DesktopListenerDLList;
70 
71 
72 class DesktopObservable {
73 public:
74 							DesktopObservable();
75 
76 		void				RegisterListener(DesktopListener* listener,
77 								Desktop* desktop);
78 		void				UnregisterListener(DesktopListener* listener);
79 	const DesktopListenerDLList&	GetDesktopListenerList();
80 
81 		bool				MessageForListener(Window* sender,
82 								BPrivate::ServerLink& link);
83 
84 		void				NotifyWindowAdded(Window* window);
85 		void				NotifyWindowRemoved(Window* window);
86 
87 		void				NotifyKeyPressed(uint32 what, int32 key,
88 								int32 modifiers);
89 		void				NotifyMouseEvent(BMessage* message);
90 		void				NotifyMouseDown(Window* window, BMessage* message,
91 									const BPoint& where);
92 		void				NotifyMouseUp(Window* window, BMessage* message,
93 									const BPoint& where);
94 		void				NotifyMouseMoved(Window* window, BMessage* message,
95 									const BPoint& where);
96 
97 		void				NotifyWindowMoved(Window* window);
98 		void				NotifyWindowResized(Window* window);
99 		void				NotifyWindowActitvated(Window* window);
100 		void				NotifyWindowSentBehind(Window* window,
101 								Window* behindOf);
102 		void				NotifyWindowWorkspacesChanged(Window* window,
103 									uint32 workspaces);
104 		void				NotifyWindowMinimized(Window* window,
105 								bool minimize);
106 
107 		void				NotifyWindowTabLocationChanged(Window* window,
108 								float location);
109 
110 		bool				SetDecoratorSettings(Window* window,
111 								const BMessage& settings);
112 		void				GetDecoratorSettings(Window* window,
113 								BMessage& settings);
114 
115 private:
116 		class InvokeGuard {
117 			public:
118 				InvokeGuard(bool& invoking);
119 				~InvokeGuard();
120 			private:
121 				bool&	fInvoking;
122 		};
123 
124 		DesktopListenerDLList	fDesktopListenerList;
125 
126 		// prevent recursive invokes
127 		bool					fWeAreInvoking;
128 };
129 
130 #endif
131