diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index a446bd811f..3c809788c0 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -155,6 +156,7 @@ AppServer::AppServer(void) _active_app=-1; _p_active_app=NULL; + decorator_name="Default"; } /*! @@ -382,13 +384,24 @@ void AppServer::MainLoop(void) \param path Path to the decorator to load \return True if successful, false if not. - If the server cannot load the specified decorator, nothing changes. + If the server cannot load the specified decorator, nothing changes. Passing a + NULL string to this function sets the decorator to the internal one. */ bool AppServer::LoadDecorator(const char *path) { // Loads a window decorator based on the supplied path and forces a decorator update. // If it cannot load the specified decorator, it will retain the current one and - // return false. + // return false. Note that passing a NULL string to this function sets the decorator + // to the internal one. + + // passing the string "Default" will set the window decorator to the app_server's + // internal one + if(!path) + { + make_decorator=NULL; + return true; + } + create_decorator *pcreatefunc=NULL; status_t stat; image_id addon; @@ -409,7 +422,10 @@ bool AppServer::LoadDecorator(const char *path) unload_add_on(addon); return false; } - + + BPath temppath(path); + decorator_name=temppath.Leaf(); + acquire_sem(_decor_lock); make_decorator=pcreatefunc; _decorator_id=addon; @@ -596,33 +612,88 @@ void AppServer::DispatchMessage(PortMessage *msg) } case AS_SET_UI_COLORS: { - // TODO: Unpack the colors and set the color set to such - printf("AppServer::AS_SET_UI_COLORS unimplemented\n"); - break; - } - case AS_GET_UI_COLOR: - { - // TODO: get a partiular UI color and return it to the sender - printf("AppServer::AS_GET_UI_COLOR unimplemented\n"); + // Client application is asking to set all the system colors at once + // using a ColorSet object + + // Attached data: + // 1) ColorSet new colors to use + + gui_colorset.Lock(); + msg->Read(&gui_colorset); + gui_colorset.Unlock(); + Broadcast(AS_UPDATE_COLORS); break; } case AS_SET_DECORATOR: { - // TODO: set up window decorator notification stuff here - printf("AppServer::AS_SET_DECORATOR unimplemented\n"); + // Received from an application when the user wants to set the window + // decorator to a new one + + // Attached Data: + // char * name of the decorator in the decorators path to use + + char *decname; + msg->ReadString(&decname); + if(decname) + { + if(strcmp(decname,"Default")!=0) + { + BString decpath; + decpath.SetTo(DECORATORS_DIR); + decpath+=decname; + if(LoadDecorator(decpath.String())) + Broadcast(AS_UPDATE_DECORATOR); + } + else + { + LoadDecorator(NULL); + Broadcast(AS_UPDATE_DECORATOR); + } + } + delete decname; + break; } case AS_GET_DECORATOR: { - // TODO: get window decorator and return it to the sender - printf("AppServer::AS_GET_DECORATOR unimplemented\n"); + // TODO: get window decorator's name and return it to the sender + // Attached Data: + // 1) port_id reply port + + port_id replyport; + msg->Read(&replyport); + PortLink replylink(replyport); + replylink.SetOpCode(AS_GET_DECORATOR); + replylink.AttachString(decorator_name.String()); + replylink.Flush(); break; } case AS_R5_SET_DECORATOR: { - // TODO: Implement. This will translate the codes to names of the - // decorators and perform the same actions as AS_SET_DECORATOR + // Sort of supports Tracker's nifty Easter Egg. It was easy to do and + // it's kind of neat, so why not? + + // Attached Data: + // char * name of the decorator in the decorators path to use printf("AppServer::AS_R5_SET_DECORATOR unimplemented\n"); + + int32 decindex; + msg->Read(&decindex); + + BString decpath; + decpath.SetTo(DECORATORS_DIR); + switch(decindex) + { + case 0: decpath+="BeOS"; break; + case 1: decpath+="AmigaOS"; break; + case 2: decpath+="Windows"; break; + case 3: decpath+="MacOS"; break; + default: + break; + } + if(LoadDecorator(decpath.String())) + Broadcast(AS_UPDATE_DECORATOR); + break; } case AS_GET_SCREEN_MODE: diff --git a/src/servers/app/server/AppServer.h b/src/servers/app/server/AppServer.h index aadef86e6e..b2cce4c50d 100644 --- a/src/servers/app/server/AppServer.h +++ b/src/servers/app/server/AppServer.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "Decorator.h" #include "ServerConfig.h" @@ -53,6 +54,7 @@ private: port_id _messageport,_mouseport; image_id _decorator_id; + BString decorator_name; bool _quitting_server; BList *_applist; int32 _active_app; diff --git a/src/servers/app/server/ColorSet.cpp b/src/servers/app/server/ColorSet.cpp index b3f4ba3f9a..41e944ec34 100644 --- a/src/servers/app/server/ColorSet.cpp +++ b/src/servers/app/server/ColorSet.cpp @@ -26,6 +26,7 @@ // //------------------------------------------------------------------------------ #include +#include #include #include #include @@ -412,6 +413,148 @@ RGBColor *ColorSet::StringToMember(const char *string) } +RGBColor ColorSet::AttributeToColor(int32 which) +{ + switch(which) + { + case B_PANEL_BACKGROUND_COLOR: + { + return panel_background; + break; + } + case B_PANEL_TEXT_COLOR: + { + return panel_text; + break; + } + case B_DOCUMENT_BACKGROUND_COLOR: + { + return document_background; + break; + } + case B_DOCUMENT_TEXT_COLOR: + { + return document_text; + break; + } + case B_CONTROL_BACKGROUND_COLOR: + { + return control_background; + break; + } + case B_CONTROL_TEXT_COLOR: + { + return control_text; + break; + } + case B_CONTROL_BORDER_COLOR: + { + return control_highlight; + break; + } + case B_CONTROL_HIGHLIGHT_COLOR: + { + return control_border; + break; + } + case B_NAVIGATION_BASE_COLOR: + { + return keyboard_navigation_base; + break; + } + case B_NAVIGATION_PULSE_COLOR: + { + return keyboard_navigation_pulse; + break; + } + case B_SHINE_COLOR: + { + return shine; + break; + } + case B_SHADOW_COLOR: + { + return shadow; + break; + } + case B_MENU_BACKGROUND_COLOR: + { + return menu_background; + break; + } + case B_MENU_SELECTED_BACKGROUND_COLOR: + { + return menu_selected_background; + break; + } + case B_MENU_ITEM_TEXT_COLOR: + { + return menu_text; + break; + } + case B_MENU_SELECTED_ITEM_TEXT_COLOR: + { + return menu_selected_text; + break; + } + case B_MENU_SELECTED_BORDER_COLOR: + { + return menu_selected_border; + break; + } + case B_TOOLTIP_BACKGROUND_COLOR: + { + return tooltip_background; + break; + } + case B_TOOLTIP_TEXT_COLOR: + { + return tooltip_text; + break; + } + case B_SUCCESS_COLOR: + { + return success; + break; + } + case B_FAILURE_COLOR: + { + return failure; + break; + } + case B_WINDOW_TAB_COLOR: + { + return window_tab; + break; + } + + // DANGER! DANGER, WILL ROBINSON!! + // These are magic numbers to work around compatibility difficulties while still keeping + // functionality. This __will__ break following R1 + case 22: + { + return window_tab_text; + break; + } + case 23: + { + return inactive_window_tab; + break; + } + case 24: + { + return inactive_window_tab_text; + break; + } + + default: + { + return RGBColor(0,0,0,0); + break; + } + } +} + /*! \brief Loads the saved system colors into a ColorSet \param set the set to receive the system colors @@ -465,3 +608,4 @@ void SaveGUIColors(const ColorSet &set) msg.Flatten(&file); } + diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 7c02703f59..e4828045f7 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -743,6 +743,12 @@ void ServerApp::_DispatchMessage(PortMessage *msg) replysession.Sync(); break; } + case AS_GET_UI_COLOR: + { + // TODO: get a partiular UI color and return it to the sender + printf("ServerApp::AS_GET_UI_COLOR unimplemented\n"); + break; + } default: { STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(msg->Code()))); diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index d50f2d5971..f3f6a82465 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -48,6 +48,10 @@ class Workspace; class BSession; class Layer; +#define AS_UPDATE_DECORATOR 'asud' +#define AS_UPDATE_COLORS 'asuc' +#define AS_UPDATE_FONTS 'asuf' + /*! \class ServerWindow ServerWindow.h \brief Shadow BWindow class