Renamed AS_WINDOW_TITLE to AS_SET_WINDOW_TITLE.

Fixed handling in ServerWindow as stippi's latest commit broke it.
It's now properly done with a separate ServerWindow::SetTitle() method,
that will also take care to rename the window's thread.
Changed naming the window thread in the app_server to "w:<team>:<title>".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13461 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-07-05 19:20:19 +00:00
parent 7942339dee
commit 2b1246d968
4 changed files with 35 additions and 15 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ enum {
AS_BEGIN_UPDATE, AS_BEGIN_UPDATE,
AS_END_UPDATE, AS_END_UPDATE,
AS_NEEDS_UPDATE, AS_NEEDS_UPDATE,
AS_WINDOW_TITLE, AS_SET_WINDOW_TITLE,
AS_ADD_TO_SUBSET, AS_ADD_TO_SUBSET,
AS_REM_FROM_SUBSET, AS_REM_FROM_SUBSET,
AS_SET_ALIGNMENT, AS_SET_ALIGNMENT,
+1 -1
View File
@@ -1446,7 +1446,7 @@ BWindow::SetTitle(const char *title)
// we notify the app_server so we can actually see the change // we notify the app_server so we can actually see the change
if (Lock()) { if (Lock()) {
fLink->StartMessage(AS_WINDOW_TITLE); fLink->StartMessage(AS_SET_WINDOW_TITLE);
fLink->AttachString(fTitle); fLink->AttachString(fTitle);
fLink->Flush(); fLink->Flush();
Unlock(); Unlock();
+31 -13
View File
@@ -128,9 +128,6 @@ ServerWindow::Init(BRect frame, uint32 look, uint32 feel, uint32 flags, uint32 w
fLink.SetSenderPort(fClientReplyPort); fLink.SetSenderPort(fClientReplyPort);
fLink.SetReceiverPort(fMessagePort); fLink.SetReceiverPort(fMessagePort);
// char name[60];
// snprintf(name, sizeof(name), "%ld: %s", fClientTeam, fTitle);
// We cannot call MakeWinBorder in the constructor, since it // We cannot call MakeWinBorder in the constructor, since it
fWinBorder = MakeWinBorder(frame, fTitle, look, feel, flags, workspace); fWinBorder = MakeWinBorder(frame, fTitle, look, feel, flags, workspace);
if (!fWinBorder) if (!fWinBorder)
@@ -149,7 +146,7 @@ ServerWindow::Run()
BAutolock locker(this); BAutolock locker(this);
char name[B_OS_NAME_LENGTH]; char name[B_OS_NAME_LENGTH];
snprintf(name, sizeof(name), "w:%s", fTitle); snprintf(name, sizeof(name), "w:%ld:%s", ClientTeam(), Title());
// Spawn our message-monitoring thread // Spawn our message-monitoring thread
fThread = spawn_thread(_message_thread, name, B_NORMAL_PRIORITY, this); fThread = spawn_thread(_message_thread, name, B_NORMAL_PRIORITY, this);
@@ -255,6 +252,34 @@ ServerWindow::Hide()
} }
void
ServerWindow::SetTitle(const char* newTitle)
{
const char* oldTitle = fTitle;
if (newTitle == NULL || !newTitle[0])
fTitle = strdup("Unnamed Window");
else
fTitle = strdup(newTitle);
if (fTitle == NULL) {
fTitle = oldTitle;
return;
}
free(const_cast<char*>(oldTitle));
if (Thread() >= B_OK) {
char name[B_OS_NAME_LENGTH];
snprintf(name, sizeof(name), "w:%ld:%s", ClientTeam(), fTitle);
rename_thread(Thread(), name);
}
if (fWinBorder != NULL)
fWinBorder->SetName(newTitle);
}
//! Requests that the ServerWindow's BWindow quit //! Requests that the ServerWindow's BWindow quit
void void
ServerWindow::NotifyQuitRequested() ServerWindow::NotifyQuitRequested()
@@ -1196,20 +1221,13 @@ myRootLayer->Unlock();
break; break;
} }
#endif #endif
case AS_WINDOW_TITLE: case AS_SET_WINDOW_TITLE:
{ {
char* newTitle; char* newTitle;
if (link.ReadString(&newTitle) == B_OK) { if (link.ReadString(&newTitle) == B_OK) {
printf("ServerWindow %s: Message SetTitle(\"%s\") requested, unimplemented\n", SetTitle(newTitle);
Title(), newTitle);
free(newTitle); free(newTitle);
} }
char* title;
link.ReadString(&title);
fWinBorder->SetName(title);
free(title);
break; break;
} }
+2
View File
@@ -96,6 +96,8 @@ public:
// to who we belong. who do we own. our title. // to who we belong. who do we own. our title.
inline ServerApp* App() const { return fServerApp; } inline ServerApp* App() const { return fServerApp; }
inline const WinBorder* GetWinBorder() const { return fWinBorder; } inline const WinBorder* GetWinBorder() const { return fWinBorder; }
void SetTitle(const char* newTitle);
inline const char* Title() const { return fTitle; } inline const char* Title() const { return fTitle; }
// related thread/team_id(s). // related thread/team_id(s).