From 6d5488e18ac47e1c47706227b9a21524ae7874e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 25 Apr 2006 20:12:06 +0000 Subject: [PATCH] * There is now a server_read_only_memory structure that is placed in a (surprise!) read-only area shared between the Desktop and all applications. * Right now, this area only contains the desktop colors, ie. B_PANEL_BACKGROUND_COLOR etc.; ui_color() no longer needs to ask the server for these colors. * The ui_colors are now maintained by DesktopSettings, though ColorSet is still there. * The default colors are now hardcoded once and for everyone in InterfaceDefs.h, ie. the app_server uses them as well. * Desktop::Init() can now also return an error (but that is not yet accounted for). * Cleaned up InterfaceDefs.h. * Fixed wrong include in moreUTF8.h. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17232 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/app/Application.h | 7 +- headers/os/interface/InterfaceDefs.h | 209 +++++++++----------- headers/private/app/ApplicationPrivate.h | 5 + headers/private/app/ServerMemoryAllocator.h | 3 +- headers/private/app/ServerReadOnlyMemory.h | 34 ++++ headers/private/interface/DefaultColors.h | 18 ++ headers/private/interface/moreUTF8.h | 7 +- src/kits/app/Application.cpp | 28 ++- src/kits/app/ServerMemoryAllocator.cpp | 24 +-- src/kits/interface/InterfaceDefs.cpp | 119 +++++------ src/servers/app/Desktop.cpp | 33 +++- src/servers/app/Desktop.h | 6 +- src/servers/app/DesktopSettings.cpp | 11 +- src/servers/app/DesktopSettingsPrivate.h | 6 +- src/servers/app/ServerApp.cpp | 3 +- 15 files changed, 284 insertions(+), 229 deletions(-) create mode 100644 headers/private/app/ServerReadOnlyMemory.h create mode 100644 headers/private/interface/DefaultColors.h diff --git a/headers/os/app/Application.h b/headers/os/app/Application.h index 222fbaba31..e44841d211 100644 --- a/headers/os/app/Application.h +++ b/headers/os/app/Application.h @@ -34,8 +34,7 @@ namespace BPrivate { class BApplication : public BLooper { public: BApplication(const char* signature); - BApplication(const char* signature, - status_t* error); + BApplication(const char* signature, status_t* error); virtual ~BApplication(); // Archiving @@ -138,7 +137,6 @@ private: */ bool _QuitAllWindows(bool force); bool _WindowQuitLoop(bool quitFilePanels, bool force); void _ArgvReceived(BMessage* message); - void SetAppCursor(); uint32 InitialWorkspace(); int32 _CountWindows(bool includeMenus) const; @@ -158,7 +156,8 @@ private: //_drag_data_* fDraggedMessage; BMessageRunner* fPulseRunner; status_t fInitError; - uint32 _reserved[13]; + void* fServerReadOnlyMemory; + uint32 _reserved[12]; bool fReadyToRunCalled; }; diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index bf9c3f184c..ca278c0118 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -1,57 +1,22 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: InterfaceDefs.h -// Author: Erik Jaesler (erik@cgsoftware.com) -// Description: General Interface Kit definitions and global functions. -//------------------------------------------------------------------------------ - +/* + * Copyright (c) 2001-2006, Haiku, Inc. + * Distributed under the terms of the MIT license. + * + * Authors: + * Erik Jaesler (erik@cgsoftware.com) + */ #ifndef _INTERFACE_DEFS_H #define _INTERFACE_DEFS_H -// Standard Includes ----------------------------------------------------------- -// System Includes ------------------------------------------------------------- #include #include #include -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - class BRect; -/*----------------------------------------------------------------*/ -struct key_info { - uint32 modifiers; - uint8 key_states[16]; -}; - -/*----------------------------------------------------------------*/ +// some handy UTF-8 characters #define B_UTF8_ELLIPSIS "\xE2\x80\xA6" #define B_UTF8_OPEN_QUOTE "\xE2\x80\x9C" @@ -67,86 +32,97 @@ struct key_info { #define B_MAX_MOUSE_BUTTONS 16 #endif -/*----------------------------------------------------------------*/ -enum { B_BACKSPACE = 0x08, - B_RETURN = 0x0a, - B_ENTER = 0x0a, - B_SPACE = 0x20, - B_TAB = 0x09, - B_ESCAPE = 0x1b, - B_SUBSTITUTE = 0x1a, +// key definitions - B_LEFT_ARROW = 0x1c, - B_RIGHT_ARROW = 0x1d, - B_UP_ARROW = 0x1e, - B_DOWN_ARROW = 0x1f, +struct key_info { + uint32 modifiers; + uint8 key_states[16]; +}; - B_INSERT = 0x05, - B_DELETE = 0x7f, - B_HOME = 0x01, - B_END = 0x04, - B_PAGE_UP = 0x0b, - B_PAGE_DOWN = 0x0c, +enum { + B_BACKSPACE = 0x08, + B_RETURN = 0x0a, + B_ENTER = 0x0a, + B_SPACE = 0x20, + B_TAB = 0x09, + B_ESCAPE = 0x1b, + B_SUBSTITUTE = 0x1a, - B_FUNCTION_KEY = 0x10 }; + B_LEFT_ARROW = 0x1c, + B_RIGHT_ARROW = 0x1d, + B_UP_ARROW = 0x1e, + B_DOWN_ARROW = 0x1f, -enum { B_F1_KEY = 0x02, - B_F2_KEY = 0x03, - B_F3_KEY = 0x04, - B_F4_KEY = 0x05, - B_F5_KEY = 0x06, - B_F6_KEY = 0x07, - B_F7_KEY = 0x08, - B_F8_KEY = 0x09, - B_F9_KEY = 0x0a, - B_F10_KEY = 0x0b, - B_F11_KEY = 0x0c, - B_F12_KEY = 0x0d, - B_PRINT_KEY = 0x0e, - B_SCROLL_KEY = 0x0f, - B_PAUSE_KEY = 0x10 }; + B_INSERT = 0x05, + B_DELETE = 0x7f, + B_HOME = 0x01, + B_END = 0x04, + B_PAGE_UP = 0x0b, + B_PAGE_DOWN = 0x0c, + + B_FUNCTION_KEY = 0x10 +}; + +enum { + B_F1_KEY = 0x02, + B_F2_KEY = 0x03, + B_F3_KEY = 0x04, + B_F4_KEY = 0x05, + B_F5_KEY = 0x06, + B_F6_KEY = 0x07, + B_F7_KEY = 0x08, + B_F8_KEY = 0x09, + B_F9_KEY = 0x0a, + B_F10_KEY = 0x0b, + B_F11_KEY = 0x0c, + B_F12_KEY = 0x0d, + B_PRINT_KEY = 0x0e, + B_SCROLL_KEY = 0x0f, + B_PAUSE_KEY = 0x10 +}; struct key_map { - uint32 version; - uint32 caps_key; - uint32 scroll_key; - uint32 num_key; - uint32 left_shift_key; - uint32 right_shift_key; - uint32 left_command_key; - uint32 right_command_key; - uint32 left_control_key; - uint32 right_control_key; - uint32 left_option_key; - uint32 right_option_key; - uint32 menu_key; - uint32 lock_settings; - int32 control_map[128]; - int32 option_caps_shift_map[128]; - int32 option_caps_map[128]; - int32 option_shift_map[128]; - int32 option_map[128]; - int32 caps_shift_map[128]; - int32 caps_map[128]; - int32 shift_map[128]; - int32 normal_map[128]; - int32 acute_dead_key[32]; - int32 grave_dead_key[32]; - int32 circumflex_dead_key[32]; - int32 dieresis_dead_key[32]; - int32 tilde_dead_key[32]; - uint32 acute_tables; - uint32 grave_tables; - uint32 circumflex_tables; - uint32 dieresis_tables; - uint32 tilde_tables; + uint32 version; + uint32 caps_key; + uint32 scroll_key; + uint32 num_key; + uint32 left_shift_key; + uint32 right_shift_key; + uint32 left_command_key; + uint32 right_command_key; + uint32 left_control_key; + uint32 right_control_key; + uint32 left_option_key; + uint32 right_option_key; + uint32 menu_key; + uint32 lock_settings; + int32 control_map[128]; + int32 option_caps_shift_map[128]; + int32 option_caps_map[128]; + int32 option_shift_map[128]; + int32 option_map[128]; + int32 caps_shift_map[128]; + int32 caps_map[128]; + int32 shift_map[128]; + int32 normal_map[128]; + int32 acute_dead_key[32]; + int32 grave_dead_key[32]; + int32 circumflex_dead_key[32]; + int32 dieresis_dead_key[32]; + int32 tilde_dead_key[32]; + uint32 acute_tables; + uint32 grave_tables; + uint32 circumflex_tables; + uint32 dieresis_tables; + uint32 tilde_tables; }; struct mouse_map { - uint32 button[B_MAX_MOUSE_BUTTONS]; + uint32 button[B_MAX_MOUSE_BUTTONS]; }; + /*----------------------------------------------------------------*/ enum border_style { @@ -173,7 +149,7 @@ enum button_width { /*----------------------------------------------------------------*/ enum join_mode { - B_ROUND_JOIN=0, + B_ROUND_JOIN = 0, B_MITER_JOIN, B_BEVEL_JOIN, B_BUTT_JOIN, @@ -357,12 +333,6 @@ enum color_which { // the replacement for B_DESKTOP_COLOR. B_DESKTOP_COLOR = 5, B_WINDOW_TAB_COLOR = 3, - - B_RANDOM_COLOR = 0x80000000, - B_MICHELANGELO_FAVORITE_COLOR, - B_DSANDLER_FAVORITE_SKY_COLOR, - B_DSANDLER_FAVORITE_INK_COLOR, - B_DSANDLER_FAVORITE_SHOES_COLOR }; _IMPEXP_BE rgb_color ui_color(color_which which); @@ -386,7 +356,4 @@ const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT; const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT; const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT; -/*-------------------------------------------------------------*/ -/*-------------------------------------------------------------*/ - #endif // _INTERFACE_DEFS_H diff --git a/headers/private/app/ApplicationPrivate.h b/headers/private/app/ApplicationPrivate.h index 1ef0744192..bfd6a56d95 100644 --- a/headers/private/app/ApplicationPrivate.h +++ b/headers/private/app/ApplicationPrivate.h @@ -11,6 +11,8 @@ #include +struct server_read_only_memory; + class BApplication::Private { public: @@ -19,6 +21,9 @@ class BApplication::Private { static inline BPrivate::ServerMemoryAllocator* ServerAllocator() { return be_app->fServerAllocator; } + + static inline server_read_only_memory* ServerReadOnlyMemory() + { return (server_read_only_memory*)be_app->fServerReadOnlyMemory; } }; #endif // _APPLICATION_PRIVATE_H diff --git a/headers/private/app/ServerMemoryAllocator.h b/headers/private/app/ServerMemoryAllocator.h index 58c7245a06..08e053bdcb 100644 --- a/headers/private/app/ServerMemoryAllocator.h +++ b/headers/private/app/ServerMemoryAllocator.h @@ -21,7 +21,8 @@ class ServerMemoryAllocator { status_t InitCheck(); - status_t AddArea(area_id serverArea, area_id& _localArea, uint8*& _base); + status_t AddArea(area_id serverArea, area_id& _localArea, uint8*& _base, + bool readOnly = false); void RemoveArea(area_id serverArea); status_t AreaAndBaseFor(area_id serverArea, area_id& area, uint8*& base); diff --git a/headers/private/app/ServerReadOnlyMemory.h b/headers/private/app/ServerReadOnlyMemory.h new file mode 100644 index 0000000000..ed7fe70545 --- /dev/null +++ b/headers/private/app/ServerReadOnlyMemory.h @@ -0,0 +1,34 @@ +/* + * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef SERVER_READ_ONLY_MEMORY_H +#define SERVER_READ_ONLY_MEMORY_H + + +#include +#include + + +static const int32 kNumColors = 32; + +struct server_read_only_memory { + rgb_color colors[kNumColors]; +}; + + +static inline int32 +color_which_to_index(color_which which) +{ + if (which <= B_TOOLTIP_TEXT_COLOR) + return which - 1; + if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) + return which - B_SUCCESS_COLOR + B_TOOLTIP_TEXT_COLOR; + + return -1; +} + +#endif /* SERVER_READ_ONLY_MEMORY_H */ diff --git a/headers/private/interface/DefaultColors.h b/headers/private/interface/DefaultColors.h new file mode 100644 index 0000000000..592e1afb1e --- /dev/null +++ b/headers/private/interface/DefaultColors.h @@ -0,0 +1,18 @@ +/* + * Copyright 2006, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _DEFAULT_COLORS_H +#define _DEFAULT_COLORS_H + + +#include + + +namespace BPrivate { + +extern const rgb_color* kDefaultColors; + +} // namespace BPrivate + +#endif // _DEFAULT_COLORS_H diff --git a/headers/private/interface/moreUTF8.h b/headers/private/interface/moreUTF8.h index 811f28fde2..a1ff7e38fe 100644 --- a/headers/private/interface/moreUTF8.h +++ b/headers/private/interface/moreUTF8.h @@ -1,7 +1,9 @@ #ifndef __MOREUTF8 #define __MOREUTF8 -#include + +#include + static inline bool IsInsideGlyph(uchar ch) @@ -203,5 +205,4 @@ UTF8ToLength(const char *bytes) return length; } - -#endif +#endif // __MOREUTF8 diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index 49b0b192ea..88ee5c8a12 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -660,11 +660,11 @@ bool BApplication::IsCursorHidden() const { BPrivate::AppServerLink link; - int32 code = SERVER_FALSE; + int32 status = B_ERROR; link.StartMessage(AS_QUERY_CURSOR_HIDDEN); - link.FlushWithReply(code); + link.FlushWithReply(status); - return code == SERVER_TRUE; + return status == B_OK; } @@ -995,10 +995,6 @@ BApplication::_InitGUIContext() if (error != B_OK) return error; - error = _SetupServerAllocator(); - if (error != B_OK) - return error; - // Initialize the IK after we have set be_app because of a construction of a // AppServerLink (which depends on be_app) nested inside the call to get_menu_info. error = _init_interface_kit_(); @@ -1061,21 +1057,37 @@ BApplication::_ConnectToServer() fServerLink->Attach(_get_object_token_(this)); fServerLink->AttachString(fAppName); + area_id sharedReadOnlyArea; + if (fServerLink->FlushWithReply(code) == B_OK && code == B_OK) { // We don't need to contact the main app_server anymore // directly; we now talk to our server alter ego only. fServerLink->Read(&serverPort); - fServerLink->SetSenderPort(serverPort); + fServerLink->Read(&sharedReadOnlyArea); } else { fServerLink->SetSenderPort(-1); debugger("BApplication: couldn't obtain new app_server comm port"); return B_ERROR; } + fServerLink->SetSenderPort(serverPort); + + status_t status = _SetupServerAllocator(); + if (status != B_OK) + return status; + + area_id area; + uint8* base; + status = fServerAllocator->AddArea(sharedReadOnlyArea, area, base, true); + if (status < B_OK) + return status; + + fServerReadOnlyMemory = base; return B_OK; } + #if 0 void BApplication::send_drag(BMessage *message, int32 vs_token, BPoint offset, diff --git a/src/kits/app/ServerMemoryAllocator.cpp b/src/kits/app/ServerMemoryAllocator.cpp index 24aa915894..1c7a405e5a 100644 --- a/src/kits/app/ServerMemoryAllocator.cpp +++ b/src/kits/app/ServerMemoryAllocator.cpp @@ -58,7 +58,8 @@ ServerMemoryAllocator::InitCheck() status_t -ServerMemoryAllocator::AddArea(area_id serverArea, area_id& _area, uint8*& _base) +ServerMemoryAllocator::AddArea(area_id serverArea, area_id& _area, uint8*& _base, + bool readOnly) { area_mapping* mapping = new (std::nothrow) area_mapping; if (mapping == NULL || !fAreas.AddItem(mapping)) { @@ -66,19 +67,20 @@ ServerMemoryAllocator::AddArea(area_id serverArea, area_id& _area, uint8*& _base return B_NO_MEMORY; } -#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST - // reserve 128 MB of space for the area - void* base = (void*)0x60000000; - status_t status = _kern_reserve_heap_address_range((addr_t*)&base, - B_BASE_ADDRESS, 128 * 1024 * 1024); -#else - void* base; status_t status = B_ERROR; + void* base; +#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST + if (!readOnly) { + // reserve 128 MB of space for the area + base = (void*)0x60000000; + status = _kern_reserve_heap_address_range((addr_t*)&base, + B_BASE_ADDRESS, 128 * 1024 * 1024); + } #endif - mapping->local_area = clone_area("server_memory", &base, - status == B_OK ? B_EXACT_ADDRESS : B_BASE_ADDRESS, - B_READ_AREA | B_WRITE_AREA, serverArea); + mapping->local_area = clone_area(readOnly ? "server read-only memory" : "server_memory", + &base, status == B_OK ? B_EXACT_ADDRESS : B_BASE_ADDRESS, + B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA), serverArea); if (mapping->local_area < B_OK) { status = mapping->local_area; delete mapping; diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 91a2217bd2..c1e63bf3b5 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -10,7 +10,19 @@ /** Global functions and variables for the Interface Kit */ -#include +#include "moreUTF8.h" +#include "truncate_string.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -20,18 +32,10 @@ #include #include +#include #include #include -#include -#include -#include -#include -#include -#include - -#include "moreUTF8.h" -#include "truncate_string.h" // Private definitions not placed in public headers void _init_global_fonts_(); @@ -54,6 +58,35 @@ menu_info *_menu_info_ptr_; extern "C" const char B_NOTIFICATION_SENDER[] = "be:sender"; +static const rgb_color _kDefaultColors[kNumColors] = { + {216, 216, 216, 255}, // B_PANEL_BACKGROUND_COLOR + {216, 216, 216, 255}, // B_MENU_BACKGROUND_COLOR + {255, 0, 203, 255}, // B_WINDOW_TAB_COLOR + {0, 0, 229, 255}, // B_KEYBOARD_NAVIGATION_COLOR + {51, 102, 152, 255}, // B_DESKTOP_COLOR + {115, 120, 184, 255}, // B_MENU_SELECTED_BACKGROUND_COLOR + {0, 0, 0, 255}, // B_MENU_ITEM_TEXT_COLOR + {0, 0, 0, 255}, // B_MENU_SELECTED_ITEM_TEXT_COLOR + {0, 0, 0, 255}, // B_MENU_SELECTED_BORDER_COLOR + {0, 0, 0, 255}, // B_PANEL_TEXT_COLOR + {255, 255, 255, 255}, // B_DOCUMENT_BACKGROUND_COLOR + {0, 0, 0, 255}, // B_DOCUMENT_TEXT_COLOR + {245, 245, 245, 255}, // B_CONTROL_BACKGROUND_COLOR + {0, 0, 0, 255}, // B_CONTROL_TEXT_COLOR + {0, 0, 0, 255}, // B_CONTROL_BORDER_COLOR + {102, 152, 203, 255}, // B_CONTROL_HIGHLIGHT_COLOR + {0, 0, 0, 255}, // B_NAVIGATION_PULSE_COLOR + {255, 255, 255, 255}, // B_SHINE_COLOR + {0, 0, 0, 255}, // B_SHADOW_COLOR + {255, 255, 0, 255}, // B_TOOLTIP_BACKGROUND_COLOR + {0, 0, 0, 255}, // B_TOOLTIP_TEXT_COLOR + // 100... + {0, 255, 0, 255}, // B_SUCCESS_COLOR + {255, 0, 0, 255}, // B_FAILURE_COLOR + {} +}; +const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0]; + static status_t mode2parms(uint32 space, uint32 *out_space, int32 *width, int32 *height) @@ -686,66 +719,18 @@ mouse_mode() _IMPEXP_BE rgb_color ui_color(color_which which) { + int32 index = color_which_to_index(which); + if (index < 0 || index >= kNumColors) { + fprintf(stderr, "ui_color(): unknown color_which %d\n", which); + return make_color(0, 0, 0); + } + if (be_app) { - rgb_color color; - BPrivate::AppServerLink link; - link.StartMessage(AS_GET_UI_COLOR); - link.Attach(which); - - int32 code; - if (link.FlushWithReply(code) == B_OK && code == B_OK) { - link.Read(&color); - return color; - } + server_read_only_memory* shared = BApplication::Private::ServerReadOnlyMemory(); + return shared->colors[index]; } - switch (which) { - case B_PANEL_BACKGROUND_COLOR: - return make_color(216,216,216); - case B_PANEL_TEXT_COLOR: - return make_color(0,0,0); - case B_DOCUMENT_BACKGROUND_COLOR: - return make_color(255,255,255); - case B_DOCUMENT_TEXT_COLOR: - return make_color(0,0,0); - case B_CONTROL_BACKGROUND_COLOR: - return make_color(245,245,245); - case B_CONTROL_TEXT_COLOR: - return make_color(0,0,0); - case B_CONTROL_BORDER_COLOR: - return make_color(0,0,0); - case B_CONTROL_HIGHLIGHT_COLOR: - return make_color(102, 152, 203); - case B_NAVIGATION_BASE_COLOR: - return make_color(0,0,229); - case B_NAVIGATION_PULSE_COLOR: - return make_color(0,0,0); - case B_SHINE_COLOR: - return make_color(255,255,255); - case B_SHADOW_COLOR: - return make_color(0,0,0); - case B_MENU_BACKGROUND_COLOR: - return make_color(216,216,216); - case B_MENU_SELECTED_BACKGROUND_COLOR: - return make_color(115,120,184); - case B_MENU_ITEM_TEXT_COLOR: - return make_color(0,0,0); - case B_MENU_SELECTED_BORDER_COLOR: - return make_color(0,0,0); - case B_TOOLTIP_BACKGROUND_COLOR: - return make_color(255,255,0); - case B_TOOLTIP_TEXT_COLOR: - return make_color(0,0,0); - case B_SUCCESS_COLOR: - return make_color(0,255,0); - case B_FAILURE_COLOR: - return make_color(255,0,0); - case B_WINDOW_TAB_COLOR: - return make_color(255,0,203); - default: - fprintf(stderr, "ui_color(): unknown color_which %d\n", which); - return make_color(0,0,0); - } + return kDefaultColors[index]; } diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index d926193b9b..68a7950e1b 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -300,7 +300,8 @@ Desktop::Desktop(uid_t userID) : MessageLooper("desktop"), fUserID(userID), - fSettings(new DesktopSettings::Private()), + fSettings(NULL), + fSharedReadOnlyArea(-1), fApplicationsLock("application list"), fShutdownSemaphore(-1), fCurrentWorkspace(0), @@ -317,17 +318,11 @@ Desktop::Desktop(uid_t userID) char name[B_OS_NAME_LENGTH]; Desktop::_GetLooperName(name, sizeof(name)); - for (int32 i = 0; i < kMaxWorkspaces; i++) { - _Windows(i).SetIndex(i); - fWorkspaces[i].RestoreConfiguration(*fSettings->WorkspacesMessage(i)); - } - fMessagePort = create_port(DEFAULT_MONITOR_PORT_SIZE, name); if (fMessagePort < B_OK) return; fLink.SetReceiverPort(fMessagePort); - gFontManager->AttachUser(fUserID); } @@ -335,14 +330,32 @@ Desktop::~Desktop() { delete fSettings; + delete_area(fSharedReadOnlyArea); delete_port(fMessagePort); gFontManager->DetachUser(fUserID); } -void +status_t Desktop::Init() { + if (fMessagePort < B_OK) + return fMessagePort; + + char name[B_OS_NAME_LENGTH]; + snprintf(name, sizeof(name), "d:%d:shared read only", /*id*/0); + fSharedReadOnlyArea = create_area(name, (void **)&fServerReadOnlyMemory, + B_ANY_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); + if (fSharedReadOnlyArea < B_OK) + return fSharedReadOnlyArea; + + fSettings = new DesktopSettings::Private(fServerReadOnlyMemory); + + for (int32 i = 0; i < kMaxWorkspaces; i++) { + _Windows(i).SetIndex(i); + fWorkspaces[i].RestoreConfiguration(*fSettings->WorkspacesMessage(i)); + } + fVirtualScreen.RestoreConfiguration(*this, fSettings->WorkspacesMessage(0)); // TODO: temporary workaround, fActiveScreen will be removed @@ -371,6 +384,10 @@ Desktop::Init() BRegion stillAvailableOnScreen; _RebuildClippingForAllWindows(stillAvailableOnScreen); _SetBackground(stillAvailableOnScreen); + + gFontManager->AttachUser(fUserID); + + return B_OK; } diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index 73fd2a0bc5..63ea1c8e11 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -45,6 +45,7 @@ class DrawingEngine; class HWInterface; class ServerApp; class WorkspacesLayer; +struct server_read_only_memory; namespace BPrivate { class LinkSender; @@ -55,10 +56,11 @@ class Desktop : public MessageLooper, public ScreenOwner { Desktop(uid_t userID); virtual ~Desktop(); - void Init(); + status_t Init(); uid_t UserID() const { return fUserID; } virtual port_id MessagePort() const { return fMessagePort; } + area_id SharedReadOnlyArea() const { return fSharedReadOnlyArea; } ::EventDispatcher& EventDispatcher() { return fEventDispatcher; } @@ -217,6 +219,8 @@ class Desktop : public MessageLooper, public ScreenOwner { port_id fMessagePort; ::EventDispatcher fEventDispatcher; port_id fInputPort; + area_id fSharedReadOnlyArea; + server_read_only_memory* fServerReadOnlyMemory; BLocker fApplicationsLock; BObjectList fApplications; diff --git a/src/servers/app/DesktopSettings.cpp b/src/servers/app/DesktopSettings.cpp index 50ff4744e5..67d0663d3f 100644 --- a/src/servers/app/DesktopSettings.cpp +++ b/src/servers/app/DesktopSettings.cpp @@ -14,15 +14,18 @@ #include "FontManager.h" #include "ServerConfig.h" +#include +#include + #include #include #include -//#include #include -DesktopSettings::Private::Private() - : BLocker("DesktopSettings_Private") +DesktopSettings::Private::Private(server_read_only_memory* shared) + : BLocker("DesktopSettings_Private"), + fShared(*shared) { // if the on-disk settings are not complete, the defaults will be kept _SetDefaults(); @@ -65,6 +68,8 @@ DesktopSettings::Private::_SetDefaults() fMenuInfo.triggers_always_shown = false; fWorkspacesCount = 4; + + memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors); } diff --git a/src/servers/app/DesktopSettingsPrivate.h b/src/servers/app/DesktopSettingsPrivate.h index 662f7af529..a505ecbfed 100644 --- a/src/servers/app/DesktopSettingsPrivate.h +++ b/src/servers/app/DesktopSettingsPrivate.h @@ -14,10 +14,12 @@ #include +struct server_read_only_memory; + class DesktopSettings::Private : public BLocker { public: - Private(); + Private(server_read_only_memory* shared); ~Private(); status_t Save(uint32 mask = kAllSettings); @@ -61,6 +63,8 @@ class DesktopSettings::Private : public BLocker { mode_mouse fMouseMode; int32 fWorkspacesCount; BMessage fWorkspaceMessages[kMaxWorkspaces]; + + server_read_only_memory& fShared; }; #endif /* DESKTOP_SETTINGS_PRIVATE_H */ diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 6f9b7626d1..6d20855dbb 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -220,7 +220,8 @@ ServerApp::Run() // Let's tell the client how to talk with us fLink.StartMessage(B_OK); - fLink.Attach(fMessagePort); + fLink.Attach(fMessagePort); + fLink.Attach(fDesktop->SharedReadOnlyArea()); fLink.Flush(); return true;