Added code to read R5 workspace config data
Added some functions to handle global mouse, menu, and FFM data Tweaks to DesktopClasses git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3876 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0491e1650c
commit
ea39092263
@ -47,15 +47,23 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
bool ReadOBOSWorkspaceData(void);
|
||||
bool ReadR5WorkspaceData(void);
|
||||
void SaveWorkspaceData(void);
|
||||
|
||||
//! This namespace encapsulates all globals specifically for the desktop
|
||||
namespace desktop_private {
|
||||
int8 *dragmessage=NULL;
|
||||
int32 dragmessagesize=0;
|
||||
BLocker draglock,
|
||||
layerlock,
|
||||
workspacelock;
|
||||
workspacelock,
|
||||
optlock;
|
||||
BList *screenlist=NULL;
|
||||
Screen *activescreen=NULL;
|
||||
scroll_bar_info scrollbarinfo;
|
||||
menu_info menuinfo;
|
||||
int16 ffm;
|
||||
}
|
||||
|
||||
//! locks layer access
|
||||
@ -111,7 +119,7 @@ printf("Desktop: InitWorkspace\n");
|
||||
printf("\t NULL display driver. OK. We crash now. :P\n");
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#else // end if not TEST_MODE
|
||||
|
||||
#if DISPLAYDRIVER == SCREENDRIVER
|
||||
tdriver=new ScreenDriver;
|
||||
@ -382,6 +390,15 @@ screen_id ActiveScreen(void)
|
||||
return desktop_private::activescreen->GetID();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the active screen.
|
||||
\return The currently active screen
|
||||
*/
|
||||
Screen *GetActiveScreen(void)
|
||||
{
|
||||
return desktop_private::activescreen;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Obtains the DisplayDriver object used for the specified screen.
|
||||
\param screen ID of the screen to get the DisplayDriver for.
|
||||
@ -489,7 +506,7 @@ printf("Desktop: SetActiveWindow(%s)\n",win?win->GetTitle():"NULL");
|
||||
#endif
|
||||
lock_workspaces();
|
||||
Workspace *w=desktop_private::activescreen->GetActiveWorkspace();
|
||||
if(win->GetWorkspace()!=w)
|
||||
if(win && win->GetWorkspace()!=w)
|
||||
{
|
||||
desktop_private::workspacelock.Unlock();
|
||||
return;
|
||||
@ -583,3 +600,200 @@ void empty_drag_message(void)
|
||||
unlock_dragdata();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Thread-safe way of obtaining the current scrollbar behavior info
|
||||
\return Current scroll behavior data
|
||||
*/
|
||||
scroll_bar_info GetScrollBarInfo(void)
|
||||
{
|
||||
scroll_bar_info sbi;
|
||||
desktop_private::optlock.Lock();
|
||||
sbi=desktop_private::scrollbarinfo;
|
||||
desktop_private::optlock.Unlock();
|
||||
return sbi;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Thread-safe way of setting the current scrollbar behavior info
|
||||
\param info Behavior data structure
|
||||
*/
|
||||
void SetScrollBarInfo(const scroll_bar_info &info)
|
||||
{
|
||||
desktop_private::optlock.Lock();
|
||||
desktop_private::scrollbarinfo=info;
|
||||
desktop_private::optlock.Unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Thread-safe way of obtaining the current menu behavior info
|
||||
\return Current menu behavior data
|
||||
*/
|
||||
menu_info GetMenuInfo(void)
|
||||
{
|
||||
menu_info mi;
|
||||
desktop_private::optlock.Lock();
|
||||
mi=desktop_private::menuinfo;
|
||||
desktop_private::optlock.Unlock();
|
||||
return mi;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Thread-safe way of setting the current menu behavior info
|
||||
\param info Behavior data structure
|
||||
*/
|
||||
void SetMenuInfo(const menu_info &info)
|
||||
{
|
||||
desktop_private::optlock.Lock();
|
||||
desktop_private::menuinfo=info;
|
||||
desktop_private::optlock.Unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Thread-safe way of obtaining the current focus-follows-mouse behavior
|
||||
\return Current menu behavior data
|
||||
*/
|
||||
int16 GetFFMouse(void)
|
||||
{
|
||||
int16 value;
|
||||
desktop_private::optlock.Lock();
|
||||
value=desktop_private::ffm;
|
||||
desktop_private::optlock.Unlock();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Thread-safe way of setting the current focus-follows-mouse behavior
|
||||
\param info Behavior data structure
|
||||
*/
|
||||
void SetFFMouse(const int16 &value)
|
||||
{
|
||||
desktop_private::optlock.Lock();
|
||||
desktop_private::ffm=value;
|
||||
desktop_private::optlock.Unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Read in settings from R5's workspace settings file in ~/config/settings
|
||||
\return True if successful, false unable to read and parse file.
|
||||
*/
|
||||
bool ReadR5WorkspaceData(void)
|
||||
{
|
||||
//TODO: Add read checks for fscsnf calls
|
||||
|
||||
// Should there be multiple graphics devices, I assume that we'd probably need to loop through
|
||||
// each device and read the workspace data for each. For now, we just assume that there is
|
||||
// just one.
|
||||
|
||||
FILE *file=fopen("/boot/home/config/settings/app_server_settings",B_READ_ONLY);
|
||||
if(!file)
|
||||
return false;
|
||||
|
||||
char devicepath[B_PATH_NAME_LENGTH];
|
||||
as_workspace_data wdata;
|
||||
int workspace_count=3;
|
||||
|
||||
Screen *active=GetActiveScreen();
|
||||
|
||||
// read in device
|
||||
// Device <devpath>
|
||||
fscanf(file,"Device %s",devicepath);
|
||||
|
||||
// read workspace count
|
||||
// Workspaces # {
|
||||
fscanf(file,"Workspaces %d {",&workspace_count);
|
||||
|
||||
// read workspace config for all 32 (0-31)
|
||||
|
||||
for(int i=0; i<32;i++)
|
||||
{
|
||||
// Workspace # {
|
||||
fscanf(file,"Workspace %d {",&wdata.index);
|
||||
|
||||
// timing: display_timing struct in Accelerant.h
|
||||
fscanf(file,"timing %lu %u %u %u %u %u %u %u %u %lu",&wdata.timing.pixel_clock,
|
||||
(unsigned int*)&(wdata.timing.h_display),(unsigned int*)&(wdata.timing.h_sync_start),
|
||||
(unsigned int*)&(wdata.timing.h_sync_end),(unsigned int*)&(wdata.timing.h_total),
|
||||
(unsigned int*)&(wdata.timing.v_display),(unsigned int*)&(wdata.timing.v_sync_start),
|
||||
(unsigned int*)&(wdata.timing.v_sync_end),(unsigned int*)&(wdata.timing.v_total),
|
||||
&wdata.timing.flags);
|
||||
|
||||
// colorspace: member of color_space struct, like RGB15, RGB32, etc.
|
||||
fscanf(file,"colorspace %lx",(long*)&wdata.space);
|
||||
|
||||
// virtual width height
|
||||
fscanf(file,"virtual %d %d",&wdata.res_w, &wdata.res_h);
|
||||
|
||||
// flags:
|
||||
fscanf(file,"flags %lx",&wdata.flags);
|
||||
|
||||
// color: RGB hexcode
|
||||
fscanf(file,"color %lx",&wdata.bgcolor);
|
||||
// }
|
||||
|
||||
// Create a workspace and add it to the active screen.
|
||||
Workspace *w=new Workspace(&wdata,active);
|
||||
active->AddWorkspace(w);
|
||||
}
|
||||
|
||||
scroll_bar_info sbi;
|
||||
|
||||
// read interface block
|
||||
// Interface {
|
||||
// read scrollbars block
|
||||
// Scrollbars {
|
||||
int bflag;
|
||||
|
||||
// get the four scrollbar values
|
||||
// proportional 1
|
||||
fscanf(file,"proportional %d",&bflag);
|
||||
sbi.proportional=(bflag==1)?true:false;
|
||||
|
||||
// arrows 2
|
||||
fscanf(file,"arrows %d",&bflag);
|
||||
sbi.double_arrows=(bflag==2)?true:false;
|
||||
|
||||
// knobtype 0
|
||||
fscanf(file,"knobtype %ld",&sbi.knob);
|
||||
|
||||
// knobsize 15
|
||||
fscanf(file,"knobsize %ld",&sbi.min_knob_size);
|
||||
// }
|
||||
|
||||
// read options block
|
||||
// Options {
|
||||
|
||||
// get focus-follows-mouse block
|
||||
// ffm #
|
||||
// FFM values:
|
||||
// 0: Disabled
|
||||
// 1: Enabled
|
||||
// 2: Warping
|
||||
// 3: Instant Warping
|
||||
int ffm;
|
||||
fscanf(file,"ffm %d",&ffm);
|
||||
SetFFMouse(ffm);
|
||||
|
||||
// skip decor listing
|
||||
fclose(file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Reads in workspace config data using the regular system file
|
||||
\return True if settings were successfully loaded. False if not
|
||||
|
||||
The file's location is defined in ServerConfig.h - SERVER_SETTINGS_DIR/WORKSPACE_SETTINGS_NAME.
|
||||
*/
|
||||
bool ReadOBOSWorkspaceData(void)
|
||||
{
|
||||
//TODO: Implement
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Saves workspace config to SERVER_SETTINGS_DIR/WORKSPACE_SETTINGS_NAME as defined in ServerConfig.h
|
||||
void SaveWorkspaceData(void)
|
||||
{
|
||||
//TODO: Implement
|
||||
}
|
||||
|
@ -28,9 +28,12 @@
|
||||
#define DESKTOP_H_
|
||||
|
||||
#include <Window.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <Menu.h>
|
||||
#include <GraphicsDefs.h>
|
||||
|
||||
class ServerWindow;
|
||||
class Screen;
|
||||
class DisplayDriver;
|
||||
class Layer;
|
||||
|
||||
@ -47,6 +50,7 @@ void SetWorkspace(int32 workspace);
|
||||
void SetScreen(screen_id id);
|
||||
int32 CountScreens(void);
|
||||
screen_id ActiveScreen(void);
|
||||
Screen *GetActiveScreen(void);
|
||||
DisplayDriver *GetGfxDriver(screen_id screen);
|
||||
status_t SetSpace(int32 index, int32 res, screen_id screen, bool stick=true);
|
||||
|
||||
@ -60,6 +64,15 @@ void set_drag_message(int32 size, int8 *flattened);
|
||||
int8* get_drag_message(int32 *size);
|
||||
void empty_drag_message(void);
|
||||
|
||||
scroll_bar_info GetScrollBarInfo(void);
|
||||
void SetScrollBarInfo(const scroll_bar_info &info);
|
||||
|
||||
menu_info GetMenuInfo(void);
|
||||
void SetMenuInfo(const menu_info &info);
|
||||
|
||||
int16 GetFFMouse(void);
|
||||
void SetFFMouse(const int16 &value);
|
||||
|
||||
void lock_layers(void);
|
||||
void unlock_layers(void);
|
||||
void lock_dragdata(void);
|
||||
|
@ -25,10 +25,15 @@
|
||||
// Description: Classes for managing workspaces and screens
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "DesktopClasses.h"
|
||||
#include "TokenHandler.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "WinBorder.h"
|
||||
#include "Desktop.h"
|
||||
|
||||
//#define DEBUG_WORKSPACE
|
||||
//#define DEBUG_SCREEN
|
||||
@ -64,6 +69,14 @@ printf("Workspace::Workspace(%s)\n",_rootlayer->GetName());
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Constructor to accept data from reading R5's settings
|
||||
*/
|
||||
Workspace::Workspace(as_workspace_data *data, Screen *screen)
|
||||
{
|
||||
//TODO: Implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Deletes the heap memory used by the Workspace
|
||||
*/
|
||||
@ -204,12 +217,16 @@ printf("Screen::Screen(%s,%u)\n",gfxmodule?"driver":"NULL",workspaces);
|
||||
_workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo,this));
|
||||
}
|
||||
_resolution=_driver->GetMode();
|
||||
|
||||
if(workspaces>0)
|
||||
{
|
||||
_currentworkspace=0;
|
||||
_activeworkspace=(Workspace*)_workspacelist->ItemAt(0);
|
||||
_workspacecount=workspaces;
|
||||
_activeworkspace->GetRoot()->Show();
|
||||
_activeworkspace->GetRoot()->RequestDraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -245,6 +262,22 @@ printf("Screen::AddWorkspace(%ld)\n",index+1);
|
||||
_workspacelist->AddItem(workspace);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Adds a workspace object to the screen
|
||||
\param workspace The workspace to add.
|
||||
\param index Optional index to insert workspace at. Defaults to adding to end of list.
|
||||
|
||||
This function will do nothing if workspace is NULL.
|
||||
*/
|
||||
void Screen::AddWorkspace(Workspace *workspace,int32 index)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::AddWorkspace(%s)\n",(workspace && workspace->GetRoot())?workspace->GetRoot()->GetName():"NULL");
|
||||
#endif
|
||||
if ( (index==-1) || !_workspacelist->AddItem(workspace,index) )
|
||||
_workspacelist->AddItem(workspace);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Deletes the workspace at the specified index
|
||||
\param index The position within the workspace list
|
||||
@ -430,7 +463,21 @@ ServerWindow *Screen::ActiveWindow(void)
|
||||
*/
|
||||
void Screen::SetActiveWindow(ServerWindow *win)
|
||||
{
|
||||
//TODO: Implement
|
||||
if(win)
|
||||
{
|
||||
if(win->GetWorkspace()==NULL)
|
||||
{
|
||||
// has not been added to desktop
|
||||
AddWindowToDesktop(win,win->GetWorkspaceIndex(),_id);
|
||||
}
|
||||
Workspace *wksp=win->GetWorkspace();
|
||||
if(wksp->GetScreen()!=this)
|
||||
return;
|
||||
set_active_winborder(win->_winborder);
|
||||
}
|
||||
else
|
||||
set_active_winborder(NULL);
|
||||
_activewin=win;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -29,6 +29,8 @@
|
||||
#define DESKTOPCLASSES_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <Accelerant.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <GraphicsCard.h>
|
||||
#include <Window.h> // for workspace defs
|
||||
#include "RootLayer.h"
|
||||
@ -45,10 +47,22 @@ class Screen;
|
||||
Doesn't actually do a whole lot except to couple some associated data with a
|
||||
RootLayer.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int index;
|
||||
display_timing timing;
|
||||
color_space space;
|
||||
int res_w;
|
||||
int res_h;
|
||||
int32 flags;
|
||||
int32 bgcolor;
|
||||
} as_workspace_data;
|
||||
|
||||
class Workspace
|
||||
{
|
||||
public:
|
||||
Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, Screen *screen);
|
||||
Workspace(as_workspace_data *data, Screen *screen);
|
||||
~Workspace(void);
|
||||
void SetBGColor(const RGBColor &c);
|
||||
RGBColor BGColor();
|
||||
@ -78,6 +92,7 @@ public:
|
||||
Screen(DisplayDriver *gfxmodule, uint8 workspaces);
|
||||
~Screen(void);
|
||||
void AddWorkspace(int32 index=-1);
|
||||
void AddWorkspace(Workspace *workspace,int32 index=-1);
|
||||
void DeleteWorkspace(int32 index);
|
||||
int32 CountWorkspaces(void);
|
||||
void SetWorkspaceCount(int32 count);
|
||||
|
@ -57,6 +57,9 @@
|
||||
// name of the file containing the current UI color settings
|
||||
#define COLOR_SETTINGS_NAME "system_colors"
|
||||
|
||||
// name of the file containing the config data for the desktop
|
||||
#define WORKSPACE_SETTINGS_NAME "workspace_data"
|
||||
|
||||
// Folder for additional window decorators
|
||||
#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user