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:
@@ -55,6 +55,23 @@ MessageLooper::Run()
|
|||||||
void
|
void
|
||||||
MessageLooper::Quit()
|
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
|
void
|
||||||
MessageLooper::_GetLooperName(char* name, size_t length)
|
MessageLooper::_GetLooperName(char* name, size_t length)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class MessageLooper : public BLocker {
|
|||||||
thread_id Thread() const { return fThread; }
|
thread_id Thread() const { return fThread; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual void _PrepareQuit();
|
||||||
virtual void _GetLooperName(char* name, size_t length);
|
virtual void _GetLooperName(char* name, size_t length);
|
||||||
virtual void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
|
virtual void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
|
||||||
virtual void _MessageLooper();
|
virtual void _MessageLooper();
|
||||||
@@ -39,4 +40,6 @@ class MessageLooper : public BLocker {
|
|||||||
bool fQuitting;
|
bool fQuitting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint32 kMsgQuitLooper = 'quit';
|
||||||
|
|
||||||
#endif /* MESSAGE_LOOPER_H */
|
#endif /* MESSAGE_LOOPER_H */
|
||||||
|
|||||||
@@ -10,6 +10,16 @@
|
|||||||
* Axel Dörfler, [email protected]
|
* 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 <new>
|
||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
@@ -65,9 +75,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgWindowQuit = 'winQ';
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
|
|
||||||
@@ -168,27 +175,15 @@ ServerWindow::Run()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerWindow::Quit()
|
ServerWindow::_PrepareQuit()
|
||||||
{
|
{
|
||||||
fQuitting = true;
|
|
||||||
|
|
||||||
if (fThread < B_OK) {
|
|
||||||
delete this;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fThread == find_thread(NULL)) {
|
if (fThread == find_thread(NULL)) {
|
||||||
// make sure we're hidden
|
// make sure we're hidden
|
||||||
Hide();
|
Hide();
|
||||||
|
|
||||||
App()->RemoveWindow(this);
|
App()->RemoveWindow(this);
|
||||||
|
} else if (fThread >= B_OK)
|
||||||
delete this;
|
|
||||||
exit_thread(0);
|
|
||||||
} else {
|
|
||||||
PostMessage(AS_HIDE_WINDOW);
|
PostMessage(AS_HIDE_WINDOW);
|
||||||
PostMessage(kMsgWindowQuit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2141,7 +2136,7 @@ ServerWindow::_MessageLooper()
|
|||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case AS_DELETE_WINDOW:
|
case AS_DELETE_WINDOW:
|
||||||
case kMsgWindowQuit:
|
case kMsgQuitLooper:
|
||||||
// this means the client has been killed
|
// this means the client has been killed
|
||||||
STRACE(("ServerWindow %s received 'AS_DELETE_WINDOW' message code\n",
|
STRACE(("ServerWindow %s received 'AS_DELETE_WINDOW' message code\n",
|
||||||
Title()));
|
Title()));
|
||||||
|
|||||||
@@ -44,15 +44,6 @@ struct window_info;
|
|||||||
#define AS_UPDATE_COLORS 'asuc'
|
#define AS_UPDATE_COLORS 'asuc'
|
||||||
#define AS_UPDATE_FONTS 'asuf'
|
#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 {
|
class ServerWindow : public MessageLooper {
|
||||||
public:
|
public:
|
||||||
ServerWindow(const char *title, ServerApp *app,
|
ServerWindow(const char *title, ServerApp *app,
|
||||||
@@ -64,7 +55,6 @@ public:
|
|||||||
uint32 feel, uint32 flags,
|
uint32 feel, uint32 flags,
|
||||||
uint32 workspace);
|
uint32 workspace);
|
||||||
virtual bool Run();
|
virtual bool Run();
|
||||||
virtual void Quit();
|
|
||||||
|
|
||||||
void ReplaceDecorator();
|
void ReplaceDecorator();
|
||||||
void Show();
|
void Show();
|
||||||
@@ -121,8 +111,9 @@ private:
|
|||||||
void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
|
void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
|
||||||
void _DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link);
|
void _DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link);
|
||||||
void _MessageLooper();
|
void _MessageLooper();
|
||||||
virtual void _GetLooperName(char* name, size_t size);
|
virtual void _PrepareQuit();
|
||||||
virtual port_id _MessagePort() const { return fMessagePort; }
|
virtual void _GetLooperName(char* name, size_t size);
|
||||||
|
virtual port_id _MessagePort() const { return fMessagePort; }
|
||||||
|
|
||||||
// TODO: Move me elsewhere
|
// TODO: Move me elsewhere
|
||||||
status_t PictureToRegion(ServerPicture *picture,
|
status_t PictureToRegion(ServerPicture *picture,
|
||||||
|
|||||||
Reference in New Issue
Block a user