2 * Copyright 2001-2009, Haiku.
3 * Distributed under the terms of the MIT License.
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Adrian Oanca <adioanca@gmail.com>
8 * Stephan Aßmus <superstippi@gmx.de>
9 * Stefano Ceccherini (burton666@libero.it)
10 * Axel Dörfler, axeld@pinc-software.de
12 #ifndef SERVER_WINDOW_H
13 #define SERVER_WINDOW_H
16 #include <GraphicsDefs.h>
19 #include <Messenger.h>
26 #include <TokenSpace.h>
28 #include "EventDispatcher.h"
29 #include "MessageLooper.h"
44 class DirectWindowInfo
;
47 #define AS_UPDATE_DECORATOR 'asud'
48 #define AS_UPDATE_COLORS 'asuc'
49 #define AS_UPDATE_FONTS 'asuf'
52 class ServerWindow
: public MessageLooper
{
54 ServerWindow(const char *title
, ServerApp
*app
,
55 port_id clientPort
, port_id looperPort
,
57 virtual ~ServerWindow();
59 status_t
Init(BRect frame
, window_look look
,
60 window_feel feel
, uint32 flags
,
63 virtual port_id
MessagePort() const { return fMessagePort
; }
65 ::EventTarget
& EventTarget() { return fEventTarget
; }
67 inline ServerApp
* App() const { return fServerApp
; }
68 ::Desktop
* Desktop() const { return fDesktop
; }
69 ::Window
* Window() const;
71 // methods for sending various messages to client.
72 void NotifyQuitRequested();
73 void NotifyMinimize(bool minimize
);
77 const BMessenger
& FocusMessenger() const
78 { return fFocusMessenger
; }
79 const BMessenger
& HandlerMessenger() const
80 { return fHandlerMessenger
; }
82 void ScreenChanged(const BMessage
* message
);
83 status_t
SendMessageToClient(const BMessage
* message
,
84 int32 target
= B_NULL_TOKEN
) const;
86 virtual ::Window
* MakeWindow(BRect frame
, const char* name
,
87 window_look look
, window_feel feel
,
88 uint32 flags
, uint32 workspace
);
90 void SetTitle(const char* newTitle
);
91 inline const char* Title() const { return fTitle
; }
93 // related thread/team_id(s).
94 inline team_id
ClientTeam() const { return fClientTeam
; }
96 inline port_id
ClientLooperPort () const
97 { return fClientLooperPort
; }
99 inline int32
ClientToken() const { return fClientToken
; }
100 inline int32
ServerToken() const { return fServerToken
; }
102 void RequestRedraw();
104 void GetInfo(window_info
& info
);
106 void HandleDirectConnection(int32 bufferState
,
107 int32 driverState
= 0);
108 bool HasDirectFrameBufferAccess() const
109 { return fDirectWindowInfo
!= NULL
; }
110 bool IsDirectlyAccessing() const
111 { return fIsDirectlyAccessing
; }
113 void ResyncDrawState();
116 inline void UpdateCurrentDrawingRegion()
117 { _UpdateCurrentDrawingRegion(); };
120 View
* _CreateView(BPrivate::LinkReceiver
&link
,
126 // message handling methods.
127 void _DispatchMessage(int32 code
,
128 BPrivate::LinkReceiver
&link
);
129 void _DispatchViewMessage(int32 code
,
130 BPrivate::LinkReceiver
&link
);
131 void _DispatchViewDrawingMessage(int32 code
,
132 BPrivate::LinkReceiver
&link
);
133 bool _DispatchPictureMessage(int32 code
,
134 BPrivate::LinkReceiver
&link
);
135 void _MessageLooper();
136 virtual void _PrepareQuit();
137 virtual void _GetLooperName(char* name
, size_t size
);
139 void _ResizeToFullScreen();
140 status_t
_EnableDirectWindowMode();
141 void _DirectWindowSetFullScreen(bool set
);
143 void _SetCurrentView(View
* view
);
144 void _UpdateDrawState(View
* view
);
145 void _UpdateCurrentDrawingRegion();
147 bool _MessageNeedsAllWindowsLocked(
154 ServerApp
* fServerApp
;
156 bool fWindowAddedToDesktop
;
160 port_id fMessagePort
;
161 port_id fClientReplyPort
;
162 port_id fClientLooperPort
;
163 BMessenger fFocusMessenger
;
164 BMessenger fHandlerMessenger
;
165 ::EventTarget fEventTarget
;
167 int32 fRedrawRequested
;
173 BRegion fCurrentDrawingRegion
;
174 bool fCurrentDrawingRegionValid
;
176 DirectWindowInfo
* fDirectWindowInfo
;
177 bool fIsDirectlyAccessing
;
180 #endif // SERVER_WINDOW_H