libbe: ui_color() now works without UI connection.
* Since the app_server is a BApplication, too, now, Workspaces would trigger this problem. * Now it checks whether the shared memory is actually set, and only uses it in this case. This will also fix using ui_color() in any BServer without UI connection.
This commit is contained in:
@@ -343,11 +343,12 @@ BApplication::_InitData(const char* signature, bool initGUI, status_t* _error)
|
|||||||
{
|
{
|
||||||
DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
|
DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
|
||||||
// check whether there exists already an application
|
// check whether there exists already an application
|
||||||
if (be_app)
|
if (be_app != NULL)
|
||||||
debugger("2 BApplication objects were created. Only one is allowed.");
|
debugger("2 BApplication objects were created. Only one is allowed.");
|
||||||
|
|
||||||
fServerLink = new BPrivate::PortLink(-1, -1);
|
fServerLink = new BPrivate::PortLink(-1, -1);
|
||||||
fServerAllocator = NULL;
|
fServerAllocator = NULL;
|
||||||
|
fServerReadOnlyMemory = NULL;
|
||||||
fInitialWorkspace = 0;
|
fInitialWorkspace = 0;
|
||||||
//fDraggedMessage = NULL;
|
//fDraggedMessage = NULL;
|
||||||
fReadyToRunCalled = false;
|
fReadyToRunCalled = false;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2010, Haiku, Inc.
|
* Copyright 2001-2015, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -947,7 +947,7 @@ get_mouse(BPoint* screenWhere, uint32* buttons)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_CURSOR_POSITION);
|
link.StartMessage(AS_GET_CURSOR_POSITION);
|
||||||
|
|
||||||
int32 code;
|
int32 code;
|
||||||
status_t ret = link.FlushWithReply(code);
|
status_t ret = link.FlushWithReply(code);
|
||||||
if (ret != B_OK)
|
if (ret != B_OK)
|
||||||
@@ -980,21 +980,21 @@ get_mouse_bitmap(BBitmap** bitmap, BPoint* hotspot)
|
|||||||
{
|
{
|
||||||
if (bitmap == NULL && hotspot == NULL)
|
if (bitmap == NULL && hotspot == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_CURSOR_BITMAP);
|
link.StartMessage(AS_GET_CURSOR_BITMAP);
|
||||||
|
|
||||||
int32 code;
|
int32 code;
|
||||||
status_t status = link.FlushWithReply(code);
|
status_t status = link.FlushWithReply(code);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
if (code != B_OK)
|
if (code != B_OK)
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
uint32 size = 0;
|
uint32 size = 0;
|
||||||
uint32 cursorWidth = 0;
|
uint32 cursorWidth = 0;
|
||||||
uint32 cursorHeight = 0;
|
uint32 cursorHeight = 0;
|
||||||
|
|
||||||
// if link.Read() returns an error, the same error will be returned on
|
// if link.Read() returns an error, the same error will be returned on
|
||||||
// subsequent calls, so we'll check only the return value of the last call
|
// subsequent calls, so we'll check only the return value of the last call
|
||||||
link.Read<uint32>(&size);
|
link.Read<uint32>(&size);
|
||||||
@@ -1011,16 +1011,16 @@ get_mouse_bitmap(BBitmap** bitmap, BPoint* hotspot)
|
|||||||
data = malloc(size);
|
data = malloc(size);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
status = link.Read(data, size);
|
status = link.Read(data, size);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
free(data);
|
free(data);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBitmap* cursorBitmap = new (std::nothrow) BBitmap(BRect(0, 0,
|
BBitmap* cursorBitmap = new (std::nothrow) BBitmap(BRect(0, 0,
|
||||||
cursorWidth - 1, cursorHeight - 1), B_RGBA32);
|
cursorWidth - 1, cursorHeight - 1), B_RGBA32);
|
||||||
|
|
||||||
if (cursorBitmap == NULL) {
|
if (cursorBitmap == NULL) {
|
||||||
free(data);
|
free(data);
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -1030,12 +1030,12 @@ get_mouse_bitmap(BBitmap** bitmap, BPoint* hotspot)
|
|||||||
cursorBitmap->SetBits(data, size, 0, B_RGBA32);
|
cursorBitmap->SetBits(data, size, 0, B_RGBA32);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
if (status == B_OK && bitmap != NULL)
|
if (status == B_OK && bitmap != NULL)
|
||||||
*bitmap = cursorBitmap;
|
*bitmap = cursorBitmap;
|
||||||
else
|
else
|
||||||
delete cursorBitmap;
|
delete cursorBitmap;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1076,10 +1076,11 @@ ui_color(color_which which)
|
|||||||
return make_color(0, 0, 0);
|
return make_color(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (be_app) {
|
if (be_app != NULL) {
|
||||||
server_read_only_memory* shared
|
server_read_only_memory* shared
|
||||||
= BApplication::Private::ServerReadOnlyMemory();
|
= BApplication::Private::ServerReadOnlyMemory();
|
||||||
return shared->colors[index];
|
if (shared != NULL)
|
||||||
|
return shared->colors[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
return kDefaultColors[index];
|
return kDefaultColors[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user