usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / servers / app / ServerWindow.h
blobf32330c01d52009466100654047d8cc4079fb5b5
1 /*
2 * Copyright 2001-2009, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
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>
17 #include <Locker.h>
18 #include <Message.h>
19 #include <Messenger.h>
20 #include <Rect.h>
21 #include <Region.h>
22 #include <String.h>
23 #include <Window.h>
25 #include <PortLink.h>
26 #include <TokenSpace.h>
28 #include "EventDispatcher.h"
29 #include "MessageLooper.h"
32 class BString;
33 class BMessenger;
34 class BPoint;
35 class BMessage;
37 class Desktop;
38 class ServerApp;
39 class Decorator;
40 class Window;
41 class Workspace;
42 class View;
43 class ServerPicture;
44 class DirectWindowInfo;
45 struct window_info;
47 #define AS_UPDATE_DECORATOR 'asud'
48 #define AS_UPDATE_COLORS 'asuc'
49 #define AS_UPDATE_FONTS 'asuf'
52 class ServerWindow : public MessageLooper {
53 public:
54 ServerWindow(const char *title, ServerApp *app,
55 port_id clientPort, port_id looperPort,
56 int32 clientToken);
57 virtual ~ServerWindow();
59 status_t Init(BRect frame, window_look look,
60 window_feel feel, uint32 flags,
61 uint32 workspace);
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);
74 void NotifyZoom();
76 // util methods.
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();
115 // TODO: Change this
116 inline void UpdateCurrentDrawingRegion()
117 { _UpdateCurrentDrawingRegion(); };
119 private:
120 View* _CreateView(BPrivate::LinkReceiver &link,
121 View **_parent);
123 void _Show();
124 void _Hide();
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(
148 uint32 code) const;
150 private:
151 char* fTitle;
153 ::Desktop* fDesktop;
154 ServerApp* fServerApp;
155 ::Window* fWindow;
156 bool fWindowAddedToDesktop;
158 team_id fClientTeam;
160 port_id fMessagePort;
161 port_id fClientReplyPort;
162 port_id fClientLooperPort;
163 BMessenger fFocusMessenger;
164 BMessenger fHandlerMessenger;
165 ::EventTarget fEventTarget;
167 int32 fRedrawRequested;
169 int32 fServerToken;
170 int32 fClientToken;
172 View* fCurrentView;
173 BRegion fCurrentDrawingRegion;
174 bool fCurrentDrawingRegionValid;
176 DirectWindowInfo* fDirectWindowInfo;
177 bool fIsDirectlyAccessing;
180 #endif // SERVER_WINDOW_H