Turns out the whole "active app" mechanism in the registrar wasn't used at all; the

Switcher now works as expected.
* Renamed TRoster::ActivateApp() to UpdateActiveApp(), as the app is already activated
  at that point (the registrar only keeps track of it).
* BWindow::DispatchMessage() now calls the new BRoster::Private::UpdateActiveApp()
  method when it receives a B_WINDOW_ACTIVATED message.
* Added BRoster::_UpdateActiveApp() which calls the new B_REG_UPDATE_ACTIVE_APP.
* Removed now unused B_REG_ACTIVATE_APP.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19857 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-01-18 17:45:08 +00:00
parent badbad99a9
commit c2f641f2e5
8 changed files with 121 additions and 104 deletions
+34 -5
View File
@@ -1,9 +1,10 @@
/*
* Copyright 2001-2006, Haiku.
* Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold ([email protected])
* Axel Dörfler, [email protected]
*/
/*! BRoster class lets you launch apps and keeps track of apps
@@ -510,13 +511,14 @@ BRoster::GetRunningAppInfo(team_id team, app_info *info) const
status_t
BRoster::GetActiveAppInfo(app_info *info) const
{
status_t error = (info ? B_OK : B_BAD_VALUE);
if (info == NULL)
return B_BAD_VALUE;
// compose the request message
BMessage request(B_REG_GET_APP_INFO);
// send the request
BMessage reply;
if (error == B_OK)
error = fMessenger.SendMessage(&request, &reply);
status_t error = fMessenger.SendMessage(&request, &reply);
// evaluate the reply
if (error == B_OK) {
if (reply.what == B_REG_SUCCESS)
@@ -1732,7 +1734,34 @@ BRoster::_ApplicationCrashed(team_id team)
}
// _LaunchApp
/*!
Tells the registrar which application is currently active.
It's called from within BWindow on B_WINDOW_ACTIVATED messages.
*/
status_t
BRoster::_UpdateActiveApp(team_id team) const
{
if (team < B_OK)
return B_BAD_TEAM_ID;
// compose the request message
BMessage request(B_REG_UPDATE_ACTIVE_APP);
status_t status = request.AddInt32("team", team);
// send the request
BMessage reply;
if (status == B_OK)
status = fMessenger.SendMessage(&request, &reply);
// evaluate the reply
if (status == B_OK && reply.what != B_REG_SUCCESS
&& reply.FindInt32("error", &status) != B_OK)
status = B_ERROR;
return status;
}
/*! \brief Launches the application associated with the supplied MIME type or
the entry referred to by the supplied entry_ref.
+9 -2
View File
@@ -29,6 +29,7 @@
#include <MenuPrivate.h>
#include <MessagePrivate.h>
#include <PortLink.h>
#include <RosterPrivate.h>
#include <ServerProtocol.h>
#include <TokenSpace.h>
#include <tracker_private.h>
@@ -905,12 +906,18 @@ FrameMoved(origin);
if (msg->FindBool("active", &active) == B_OK
&& active != fActive) {
fActive = active;
if (active) {
// notify registrar about the active app
BRoster::Private roster;
roster.UpdateActiveApp(be_app->Team());
}
WindowActivated(active);
// call hook function 'WindowActivated(bool)' for all
// views attached to this window.
fTopView->_Activate(active);
// we notify the input server if we are gaining or losing focus
// from a view which has the B_INPUT_METHOD_AWARE on a window
// (de)activation