Split ServerWindow::Quit() into two parts, and moved the generic one to

the MessageLooper class - the other part is called from there as virtual
_PrepareQuit().
Moved the class documentation to the source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13815 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-07-24 17:13:02 +00:00
parent b2355ae66d
commit c6a2527297
4 changed files with 43 additions and 30 deletions
+24
View File
@@ -55,6 +55,23 @@ MessageLooper::Run()
void
MessageLooper::Quit()
{
fQuitting = true;
_PrepareQuit();
if (fThread < B_OK) {
// thread has not been started yet
delete this;
return;
}
if (fThread == find_thread(NULL)) {
// called from our message looper
delete this;
exit_thread(0);
} else {
// called from a different thread
PostMessage(kMsgQuitLooper);
}
}
@@ -71,6 +88,13 @@ MessageLooper::PostMessage(int32 code)
}
void
MessageLooper::_PrepareQuit()
{
// to be implemented by subclasses
}
void
MessageLooper::_GetLooperName(char* name, size_t length)
{
+3
View File
@@ -26,6 +26,7 @@ class MessageLooper : public BLocker {
thread_id Thread() const { return fThread; }
private:
virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t length);
virtual void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
virtual void _MessageLooper();
@@ -39,4 +40,6 @@ class MessageLooper : public BLocker {
bool fQuitting;
};
static const uint32 kMsgQuitLooper = 'quit';
#endif /* MESSAGE_LOOPER_H */
+13 -18
View File
@@ -10,6 +10,16 @@
* Axel Dörfler, [email protected]
*/
/*!
\class ServerWindow
\brief Shadow BWindow class
A ServerWindow handles all the intraserver tasks required of it by its BWindow. There are
too many tasks to list as being done by them, but they include handling View transactions,
coordinating and linking a window's WinBorder half with its messaging half, dispatching
mouse and key events from the server to its window, and other such things.
*/
#include <new>
#include <AppDefs.h>
@@ -65,9 +75,6 @@
#endif
static const uint32 kMsgWindowQuit = 'winQ';
/*!
\brief Constructor
@@ -168,27 +175,15 @@ ServerWindow::Run()
void
ServerWindow::Quit()
ServerWindow::_PrepareQuit()
{
fQuitting = true;
if (fThread < B_OK) {
delete this;
return;
}
if (fThread == find_thread(NULL)) {
// make sure we're hidden
Hide();
App()->RemoveWindow(this);
delete this;
exit_thread(0);
} else {
} else if (fThread >= B_OK)
PostMessage(AS_HIDE_WINDOW);
PostMessage(kMsgWindowQuit);
}
}
@@ -2141,7 +2136,7 @@ ServerWindow::_MessageLooper()
switch (code) {
case AS_DELETE_WINDOW:
case kMsgWindowQuit:
case kMsgQuitLooper:
// this means the client has been killed
STRACE(("ServerWindow %s received 'AS_DELETE_WINDOW' message code\n",
Title()));
+3 -12
View File
@@ -44,15 +44,6 @@ struct window_info;
#define AS_UPDATE_COLORS 'asuc'
#define AS_UPDATE_FONTS 'asuf'
/*!
\class ServerWindow ServerWindow.h
\brief Shadow BWindow class
A ServerWindow handles all the intraserver tasks required of it by its BWindow. There are
too many tasks to list as being done by them, but they include handling View transactions,
coordinating and linking a window's WinBorder half with its messaging half, dispatching
mouse and key events from the server to its window, and other such things.
*/
class ServerWindow : public MessageLooper {
public:
ServerWindow(const char *title, ServerApp *app,
@@ -64,7 +55,6 @@ public:
uint32 feel, uint32 flags,
uint32 workspace);
virtual bool Run();
virtual void Quit();
void ReplaceDecorator();
void Show();
@@ -121,8 +111,9 @@ private:
void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
void _DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link);
void _MessageLooper();
virtual void _GetLooperName(char* name, size_t size);
virtual port_id _MessagePort() const { return fMessagePort; }
virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t size);
virtual port_id _MessagePort() const { return fMessagePort; }
// TODO: Move me elsewhere
status_t PictureToRegion(ServerPicture *picture,