Lots of minor tweaks here and there
Added debug code to a number of files Enabled ServerWindow and WinBorder mouse-handling code ScreenDriver is now double-buffered (exceedingly useful for testing) I'm trying to think, but nothing happens! :D git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3052 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0fe548713a
commit
47b0fc0ee3
@ -130,7 +130,7 @@ AppServer::AppServer(void)
|
||||
_decor_lock=create_sem(1,"app_server_decor_sem");
|
||||
|
||||
// Get the driver first - Poller thread utilizes the thing
|
||||
_driver=GetGfxDriver();
|
||||
_driver=GetGfxDriver(ActiveScreen());
|
||||
|
||||
// Spawn our input-polling thread
|
||||
_poller_id=spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this);
|
||||
|
@ -150,7 +150,7 @@ void CursorManager::ShowCursor(void)
|
||||
{
|
||||
acquire_sem(_lock);
|
||||
|
||||
DisplayDriver *driver=GetGfxDriver();
|
||||
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
|
||||
driver->ShowCursor();
|
||||
release_sem(_lock);
|
||||
}
|
||||
@ -160,7 +160,7 @@ void CursorManager::HideCursor(void)
|
||||
{
|
||||
acquire_sem(_lock);
|
||||
|
||||
DisplayDriver *driver=GetGfxDriver();
|
||||
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
|
||||
driver->HideCursor();
|
||||
release_sem(_lock);
|
||||
}
|
||||
@ -170,7 +170,7 @@ void CursorManager::ObscureCursor(void)
|
||||
{
|
||||
acquire_sem(_lock);
|
||||
|
||||
DisplayDriver *driver=GetGfxDriver();
|
||||
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
|
||||
driver->ObscureCursor();
|
||||
release_sem(_lock);
|
||||
}
|
||||
@ -185,7 +185,7 @@ void CursorManager::SetCursor(int32 token)
|
||||
ServerCursor *c=_FindCursor(token);
|
||||
if(c)
|
||||
{
|
||||
DisplayDriver *driver=GetGfxDriver();
|
||||
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
|
||||
driver->SetCursor(c);
|
||||
_current_which=B_CURSOR_OTHER;
|
||||
}
|
||||
@ -196,7 +196,7 @@ void CursorManager::SetCursor(cursor_which which)
|
||||
{
|
||||
acquire_sem(_lock);
|
||||
|
||||
DisplayDriver *driver=GetGfxDriver();
|
||||
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
|
||||
switch(which)
|
||||
{
|
||||
case B_CURSOR_DEFAULT:
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "RGBColor.h"
|
||||
|
||||
//#define DEBUG_DECORATOR
|
||||
|
||||
|
||||
#define USE_VIEW_FILL_HACK
|
||||
|
||||
#ifdef DEBUG_DECORATOR
|
||||
@ -141,8 +143,8 @@ else
|
||||
if(_tabrect.Contains(pt))
|
||||
{
|
||||
// Here's part of our window management stuff
|
||||
if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus())
|
||||
return CLICK_MOVETOFRONT;
|
||||
// if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus())
|
||||
// return CLICK_MOVETOFRONT;
|
||||
if(buttons==B_SECONDARY_MOUSE_BUTTON)
|
||||
return CLICK_MOVETOBACK;
|
||||
return CLICK_DRAG;
|
||||
|
@ -41,6 +41,12 @@
|
||||
|
||||
#include "ServerWindow.h"
|
||||
|
||||
//#define DEBUG_DESKTOP
|
||||
|
||||
#ifdef DEBUG_DESKTOP
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
//! This namespace encapsulates all globals specifically for the desktop
|
||||
namespace desktop_private {
|
||||
int8 *dragmessage=NULL;
|
||||
@ -73,12 +79,14 @@ void unlock_workspaces(void) { desktop_private::workspacelock.Unlock(); }
|
||||
*/
|
||||
void InitDesktop(void)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: InitWorkspace\n");
|
||||
#endif
|
||||
desktop_private::screenlist=new BList(0);
|
||||
DisplayDriver *tdriver;
|
||||
Screen *s=NULL;
|
||||
|
||||
#ifndef TEST_MODE
|
||||
|
||||
// If we're using the AccelerantDriver for rendering, eventually we will loop through
|
||||
// drivers until one can't initialize in order to support multiple monitors. For now,
|
||||
// we'll just load one and be done with it.
|
||||
@ -99,6 +107,9 @@ void InitDesktop(void)
|
||||
tdriver->Shutdown();
|
||||
delete tdriver;
|
||||
tdriver=NULL;
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("\t NULL display driver. OK. We crash now. :P\n");
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
@ -123,6 +134,9 @@ void InitDesktop(void)
|
||||
tdriver->Shutdown();
|
||||
delete tdriver;
|
||||
tdriver=NULL;
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("\t NULL display driver. OK. We crash now. :P\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -133,11 +147,18 @@ void InitDesktop(void)
|
||||
desktop_private::activescreen=s;
|
||||
s->SetSpace(0,B_32_BIT_640x480,true);
|
||||
}
|
||||
#ifdef DEBUG_DESKTOP
|
||||
else
|
||||
printf("ERROR: NULL display driver\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Shuts down the graphics subsystem
|
||||
void ShutdownDesktop(void)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: ShutdownDesktop\n");
|
||||
#endif
|
||||
Screen *s;
|
||||
|
||||
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
|
||||
@ -165,6 +186,9 @@ void ShutdownDesktop(void)
|
||||
*/
|
||||
void AddWorkspace(int32 index=-1)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: AddWorkspace(%ld)\n",index+1);
|
||||
#endif
|
||||
lock_workspaces();
|
||||
lock_layers();
|
||||
|
||||
@ -192,6 +216,9 @@ void AddWorkspace(int32 index=-1)
|
||||
*/
|
||||
void DeleteWorkspace(int32 index)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: DeleteWorkspace(%ld)\n",index+1);
|
||||
#endif
|
||||
lock_workspaces();
|
||||
lock_layers();
|
||||
|
||||
@ -214,7 +241,6 @@ void DeleteWorkspace(int32 index)
|
||||
*/
|
||||
int32 CountWorkspaces(void)
|
||||
{
|
||||
|
||||
lock_workspaces();
|
||||
lock_layers();
|
||||
|
||||
@ -238,6 +264,9 @@ int32 CountWorkspaces(void)
|
||||
*/
|
||||
void SetWorkspaceCount(int32 count)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: SetWorkspaceCount(%ld)\n",count);
|
||||
#endif
|
||||
if(count<1 || count>32)
|
||||
return;
|
||||
lock_workspaces();
|
||||
@ -290,6 +319,9 @@ Workspace *WorkspaceAt(int32 index)
|
||||
*/
|
||||
void SetWorkspace(int32 workspace)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: SetWorkspace(%ld)\n",workspace+1);
|
||||
#endif
|
||||
lock_workspaces();
|
||||
if(workspace<0 || workspace>(CountWorkspaces()-1))
|
||||
{
|
||||
@ -314,6 +346,9 @@ void SetWorkspace(int32 workspace)
|
||||
*/
|
||||
void SetScreen(screen_id id)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: SetScreen(%ld)\n",id.id);
|
||||
#endif
|
||||
Screen *scr;
|
||||
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
|
||||
{
|
||||
@ -355,7 +390,7 @@ screen_id ActiveScreen(void)
|
||||
Like the other multiscreen functions, this is unused. Because multiple screens are
|
||||
not utilized, specifying an ID other than B_MAIN_SCREEN_ID will return NULL
|
||||
*/
|
||||
DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)
|
||||
DisplayDriver *GetGfxDriver(screen_id screen)
|
||||
{
|
||||
return (desktop_private::activescreen)?desktop_private::activescreen->GetGfxDriver():NULL;
|
||||
}
|
||||
@ -370,8 +405,12 @@ DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)
|
||||
|
||||
Because of the lack of outside multimonitor support, the screen ID is ignored for now.
|
||||
*/
|
||||
status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)
|
||||
status_t SetSpace(int32 index, int32 res, screen_id screen, bool stick=true)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: SetSpace(%ld,%ld,%s,%ld)\n",index+1,res,
|
||||
stick?"stick":"non-stick",screen.id);
|
||||
#endif
|
||||
desktop_private::workspacelock.Lock();
|
||||
status_t stat=desktop_private::activescreen->SetSpace(index,res,stick);
|
||||
desktop_private::workspacelock.Unlock();
|
||||
@ -384,8 +423,12 @@ status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MA
|
||||
\param workspace index of the workspace to add the window to
|
||||
\param screen Optional screen specifier. Currently unused.
|
||||
*/
|
||||
void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
|
||||
void AddWindowToDesktop(ServerWindow *win, int32 workspace, screen_id screen)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: AddWindowToDesktop(%s,%ld,%ld)\n",win?win->GetTitle():"NULL",
|
||||
workspace+1,screen.id);
|
||||
#endif
|
||||
// Workspace() will be non-NULL if it has already been added to the desktop
|
||||
if(!win || win->GetWorkspace())
|
||||
return;
|
||||
@ -407,6 +450,9 @@ void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE,
|
||||
*/
|
||||
void RemoveWindowFromDesktop(ServerWindow *win)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: RemoveWindowFromDesktop(%s)\n",win?win->GetTitle():"NULL");
|
||||
#endif
|
||||
lock_workspaces();
|
||||
lock_layers();
|
||||
|
||||
@ -438,6 +484,9 @@ ServerWindow *GetActiveWindow(void)
|
||||
*/
|
||||
void SetActiveWindow(ServerWindow *win)
|
||||
{
|
||||
#ifdef DEBUG_DESKTOP
|
||||
printf("Desktop: SetActiveWindow(%s)\n",win?win->GetTitle():"NULL");
|
||||
#endif
|
||||
lock_workspaces();
|
||||
Workspace *w=desktop_private::activescreen->GetActiveWorkspace();
|
||||
if(win->GetWorkspace()!=w)
|
||||
@ -458,7 +507,7 @@ void SetActiveWindow(ServerWindow *win)
|
||||
\param screen Index of the screen to use. Currently ignored.
|
||||
\return The root layer or NULL if there was an invalid parameter.
|
||||
*/
|
||||
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
|
||||
Layer *GetRootLayer(int32 workspace, screen_id screen)
|
||||
{
|
||||
lock_workspaces();
|
||||
lock_layers();
|
||||
|
@ -47,14 +47,14 @@ void SetWorkspace(int32 workspace);
|
||||
void SetScreen(screen_id id);
|
||||
int32 CountScreens(void);
|
||||
screen_id ActiveScreen(void);
|
||||
DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID);
|
||||
status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID);
|
||||
DisplayDriver *GetGfxDriver(screen_id screen);
|
||||
status_t SetSpace(int32 index, int32 res, screen_id screen, bool stick=true);
|
||||
|
||||
void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID);
|
||||
void AddWindowToDesktop(ServerWindow *win, int32 workspace, screen_id screen);
|
||||
void RemoveWindowFromDesktop(ServerWindow *win);
|
||||
ServerWindow *GetActiveWindow(void);
|
||||
void SetActiveWindow(ServerWindow *win);
|
||||
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID);
|
||||
Layer *GetRootLayer(int32 workspace, screen_id screen);
|
||||
|
||||
void set_drag_message(int32 size, int8 *flattened);
|
||||
int8* get_drag_message(int32 *size);
|
||||
|
@ -30,6 +30,16 @@
|
||||
#include "ServerWindow.h"
|
||||
#include "WinBorder.h"
|
||||
|
||||
//#define DEBUG_WORKSPACE
|
||||
//#define DEBUG_SCREEN
|
||||
|
||||
#ifdef DEBUG_WORKSPACE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef DEBUG_SCREEN
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
// Defined and initialized in AppServer.cpp
|
||||
extern RGBColor workspace_default_color;
|
||||
TokenHandler screen_id_handler;
|
||||
@ -49,6 +59,9 @@ Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &
|
||||
_rootlayer=new RootLayer(BRect(0,0,fbinfo.display_width-1,fbinfo.display_height-1),
|
||||
"Workspace Root",_screen->GetGfxDriver());
|
||||
_rootlayer->SetColor(workspace_default_color);
|
||||
#ifdef DEBUG_WORKSPACE
|
||||
printf("Workspace::Workspace(%s)\n",_rootlayer->GetName());
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -56,6 +69,9 @@ Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &
|
||||
*/
|
||||
Workspace::~Workspace(void)
|
||||
{
|
||||
#ifdef DEBUG_WORKSPACE
|
||||
printf("Workspace::~Workspace(%s)\n",_rootlayer->GetName());
|
||||
#endif
|
||||
if(_rootlayer)
|
||||
{
|
||||
_rootlayer->PruneTree();
|
||||
@ -70,6 +86,9 @@ Workspace::~Workspace(void)
|
||||
*/
|
||||
void Workspace::SetBGColor(const RGBColor &c)
|
||||
{
|
||||
#ifdef DEBUG_WORKSPACE
|
||||
printf("Workspace::SetBGColor(): "); c.PrintToStream();
|
||||
#endif
|
||||
_rootlayer->SetColor(c);
|
||||
}
|
||||
|
||||
@ -98,6 +117,9 @@ RootLayer *Workspace::GetRoot(void)
|
||||
*/
|
||||
void Workspace::SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo)
|
||||
{
|
||||
#ifdef DEBUG_WORKSPACE
|
||||
printf("Workspace::SetData(%s)\n",_rootlayer->GetName());
|
||||
#endif
|
||||
if(_fbinfo.display_width!=fbinfo.display_width ||
|
||||
_fbinfo.display_height!=fbinfo.display_height)
|
||||
{
|
||||
@ -128,6 +150,9 @@ void Workspace::GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)
|
||||
*/
|
||||
void Workspace::SetSpace(int32 res)
|
||||
{
|
||||
#ifdef DEBUG_WORKSPACE
|
||||
printf("Workspace::SetSpace(%ld) unimplemented\n",res);
|
||||
#endif
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
@ -138,6 +163,9 @@ void Workspace::SetSpace(int32 res)
|
||||
*/
|
||||
Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::Screen(%s,%u)\n",gfxmodule?"driver":"NULL",workspaces);
|
||||
#endif
|
||||
_workspacelist=NULL;
|
||||
_driver=gfxmodule;
|
||||
_resolution=0;
|
||||
@ -189,6 +217,9 @@ Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
|
||||
*/
|
||||
Screen::~Screen(void)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::~Screen\n");
|
||||
#endif
|
||||
if ( _workspacelist )
|
||||
{
|
||||
int i;
|
||||
@ -206,6 +237,9 @@ Screen::~Screen(void)
|
||||
*/
|
||||
void Screen::AddWorkspace(int32 index)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::AddWorkspace(%ld)\n",index+1);
|
||||
#endif
|
||||
Workspace *workspace = new Workspace(_gcinfo,_fbinfo,this);
|
||||
if ( (index == -1) || !_workspacelist->AddItem(workspace,index) )
|
||||
_workspacelist->AddItem(workspace);
|
||||
@ -217,6 +251,9 @@ void Screen::AddWorkspace(int32 index)
|
||||
*/
|
||||
void Screen::DeleteWorkspace(int32 index)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::DeleteWorkspace(%ld)\n",index+1);
|
||||
#endif
|
||||
Workspace *workspace;
|
||||
workspace = (Workspace *)_workspacelist->RemoveItem(index);
|
||||
if ( workspace )
|
||||
@ -255,6 +292,10 @@ void Screen::SetWorkspaceCount(int32 count)
|
||||
_workspacecount = count;
|
||||
if ( _currentworkspace > count-1 )
|
||||
SetWorkspace(count-1);
|
||||
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::SetWorkspaceCount(%ld)\n",count);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -272,6 +313,9 @@ int32 Screen::CurrentWorkspace(void)
|
||||
*/
|
||||
void Screen::SetWorkspace(int32 index)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::SetWorkspace(%ld)\n",index+1);
|
||||
#endif
|
||||
if ( (index >= 0) && (index <= _workspacecount-1) )
|
||||
{
|
||||
_currentworkspace = index;
|
||||
@ -285,6 +329,9 @@ void Screen::SetWorkspace(int32 index)
|
||||
*/
|
||||
void Screen::Activate(bool active)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::Activate(%s)\n",active?"active":"inactive");
|
||||
#endif
|
||||
_active=active;
|
||||
}
|
||||
|
||||
@ -306,6 +353,9 @@ DisplayDriver *Screen::GetGfxDriver(void)
|
||||
*/
|
||||
status_t Screen::SetSpace(int32 index, int32 res,bool stick)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::SetSpace(%ld,%ld,%s)\n",index,res,stick?"stick":"non-stick");
|
||||
#endif
|
||||
// the specified workspace isn't active, so this should be easy...
|
||||
Workspace *wkspc=(Workspace*)_workspacelist->ItemAt(index);
|
||||
if(!wkspc)
|
||||
@ -332,6 +382,9 @@ status_t Screen::SetSpace(int32 index, int32 res,bool stick)
|
||||
*/
|
||||
void Screen::AddWindow(ServerWindow *win, int32 workspace)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::AddWindow(%s,%ld)\n",win?win->GetTitle():"NULL", workspace+1);
|
||||
#endif
|
||||
if(!win || !win->_winborder)
|
||||
return;
|
||||
|
||||
@ -349,6 +402,9 @@ void Screen::AddWindow(ServerWindow *win, int32 workspace)
|
||||
*/
|
||||
void Screen::RemoveWindow(ServerWindow *win)
|
||||
{
|
||||
#ifdef DEBUG_SCREEN
|
||||
printf("Screen::RemoveWindow(%s)\n",win?win->GetTitle():"NULL");
|
||||
#endif
|
||||
if(!win || !win->_winborder)
|
||||
return;
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "TokenHandler.h"
|
||||
#include "RectUtils.h"
|
||||
|
||||
#define DEBUG_LAYER
|
||||
//#define DEBUG_LAYER
|
||||
|
||||
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
|
||||
TokenHandler view_token_handler;
|
||||
@ -970,3 +970,14 @@ BRect Layer::ConvertFromTop(BRect rect)
|
||||
else
|
||||
return(rect);
|
||||
}
|
||||
|
||||
// TODO: Implement and document
|
||||
void Layer::MakeTopChild(void)
|
||||
{
|
||||
}
|
||||
|
||||
// TODO: Implement and document
|
||||
void Layer::MakeBottomChild(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
Layer *FindLayer(int32 token);
|
||||
Layer *GetChildAt(BPoint pt, bool recursive=false);
|
||||
PortLink *GetLink(void);
|
||||
const char *GetName(void) { return (_name)?_name->String():NULL; }
|
||||
|
||||
void Invalidate(BRect rect);
|
||||
void Invalidate(BRegion region);
|
||||
|
@ -289,7 +289,7 @@ RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
|
||||
/*!
|
||||
\brief Prints the 32-bit values of the color to standard out
|
||||
*/
|
||||
void RGBColor::PrintToStream(void)
|
||||
void RGBColor::PrintToStream(void) const
|
||||
{
|
||||
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
RGBColor(const RGBColor &col);
|
||||
RGBColor(void);
|
||||
|
||||
void PrintToStream(void);
|
||||
void PrintToStream(void) const;
|
||||
|
||||
uint8 GetColor8(void);
|
||||
uint16 GetColor16(void);
|
||||
|
@ -44,11 +44,13 @@ RootLayer::RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver
|
||||
_driver=gfxdriver;
|
||||
_invalid=new BRegion(Bounds());
|
||||
_is_dirty=true;
|
||||
_bgcolor=new RGBColor();
|
||||
}
|
||||
|
||||
//! Frees all allocated heap memory (which happens to be none) ;)
|
||||
RootLayer::~RootLayer()
|
||||
{
|
||||
delete _bgcolor;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,58 +29,24 @@
|
||||
#define _SCREENDRIVER_H_
|
||||
|
||||
#include <Application.h>
|
||||
#include <WindowScreen.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include <GraphicsCard.h>
|
||||
#include <Accelerant.h>
|
||||
#include <GraphicsDefs.h> // for pattern struct
|
||||
#include <Cursor.h>
|
||||
#include <Message.h>
|
||||
#include <OS.h>
|
||||
#include <Locker.h>
|
||||
#include <Region.h> // for clipping_rect definition
|
||||
#include <Bitmap.h>
|
||||
#include <OS.h>
|
||||
#include <Region.h>
|
||||
#include <Font.h>
|
||||
#include "DisplayDriver.h"
|
||||
#include <ft2build.h>
|
||||
#include <WindowScreen.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
class VDWindow;
|
||||
class ServerCursor;
|
||||
class ServerBitmap;
|
||||
class RGBColor;
|
||||
class BBitmap;
|
||||
class PortLink;
|
||||
class SDWindow;
|
||||
class LayerData;
|
||||
class ScreenDriver;
|
||||
class PatternHandler;
|
||||
|
||||
// defines to translate acceleration function indices to something I can remember
|
||||
#define HWLINE_8BIT 3
|
||||
#define HWLINE_32BIT 4
|
||||
#define HWRECT_8BIT 5
|
||||
#define HWRECT_32BIT 6
|
||||
#define HWBLIT 7
|
||||
#define HWLINEARRAY_8BIT 8
|
||||
#define HWLINEARRAY_32BIT 9
|
||||
#define HWSYNC 10
|
||||
#define HWINVERT 11
|
||||
#define HWLINE_16BIT 12
|
||||
#define HWRECT_16BIT 13
|
||||
|
||||
// function pointer typedefs for accelerated 2d functions - from Be Advanced Topics.
|
||||
typedef int32 hwline8bit(int32 sx,int32 dx, int32 sy, int32 dy, uint8 color,
|
||||
bool cliptorect,int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom);
|
||||
typedef int32 hwline32bit(int32 sx,int32 dx, int32 sy, int32 dy, uint32 color,
|
||||
bool cliptorect,int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom);
|
||||
typedef int32 hwrect8bit(int32 left, int32 top, int32 right, int32 bottom, uint8 color);
|
||||
typedef int32 hwrect32bit(int32 left, int32 top, int32 right, int32 bottom, uint32 color);
|
||||
typedef int32 hwblit(int32 sx, int32 sy, int32 dx, int32 dy, int32 width, int32 height);
|
||||
typedef int32 hwlinearray8bit(indexed_color_line *array, int32 linecount,
|
||||
bool cliptorect,int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom);
|
||||
typedef int32 hwlinearray32bit(rgb_color_line *array, int32 linecount,
|
||||
bool cliptorect,int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom);
|
||||
typedef int32 hwsync(void);
|
||||
typedef int32 hwline16bit(int32 sx,int32 dx, int32 sy, int32 dy, uint16 color,
|
||||
bool cliptorect,int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom);
|
||||
typedef int32 hwrect16bit(int32 left, int32 top, int32 right, int32 bottom, uint16 color);
|
||||
|
||||
class FrameBuffer : public BWindowScreen
|
||||
{
|
||||
@ -92,9 +58,9 @@ public:
|
||||
bool IsConnected(void) const { return is_connected; }
|
||||
bool QuitRequested(void);
|
||||
static int32 MouseMonitor(void *data);
|
||||
|
||||
static int32 CopyThread(void *data);
|
||||
void Invalidate(const BRect &r);
|
||||
graphics_card_info gcinfo;
|
||||
|
||||
protected:
|
||||
friend ScreenDriver;
|
||||
|
||||
@ -102,56 +68,65 @@ protected:
|
||||
PortLink *serverlink;
|
||||
BPoint mousepos;
|
||||
uint32 buttons;
|
||||
thread_id monitor_thread;
|
||||
thread_id monitor_thread,copy_thread;
|
||||
BView *view;
|
||||
|
||||
// HW Acceleration stuff
|
||||
display_mode _dm;
|
||||
BBitmap *viewbmp;
|
||||
ServerBitmap *cursor;
|
||||
BRegion *invalid;
|
||||
int32 invalidflag;
|
||||
};
|
||||
/*
|
||||
class SDView : public BView
|
||||
{
|
||||
public:
|
||||
SDView(BRect bounds);
|
||||
~SDView(void);
|
||||
void AttachedToWindow(void);
|
||||
void Draw(BRect rect);
|
||||
void MouseDown(BPoint pt);
|
||||
void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg);
|
||||
void MouseUp(BPoint pt);
|
||||
void MessageReceived(BMessage *msg);
|
||||
|
||||
BBitmap *viewbmp;
|
||||
PortLink *serverlink;
|
||||
|
||||
frame_buffer_config _fbc;
|
||||
int hide_cursor;
|
||||
BBitmap *cursor;
|
||||
|
||||
set_cursor_shape _scs;
|
||||
move_cursor _mc;
|
||||
show_cursor _sc;
|
||||
sync_token _st;
|
||||
engine_token *_et;
|
||||
acquire_engine _ae;
|
||||
release_engine _re;
|
||||
fill_rectangle _frect;
|
||||
fill_span _fspan;
|
||||
BRect cursorframe, oldcursorframe;
|
||||
bool obscure_cursor;
|
||||
};
|
||||
*/
|
||||
class SDWindow : public BWindowScreen
|
||||
{
|
||||
public:
|
||||
SDWindow(void);
|
||||
~SDWindow(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
bool QuitRequested(void);
|
||||
void WindowActivated(bool active);
|
||||
|
||||
screen_to_screen_blit _s2sb;
|
||||
fill_rectangle _fr;
|
||||
invert_rectangle _ir;
|
||||
screen_to_screen_transparent_blit _s2stb;
|
||||
fill_span _fs;
|
||||
|
||||
hwline32bit _hwline32;
|
||||
hwrect32bit _hwrect32;
|
||||
|
||||
sync_token _stoken;
|
||||
// SDView *view;
|
||||
};
|
||||
|
||||
/*
|
||||
ScreenDriver.cpp
|
||||
Replacement class for the ViewDriver which utilizes a BWindowScreen for ease
|
||||
of testing without requiring a second video card for SecondDriver and also
|
||||
without the limitations (mostly speed) of ViewDriver.
|
||||
|
||||
This module also emulates the input server via the keyboard.
|
||||
Cursor keys move the mouse and the left modifier keys Option and Ctrl, which
|
||||
operate the first and second mouse buttons, respectively.
|
||||
The right window key on American keymaps doesn't map to anything, so it is
|
||||
not used. Consequently, when a right modifier key is pressed, it works normally.
|
||||
|
||||
The concept is pretty close to the retooled ViewDriver, where each module
|
||||
call locks a couple BLockers and draws to the buffer.
|
||||
|
||||
Components:
|
||||
ScreenDriver: actual driver module
|
||||
FrameBuffer: BWindowScreen derivative which provides the module access
|
||||
to the video card
|
||||
Internal functions for doing graphics on the buffer
|
||||
/*!
|
||||
\brief BView/BWindow combination graphics module
|
||||
|
||||
First, slowest, and easiest driver class in the app_server which is designed
|
||||
to utilize the BeOS graphics functions to cut out a lot of junk in getting the
|
||||
drawing infrastructure in this server.
|
||||
|
||||
The concept is to have SDView::Draw() draw a bitmap, which is a "frame buffer"
|
||||
of sorts, utilize a second view to write to it. This cuts out
|
||||
the most problems with having a crapload of code to get just right without
|
||||
having to write a bunch of unit tests
|
||||
|
||||
Components: 3 classes, SDView, SDWindow, and ScreenDriver
|
||||
|
||||
ScreenDriver - a wrapper class which mostly posts messages to the SDWindow
|
||||
SDWindow - does most of the work.
|
||||
SDView - doesn't do all that much except display the rendered bitmap
|
||||
*/
|
||||
class ScreenDriver : public DisplayDriver
|
||||
{
|
||||
@ -159,66 +134,67 @@ public:
|
||||
ScreenDriver(void);
|
||||
~ScreenDriver(void);
|
||||
|
||||
bool Initialize(void);
|
||||
void Shutdown(void);
|
||||
bool Initialize(void); // Sets the driver
|
||||
void Shutdown(void); // You never know when you'll need this
|
||||
|
||||
// Settings functions
|
||||
virtual void CopyBits(BRect src, BRect dest);
|
||||
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest, LayerData *d);
|
||||
// Drawing functions
|
||||
void CopyBits(BRect src, BRect dest);
|
||||
void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest);
|
||||
void DrawChar(char c, BPoint pt, LayerData *d);
|
||||
// virtual void DrawPicture(SPicture *pic, BPoint pt);
|
||||
virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL);
|
||||
void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL);
|
||||
|
||||
virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
|
||||
virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat);
|
||||
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat);
|
||||
// virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat);
|
||||
virtual void FillRect(BRect r, LayerData *d, int8 *pat);
|
||||
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
|
||||
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat);
|
||||
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
|
||||
void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
|
||||
void FillBezier(BPoint *pts, LayerData *d, int8 *pat);
|
||||
void FillEllipse(BRect r, LayerData *d, int8 *pat);
|
||||
void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat);
|
||||
void FillRect(BRect r, LayerData *d, int8 *pat);
|
||||
void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
|
||||
// void FillShape(SShape *sh, LayerData *d, int8 *pat);
|
||||
void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
|
||||
|
||||
virtual void HideCursor(void);
|
||||
virtual void MoveCursorTo(float x, float y);
|
||||
virtual void InvertRect(BRect r);
|
||||
virtual void ShowCursor(void);
|
||||
virtual void ObscureCursor(void);
|
||||
virtual void SetCursor(ServerCursor *cursor);
|
||||
void HideCursor(void);
|
||||
void InvertRect(BRect r);
|
||||
bool IsCursorHidden(void);
|
||||
void MoveCursorTo(float x, float y);
|
||||
// void MovePenTo(BPoint pt);
|
||||
void ObscureCursor(void);
|
||||
// BPoint PenPosition(void);
|
||||
// float PenSize(void);
|
||||
void SetCursor(ServerCursor *cursor);
|
||||
// drawing_mode GetDrawingMode(void);
|
||||
// void SetDrawingMode(drawing_mode mode);
|
||||
void ShowCursor(void);
|
||||
|
||||
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
|
||||
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
|
||||
virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat);
|
||||
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat);
|
||||
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true);
|
||||
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat);
|
||||
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
|
||||
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat);
|
||||
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
|
||||
// virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d);
|
||||
virtual void SetMode(int32 mode);
|
||||
void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat);
|
||||
void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat);
|
||||
void StrokeEllipse(BRect r, LayerData *d, int8 *pat);
|
||||
void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat);
|
||||
void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d);
|
||||
void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true);
|
||||
void StrokeRect(BRect r, LayerData *d, int8 *pat);
|
||||
void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
|
||||
// void StrokeShape(SShape *sh, LayerData *d, int8 *pat);
|
||||
void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
|
||||
void SetMode(int32 mode);
|
||||
float StringWidth(const char *string, int32 length, LayerData *d);
|
||||
float StringHeight(const char *string, int32 length, LayerData *d);
|
||||
virtual bool DumpToFile(const char *path);
|
||||
bool DumpToFile(const char *path);
|
||||
FrameBuffer *screenwin;
|
||||
protected:
|
||||
void SetLayerData(LayerData *d, bool set_font_data=false);
|
||||
void BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
|
||||
void BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
|
||||
void BlitBitmap(ServerBitmap *sourcebmp, BRect sourcerect, BRect destrect, drawing_mode mode=B_OP_COPY);
|
||||
void ExtractToBitmap(ServerBitmap *destbmp, BRect destrect, BRect sourcerect);
|
||||
void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex);
|
||||
void Line(BPoint start, BPoint end, LayerData *d, int8 *pat);
|
||||
void HLine(int32 x1, int32 x2, int32 y, RGBColor color);
|
||||
void HLineThick(int32 x1, int32 x2, int32 y, int32 thick, PatternHandler *pat);
|
||||
rgb_color GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true);
|
||||
void SetPixel(int x, int y, RGBColor col);
|
||||
void SetPixel32(int x, int y, rgb_color col);
|
||||
void SetPixel16(int x, int y, uint16 col);
|
||||
void SetPixel8(int x, int y, uint8 col);
|
||||
void SetThickPixel(int x, int y, int thick, RGBColor col);
|
||||
void SetThickPixel32(int x, int y, int thick, rgb_color col);
|
||||
void SetThickPixel16(int x, int y, int thick, uint16 col);
|
||||
void SetThickPixel8(int x, int y, int thick, uint8 col);
|
||||
FrameBuffer *fbuffer;
|
||||
ServerCursor *cursor, *under_cursor;
|
||||
BRect cursorframe;
|
||||
int hide_cursor;
|
||||
bool obscure_cursor;
|
||||
BBitmap *framebuffer;
|
||||
BView *drawview;
|
||||
BRegion laregion;
|
||||
PortLink *serverlink;
|
||||
|
||||
rgb_color highcolor,lowcolor;
|
||||
bool is_initialized;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -89,7 +89,7 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s
|
||||
_appcursor=(defaultc)?new ServerCursor(defaultc):NULL;
|
||||
_lock=create_sem(1,"ServerApp sem");
|
||||
|
||||
_driver=GetGfxDriver();
|
||||
_driver=GetGfxDriver(ActiveScreen());
|
||||
_cursorhidden=false;
|
||||
|
||||
#ifdef DEBUG_SERVERAPP
|
||||
@ -534,7 +534,7 @@ printf("ServerApp %s: Download Picture unimplemented\n",_signature.String());
|
||||
#ifdef DEBUG_SERVERAPP
|
||||
printf("ServerApp %s: SetScreenMode: workspace %ld, mode %lu\n",_signature.String(), workspace, mode);
|
||||
#endif
|
||||
SetSpace(workspace,mode,*((bool*)index));
|
||||
SetSpace(workspace,mode,ActiveScreen(),*((bool*)index));
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define HWDRIVER 3
|
||||
|
||||
// Display driver to be used by the server.
|
||||
#define DISPLAYDRIVER VIEWDRIVER
|
||||
#define DISPLAYDRIVER SCREENDRIVER
|
||||
|
||||
// Uncomment this if the DisplayDriver should only rely on drawing functions implemented
|
||||
// in software even though hardware-accelerated functions are available
|
||||
|
@ -92,7 +92,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
||||
|
||||
_token=win_token_handler.GetToken();
|
||||
|
||||
AddWindowToDesktop(this,index);
|
||||
AddWindowToDesktop(this,index,ActiveScreen());
|
||||
#ifdef DEBUG_SERVERWINDOW
|
||||
printf("ServerWindow %s:\n",_title->String());
|
||||
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
|
||||
@ -658,16 +658,20 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
||||
#ifdef DEBUG_SERVERWINDOW_MOUSE
|
||||
printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
#endif
|
||||
/* ServerWindow *mousewin=NULL;
|
||||
ServerWindow *mousewin=NULL;
|
||||
int8 *index=buffer;
|
||||
|
||||
// Find the window which will receive our mouse event.
|
||||
Layer *root=GetRootLayer();
|
||||
Layer *root=GetRootLayer(CurrentWorkspace(),ActiveScreen());
|
||||
WinBorder *_winborder;
|
||||
|
||||
// activeborder is used to remember windows when resizing/moving windows
|
||||
// or sliding a tab
|
||||
ASSERT(root!=NULL);
|
||||
if(!root)
|
||||
{
|
||||
printf("ERROR: HandleMouseEvent has NULL root layer!!!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispatch the mouse event to the proper window
|
||||
switch(code)
|
||||
@ -684,14 +688,10 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
|
||||
// int64 time=*((int64*)index);
|
||||
index+=sizeof(int64);
|
||||
float x=*((float*)index);
|
||||
index+=sizeof(float);
|
||||
float y=*((float*)index);
|
||||
index+=sizeof(float);
|
||||
int32 modifiers=*((int32*)index);
|
||||
index+=sizeof(uint32);
|
||||
uint32 buttons=*((uint32*)index);
|
||||
index+=sizeof(uint32);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
// int32 modifiers=*((int32*)index); index+=sizeof(uint32);
|
||||
// uint32 buttons=*((uint32*)index); index+=sizeof(uint32);
|
||||
// int32 clicks=*((int32*)index);
|
||||
BPoint pt(x,y);
|
||||
|
||||
@ -700,7 +700,7 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
if(_winborder)
|
||||
{
|
||||
mousewin=_winborder->Window();
|
||||
_winborder->MouseDown(pt,buttons,modifiers);
|
||||
_winborder->MouseDown(buffer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -714,10 +714,8 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
|
||||
// int64 time=*((int64*)index);
|
||||
index+=sizeof(int64);
|
||||
float x=*((float*)index);
|
||||
index+=sizeof(float);
|
||||
float y=*((float*)index);
|
||||
index+=sizeof(float);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
// int32 modifiers=*((int32*)index);
|
||||
BPoint pt(x,y);
|
||||
|
||||
@ -729,8 +727,7 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
|
||||
// Eventually, we will build in MouseUp messages with buttons specified
|
||||
// For now, we just "assume" no mouse specification with a 0.
|
||||
// _winborder->MouseUp(pt,0,0);
|
||||
|
||||
_winborder->MouseUp(buffer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -743,26 +740,25 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
// 4) int32 - buttons down
|
||||
// int64 time=*((int64*)index);
|
||||
index+=sizeof(int64);
|
||||
float x=*((float*)index);
|
||||
index+=sizeof(float);
|
||||
float y=*((float*)index);
|
||||
index+=sizeof(float);
|
||||
uint32 buttons=*((uint32*)index);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
// uint32 buttons=*((uint32*)index);
|
||||
BPoint pt(x,y);
|
||||
|
||||
if(is_moving_window() || is_resizing_window() || is_sliding_tab())
|
||||
// TODO: Fix
|
||||
/* if(is_moving_window() || is_resizing_window() || is_sliding_tab())
|
||||
{
|
||||
mousewin=active_serverwindow;
|
||||
mousewin->_winborder->MouseMoved(pt,buttons,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_winborder=(WinBorder*)root->GetChildAt(pt);
|
||||
*/ _winborder=(WinBorder*)root->GetChildAt(pt);
|
||||
if(_winborder)
|
||||
{
|
||||
mousewin=_winborder->Window();
|
||||
_winborder->MouseMoved(pt,buttons,0);
|
||||
}
|
||||
_winborder->MouseMoved(buffer);
|
||||
// }
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -771,7 +767,6 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -37,8 +37,9 @@
|
||||
#include "WinBorder.h"
|
||||
#include "AppServer.h" // for new_decorator()
|
||||
|
||||
#define DEBUG_WINBORDER
|
||||
//#define DEBUG_WINBORDER
|
||||
//#define DEBUG_WINBORDER_MOUSE
|
||||
//#define DEBUG_WINBORDER_CLICK
|
||||
|
||||
#ifdef DEBUG_WINBORDER
|
||||
#include <stdio.h>
|
||||
@ -48,6 +49,10 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
namespace winborder_private
|
||||
{
|
||||
bool is_moving_window=false;
|
||||
@ -62,6 +67,8 @@ bool is_moving_window(void) { return winborder_private::is_moving_window; }
|
||||
void set_is_moving_window(bool state) { winborder_private::is_moving_window=state; }
|
||||
bool is_resizing_window(void) { return winborder_private::is_resizing_window; }
|
||||
void set_is_resizing_window(bool state) { winborder_private::is_resizing_window=state; }
|
||||
bool is_sliding_tab(void) { return winborder_private::is_sliding_tab; }
|
||||
void set_is_sliding_tab(bool state) { winborder_private::is_sliding_tab=state; }
|
||||
WinBorder * get_active_winborder(void) { return winborder_private::active_winborder; }
|
||||
void set_active_winborder(WinBorder *win) { winborder_private::active_winborder=win; }
|
||||
|
||||
@ -80,8 +87,8 @@ WinBorder::WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 fl
|
||||
_hresizewin=false;
|
||||
_vresizewin=false;
|
||||
|
||||
_decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver());
|
||||
_decorator->SetDriver(GetGfxDriver());
|
||||
_decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver(ActiveScreen()));
|
||||
_decorator->SetDriver(GetGfxDriver(ActiveScreen()));
|
||||
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s:\n",_title->String());
|
||||
@ -103,37 +110,67 @@ void WinBorder::MouseDown(int8 *buffer)
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseDown unimplemented\n",_title->String());
|
||||
#endif
|
||||
/* _mbuttons=buttons;
|
||||
kmodifiers=modifiers;
|
||||
click_type click=_decorator->Clicked(pt, _mbuttons, kmodifiers);
|
||||
// Buffer data:
|
||||
// 1) int64 - time of mouse click
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - modifier keys down
|
||||
// 5) int32 - buttons down
|
||||
// 6) int32 - clicks
|
||||
int8 *index=buffer; index+=sizeof(int64);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
int32 modifiers=*((int32*)index); index+=sizeof(int32);
|
||||
int32 buttons=*((int32*)index);
|
||||
|
||||
BPoint pt(x,y);
|
||||
|
||||
_mbuttons=buttons;
|
||||
_kmodifiers=modifiers;
|
||||
click_type click=_decorator->Clicked(pt, _mbuttons, _kmodifiers);
|
||||
_mousepos=pt;
|
||||
|
||||
switch(click)
|
||||
{
|
||||
case CLICK_MOVETOBACK:
|
||||
{
|
||||
MoveToBack();
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToBack\n");
|
||||
#endif
|
||||
MakeTopChild();
|
||||
break;
|
||||
}
|
||||
case CLICK_MOVETOFRONT:
|
||||
{
|
||||
MoveToFront();
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToFront\n");
|
||||
#endif
|
||||
MakeBottomChild();
|
||||
break;
|
||||
}
|
||||
case CLICK_CLOSE:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Close\n");
|
||||
#endif
|
||||
_decorator->SetClose(true);
|
||||
_decorator->Draw();
|
||||
break;
|
||||
}
|
||||
case CLICK_ZOOM:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Zoom\n");
|
||||
#endif
|
||||
_decorator->SetZoom(true);
|
||||
_decorator->Draw();
|
||||
break;
|
||||
}
|
||||
case CLICK_MINIMIZE:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Minimize\n");
|
||||
#endif
|
||||
_decorator->SetMinimize(true);
|
||||
_decorator->Draw();
|
||||
break;
|
||||
@ -141,21 +178,40 @@ printf("WinBorder %s: MouseDown unimplemented\n",_title->String());
|
||||
case CLICK_DRAG:
|
||||
{
|
||||
if(buttons==B_PRIMARY_MOUSE_BUTTON)
|
||||
is_moving_window=true;
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Drag\n");
|
||||
#endif
|
||||
MakeBottomChild();
|
||||
set_is_moving_window(true);
|
||||
}
|
||||
|
||||
if(buttons==B_SECONDARY_MOUSE_BUTTON)
|
||||
MoveToBack();
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToBack\n");
|
||||
#endif
|
||||
MakeTopChild();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLICK_SLIDETAB:
|
||||
{
|
||||
is_sliding_tab=true;
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Slide Tab\n");
|
||||
#endif
|
||||
set_is_sliding_tab(true);
|
||||
break;
|
||||
}
|
||||
case CLICK_RESIZE:
|
||||
{
|
||||
if(buttons==B_PRIMARY_MOUSE_BUTTON)
|
||||
is_resizing_window=true;
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Resize\n");
|
||||
#endif
|
||||
set_is_resizing_window(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLICK_NONE:
|
||||
@ -167,19 +223,30 @@ printf("WinBorder %s: MouseDown unimplemented\n",_title->String());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(click!=CLICK_NONE)
|
||||
ActivateWindow(_win);
|
||||
*/
|
||||
// TODO: fix this
|
||||
// if(click!=CLICK_NONE)
|
||||
// ActivateWindow(_win);
|
||||
}
|
||||
|
||||
void WinBorder::MouseMoved(int8 *buffer)
|
||||
{
|
||||
// Buffer data:
|
||||
// 1) int64 - time of mouse click
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - buttons down
|
||||
int8 *index=buffer; index+=sizeof(int64);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
int32 buttons=*((int32*)index);
|
||||
|
||||
BPoint pt(x,y);
|
||||
click_type click=_decorator->Clicked(pt, _mbuttons, _kmodifiers);
|
||||
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseMoved unimplemented\n",_title->String());
|
||||
#endif
|
||||
/* _mbuttons=buttons;
|
||||
kmodifiers=modifiers;
|
||||
click_type click=_decorator->Clicked(pt, _mbuttons, kmodifiers);
|
||||
|
||||
if(click!=CLICK_CLOSE && _decorator->GetClose())
|
||||
{
|
||||
_decorator->SetClose(false);
|
||||
@ -198,8 +265,11 @@ printf("WinBorder %s: MouseMoved unimplemented\n",_title->String());
|
||||
_decorator->Draw();
|
||||
}
|
||||
|
||||
if(is_sliding_tab)
|
||||
if(is_sliding_tab())
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Slide Tab\n");
|
||||
#endif
|
||||
float dx=pt.x-_mousepos.x;
|
||||
|
||||
if(dx!=0)
|
||||
@ -207,75 +277,97 @@ printf("WinBorder %s: MouseMoved unimplemented\n",_title->String());
|
||||
// SlideTab returns how much things were moved, and currently
|
||||
// supports just the x direction, so get the value so
|
||||
// we can invalidate the proper area.
|
||||
layerlock->Lock();
|
||||
parent->Invalidate(_decorator->SlideTab(dx,0));
|
||||
parent->RequestDraw();
|
||||
lock_layers();
|
||||
_parent->Invalidate(_decorator->SlideTab(dx,0));
|
||||
_parent->RequestDraw();
|
||||
_decorator->DrawTab();
|
||||
layerlock->Unlock();
|
||||
unlock_layers();
|
||||
}
|
||||
}
|
||||
if(is_moving_window)
|
||||
|
||||
|
||||
if(is_moving_window())
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Drag\n");
|
||||
#endif
|
||||
float dx=pt.x-_mousepos.x,
|
||||
dy=pt.y-_mousepos.y;
|
||||
if(dx!=0 || dy!=0)
|
||||
if(buttons!=0 && (dx!=0 || dy!=0))
|
||||
{
|
||||
BRect oldmoveframe=_win->_frame;
|
||||
clientframe.OffsetBy(pt);
|
||||
_clientframe.OffsetBy(pt);
|
||||
|
||||
_win->Lock();
|
||||
_win->_frame.OffsetBy(dx,dy);
|
||||
_win->Unlock();
|
||||
|
||||
layerlock->Lock();
|
||||
// InvalidateLowerSiblings(oldmoveframe);
|
||||
parent->Invalidate(oldmoveframe);
|
||||
lock_layers();
|
||||
_parent->Invalidate(oldmoveframe);
|
||||
MoveBy(dx,dy);
|
||||
parent->RequestDraw();
|
||||
_parent->RequestDraw();
|
||||
_decorator->MoveBy(BPoint(dx, dy));
|
||||
_decorator->Draw();
|
||||
layerlock->Unlock();
|
||||
unlock_layers();
|
||||
}
|
||||
}
|
||||
if(is_resizing_window)
|
||||
|
||||
|
||||
if(is_resizing_window())
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Resize\n");
|
||||
#endif
|
||||
float dx=pt.x-_mousepos.x,
|
||||
dy=pt.y-_mousepos.y;
|
||||
if(dx!=0 || dy!=0)
|
||||
if(buttons!=0 && (dx!=0 || dy!=0))
|
||||
{
|
||||
clientframe.right+=dx;
|
||||
clientframe.bottom+=dy;
|
||||
_clientframe.right+=dx;
|
||||
_clientframe.bottom+=dy;
|
||||
|
||||
_win->Lock();
|
||||
_win->_frame.right+=dx;
|
||||
_win->_frame.bottom+=dy;
|
||||
_win->Unlock();
|
||||
|
||||
layerlock->Lock();
|
||||
lock_layers();
|
||||
ResizeBy(dx,dy);
|
||||
parent->RequestDraw();
|
||||
layerlock->Unlock();
|
||||
_parent->RequestDraw();
|
||||
unlock_layers();
|
||||
_decorator->ResizeBy(dx,dy);
|
||||
_decorator->Draw();
|
||||
}
|
||||
}
|
||||
|
||||
_mousepos=pt;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void WinBorder::MouseUp(int8 *buffer)
|
||||
{
|
||||
// buffer data:
|
||||
// 1) int64 - time of mouse click
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - modifier keys down
|
||||
int8 *index=buffer; index+=sizeof(int64);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
int32 modifiers=*((int32*)index);
|
||||
BPoint pt(x,y);
|
||||
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
|
||||
#endif
|
||||
/*
|
||||
_mbuttons=buttons;
|
||||
kmodifiers=modifiers;
|
||||
is_moving_window=false;
|
||||
is_resizing_window=false;
|
||||
is_sliding_tab=false;
|
||||
|
||||
click_type click=_decorator->Clicked(pt, _mbuttons, kmodifiers);
|
||||
_mbuttons=0;
|
||||
_kmodifiers=modifiers;
|
||||
|
||||
set_is_moving_window(false);
|
||||
set_is_resizing_window(false);
|
||||
set_is_sliding_tab(false);
|
||||
|
||||
click_type click=_decorator->Clicked(pt, _mbuttons, _kmodifiers);
|
||||
|
||||
switch(click)
|
||||
{
|
||||
@ -310,7 +402,6 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void WinBorder::RequestDraw(const BRect &r)
|
||||
|
Loading…
Reference in New Issue
Block a user