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:
DarkWyrm
2003-04-05 01:51:35 +00:00
parent 0fe548713a
commit 47b0fc0ee3
17 changed files with 1065 additions and 1967 deletions
+138 -47
View File
@@ -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)