xref: /haiku/src/servers/app/DesktopListener.h (revision 76e9533e9e9945f62053bf7c737df2f3e1735bbd)
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 #include "Window.h"
18 
19 
20 class BMessage;
21 class Desktop;
22 class Window;
23 
24 
25 class DesktopListener : public DoublyLinkedListLinkImpl<DesktopListener> {
26 public:
27 	virtual						~DesktopListener();
28 
29 	virtual int32				Identifier() = 0;
30 
31 	virtual	void				ListenerRegistered(Desktop* desktop) = 0;
32 	virtual	void				ListenerUnregistered() = 0;
33 
34 	virtual bool				HandleMessage(Window* sender,
35 									BPrivate::LinkReceiver& link,
36 									BPrivate::LinkSender& reply) = 0;
37 
38 	virtual void				WindowAdded(Window* window) = 0;
39 	virtual void				WindowRemoved(Window* window) = 0;
40 
41 	virtual bool				KeyPressed(uint32 what, int32 key,
42 									int32 modifiers) = 0;
43 	virtual void				MouseEvent(BMessage* message) = 0;
44 	virtual void				MouseDown(Window* window, BMessage* message,
45 									const BPoint& where) = 0;
46 	virtual void				MouseUp(Window* window, BMessage* message,
47 									const BPoint& where) = 0;
48 	virtual void				MouseMoved(Window* window, BMessage* message,
49 									const BPoint& where) = 0;
50 
51 	virtual void				WindowMoved(Window* window) = 0;
52 	virtual void				WindowResized(Window* window) = 0;
53 	virtual void				WindowActitvated(Window* window) = 0;
54 	virtual void				WindowSentBehind(Window* window,
55 									Window* behindOf) = 0;
56 	virtual void				WindowWorkspacesChanged(Window* window,
57 									uint32 workspaces) = 0;
58 	virtual void				WindowMinimized(Window* window,
59 									bool minimize) = 0;
60 
61 	virtual void				WindowTabLocationChanged(Window* window,
62 									float location) = 0;
63 	virtual void				SizeLimitsChanged(Window* window,
64 									int32 minWidth, int32 maxWidth,
65 									int32 minHeight, int32 maxHeight) = 0;
66 	virtual void				WindowLookChanged(Window* window,
67 									window_look look) = 0;
68 
69 	virtual bool				SetDecoratorSettings(Window* window,
70 									const BMessage& settings) = 0;
71 	virtual void				GetDecoratorSettings(Window* window,
72 									BMessage& settings) = 0;
73 };
74 
75 
76 typedef DoublyLinkedList<DesktopListener> DesktopListenerDLList;
77 
78 
79 class DesktopObservable {
80 public:
81 								DesktopObservable();
82 
83 			void				RegisterListener(DesktopListener* listener,
84 									Desktop* desktop);
85 			void				UnregisterListener(DesktopListener* listener);
86 	const DesktopListenerDLList&	GetDesktopListenerList();
87 
88 			bool				MessageForListener(Window* sender,
89 									BPrivate::LinkReceiver& link,
90 									BPrivate::LinkSender& reply);
91 
92 			void				NotifyWindowAdded(Window* window);
93 			void				NotifyWindowRemoved(Window* window);
94 
95 			bool				NotifyKeyPressed(uint32 what, int32 key,
96 									int32 modifiers);
97 			void				NotifyMouseEvent(BMessage* message);
98 			void				NotifyMouseDown(Window* window,
99 									BMessage* message, const BPoint& where);
100 			void				NotifyMouseUp(Window* window, BMessage* message,
101 										const BPoint& where);
102 			void				NotifyMouseMoved(Window* window,
103 									BMessage* message, const BPoint& where);
104 
105 			void				NotifyWindowMoved(Window* window);
106 			void				NotifyWindowResized(Window* window);
107 			void				NotifyWindowActivated(Window* window);
108 			void				NotifyWindowSentBehind(Window* window,
109 									Window* behindOf);
110 			void				NotifyWindowWorkspacesChanged(Window* window,
111 									uint32 workspaces);
112 			void				NotifyWindowMinimized(Window* window,
113 									bool minimize);
114 
115 			void				NotifyWindowTabLocationChanged(Window* window,
116 									float location);
117 			void				NotifySizeLimitsChanged(Window* window,
118 									int32 minWidth, int32 maxWidth,
119 									int32 minHeight, int32 maxHeight);
120 			void				NotifyWindowLookChanged(Window* window,
121 									window_look look);
122 
123 			bool				SetDecoratorSettings(Window* window,
124 									const BMessage& settings);
125 			void				GetDecoratorSettings(Window* window,
126 									BMessage& settings);
127 
128 private:
129 		class InvokeGuard {
130 			public:
131 				InvokeGuard(bool& invoking);
132 				~InvokeGuard();
133 			private:
134 				bool&	fInvoking;
135 		};
136 
137 		DesktopListenerDLList	fDesktopListenerList;
138 
139 		// prevent recursive invokes
140 		bool					fWeAreInvoking;
141 };
142 
143 #endif
144