Every BApplication (even applications which didn't use it) allocated a BPrivateScreen object. Now they are created/destroyed on demand (when a BScreen object is constructed), and reference counted, so that there is still only one per app. Note that since we are creating/deleting them, constructing a BScreen object can be more time consuming than before, but personally I find this approach much cleaner.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13006 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -57,7 +57,6 @@
|
|||||||
#include <MenuWindow.h>
|
#include <MenuWindow.h>
|
||||||
#include <ObjectLocker.h>
|
#include <ObjectLocker.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
#include <PrivateScreen.h>
|
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
@@ -70,12 +69,6 @@ BResources *BApplication::_app_resources = NULL;
|
|||||||
BLocker BApplication::_app_resources_lock("_app_resources_lock");
|
BLocker BApplication::_app_resources_lock("_app_resources_lock");
|
||||||
|
|
||||||
|
|
||||||
// Used by PrivateScreen.cpp
|
|
||||||
// TODO: This setup won`t let us have multiple screens. Change this.
|
|
||||||
namespace BPrivate {
|
|
||||||
BPrivateScreen *gPrivateScreen = NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
static property_info
|
static property_info
|
||||||
sPropertyInfo[] = {
|
sPropertyInfo[] = {
|
||||||
{
|
{
|
||||||
@@ -441,8 +434,6 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
|
|||||||
#ifndef RUN_WITHOUT_APP_SERVER
|
#ifndef RUN_WITHOUT_APP_SERVER
|
||||||
// Initialize the IK after we have set be_app because of a construction of a
|
// Initialize the IK after we have set be_app because of a construction of a
|
||||||
// BAppServerLink (which depends on be_app) nested inside the call to get_menu_info.
|
// BAppServerLink (which depends on be_app) nested inside the call to get_menu_info.
|
||||||
if (fInitError == B_OK)
|
|
||||||
get_scs();
|
|
||||||
if (fInitError == B_OK)
|
if (fInitError == B_OK)
|
||||||
fInitError = _init_interface_kit_();
|
fInitError = _init_interface_kit_();
|
||||||
// create global system cursors
|
// create global system cursors
|
||||||
@@ -1042,13 +1033,6 @@ BApplication::EndRectTracking()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BApplication::get_scs()
|
|
||||||
{
|
|
||||||
gPrivateScreen = new BPrivateScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BApplication::setup_server_heaps()
|
BApplication::setup_server_heaps()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,9 +24,10 @@
|
|||||||
// Description: BPrivateScreen is the class which does the real work
|
// Description: BPrivateScreen is the class which does the real work
|
||||||
// for the proxy class BScreen (it interacts with the app server).
|
// for the proxy class BScreen (it interacts with the app server).
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
#include <Debug.h>
|
||||||
|
#include <Locker.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "AppServerLink.h"
|
#include "AppServerLink.h"
|
||||||
@@ -44,10 +45,11 @@ struct screen_desc {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Defined in Application.cpp
|
static BPrivateScreen *sScreen;
|
||||||
namespace BPrivate {
|
static int32 sScreenRefCount;
|
||||||
extern BPrivateScreen *gPrivateScreen;
|
|
||||||
};
|
// used to synchronize creation/deletion of the sScreen object
|
||||||
|
static BLocker sScreenLock("screen lock");
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
@@ -55,30 +57,55 @@ using namespace BPrivate;
|
|||||||
BPrivateScreen *
|
BPrivateScreen *
|
||||||
BPrivateScreen::CheckOut(BWindow *win)
|
BPrivateScreen::CheckOut(BWindow *win)
|
||||||
{
|
{
|
||||||
// TODO: If we start supporting multiple monitors, we
|
sScreenLock.Lock();
|
||||||
// should return the right screen for the passed BWindow
|
|
||||||
return gPrivateScreen;
|
if (atomic_add(&sScreenRefCount, 1) == 0) {
|
||||||
|
// TODO: If we start supporting multiple monitors, we
|
||||||
|
// should return the right screen for the passed BWindow
|
||||||
|
ASSERT(sScreen == NULL);
|
||||||
|
sScreen = new BPrivateScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
sScreenLock.Unlock();
|
||||||
|
|
||||||
|
return sScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPrivateScreen *
|
BPrivateScreen *
|
||||||
BPrivateScreen::CheckOut(screen_id id)
|
BPrivateScreen::CheckOut(screen_id id)
|
||||||
{
|
{
|
||||||
// TODO: If we start supporting multiple monitors, we
|
sScreenLock.Lock();
|
||||||
// should return the right object for the given screen_id
|
|
||||||
return gPrivateScreen;
|
if (atomic_add(&sScreenRefCount, 1) == 0) {
|
||||||
|
// TODO: If we start supporting multiple monitors, we
|
||||||
|
// should return the right object for the given screen_id
|
||||||
|
ASSERT(sScreen == NULL);
|
||||||
|
sScreen = new BPrivateScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
sScreenLock.Unlock();
|
||||||
|
|
||||||
|
return sScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPrivateScreen::Return(BPrivateScreen *screen)
|
BPrivateScreen::Return(BPrivateScreen *screen)
|
||||||
{
|
{
|
||||||
// Not much to do here. I guess it's some legacy from pre-R5,
|
sScreenLock.Lock();
|
||||||
// where BScreen could not be used for long time,
|
|
||||||
// as they blocked the BApplication
|
if (atomic_add(&sScreenRefCount, -1) == 1) {
|
||||||
|
// TODO: Check if the passed object is the same we are deleting
|
||||||
|
// here. Not much important for now though, since we only have one.
|
||||||
|
delete sScreen;
|
||||||
|
sScreen = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sScreenLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivateScreen::SetToNext()
|
BPrivateScreen::SetToNext()
|
||||||
{
|
{
|
||||||
@@ -426,7 +453,7 @@ BPrivateScreen::get_screen_desc(screen_desc *desc)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Private, called by BApplication::get_scs()
|
// Private, called by BApplication::get_scs()
|
||||||
BPrivateScreen::BPrivateScreen()
|
BPrivateScreen::BPrivateScreen()
|
||||||
:
|
:
|
||||||
@@ -445,7 +472,7 @@ BPrivateScreen::BPrivateScreen()
|
|||||||
if (reply == SERVER_TRUE) {
|
if (reply == SERVER_TRUE) {
|
||||||
fColorMap = (color_map *)malloc(sizeof(color_map));
|
fColorMap = (color_map *)malloc(sizeof(color_map));
|
||||||
fOwnsColorMap = true;
|
fOwnsColorMap = true;
|
||||||
// TODO: This doesn't work. We probably run into a port
|
// TODO: This doesn't work. We probably ran into a port
|
||||||
// capacity issue ?
|
// capacity issue ?
|
||||||
//link.Read<color_map>(fColorMap);
|
//link.Read<color_map>(fColorMap);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user