Skip to content

Commit

Permalink
WIN32 fixes from Gustavo for fullscreen mode problems.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/trunk@68 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Nov 8, 1998
1 parent 39be223 commit 37d1178
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 57 deletions.
7 changes: 3 additions & 4 deletions FL/win32.H
@@ -1,5 +1,5 @@
//
// "$Id: win32.H,v 1.10 1998/11/05 16:27:24 mike Exp $"
// "$Id: win32.H,v 1.11 1998/11/08 14:36:54 mike Exp $"
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -74,9 +74,8 @@ public:
HCURSOR cursor;
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return w->i;}
static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
int &bt,int &bx,int &by);
static int get_border(const Fl_Window* w,int &bt,int &bx,int &by);
void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
void flush() {w->flush();}
void set_minmax(LPMINMAXINFO minmax);
Expand Down Expand Up @@ -121,5 +120,5 @@ void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy)
#define fl_delete_offscreen(bitmap) DeleteObject(bitmap);

//
// End of "$Id: win32.H,v 1.10 1998/11/05 16:27:24 mike Exp $".
// End of "$Id: win32.H,v 1.11 1998/11/08 14:36:54 mike Exp $".
//
13 changes: 7 additions & 6 deletions src/Fl_Window_fullscreen.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_fullscreen.cxx,v 1.3 1998/10/21 14:20:27 mike Exp $"
// "$Id: Fl_Window_fullscreen.cxx,v 1.4 1998/11/08 14:36:55 mike Exp $"
//
// Fullscreen window support for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -53,22 +53,23 @@ void Fl_Window::border(int b) {
}

void Fl_Window::fullscreen() {
#ifndef WIN32
//this would clobber the fake wm, since it relies on the border flags to
//determine its thickness
border(0);
#endif
if (!x()) x(1); // force it to call XResizeWindow()
resize(0,0,Fl::w(),Fl::h());
}

void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
#ifdef WIN32
border(1);
resize(X,Y,W,H);
#else
// this order produces less blinking on IRIX:
resize(X,Y,W,H);
#ifndef WIN32
border(1);
#endif
}

//
// End of "$Id: Fl_Window_fullscreen.cxx,v 1.3 1998/10/21 14:20:27 mike Exp $".
// End of "$Id: Fl_Window_fullscreen.cxx,v 1.4 1998/11/08 14:36:55 mike Exp $".
//
19 changes: 11 additions & 8 deletions src/Fl_Window_hotspot.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_hotspot.cxx,v 1.4 1998/11/05 16:04:48 mike Exp $"
// "$Id: Fl_Window_hotspot.cxx,v 1.5 1998/11/08 14:36:55 mike Exp $"
//
// Common hotspot routines for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -34,18 +34,20 @@ void Fl_Window::hotspot(int X, int Y, int offscreen) {
int mx,my; Fl::get_mouse(mx,my);
X = mx-X; Y = my-Y;
if (!offscreen) {
if (border()) {
// ensure border is on screen:
#ifdef WIN32
int top, left, right, bottom;
Fl_X::get_border(this, top, left, bottom);
right = left; top += bottom;
//These will be used by reference, so we must passed different variables
int bt,bx,by;
x(X);y(Y);
Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
//force FL_FORCE_POSITION to be set in Fl_Window::resize()
if (X==x()) x(X-1);
#else
if (border()) {
// ensure border is on screen:
const int top = 20;
const int left = 1;
const int right = 1;
const int bottom = 1;
#endif
if (X+w()+right > Fl::w()) X = Fl::w()-right-w();
if (X-left < 0) X = left;
if (Y+h()+bottom > Fl::h()) Y = Fl::h()-bottom-h();
Expand All @@ -56,6 +58,7 @@ void Fl_Window::hotspot(int X, int Y, int offscreen) {
if (X < 0) X = 0;
if (Y+h() > Fl::h()) Y = Fl::h()-h();
if (Y < 0) Y = 0;
#endif
}
position(X,Y);
}
Expand All @@ -71,5 +74,5 @@ void Fl_Window::hotspot(const Fl_Widget *o, int offscreen) {
}

//
// End of "$Id: Fl_Window_hotspot.cxx,v 1.4 1998/11/05 16:04:48 mike Exp $".
// End of "$Id: Fl_Window_hotspot.cxx,v 1.5 1998/11/08 14:36:55 mike Exp $".
//
108 changes: 69 additions & 39 deletions src/Fl_win32.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_win32.cxx,v 1.12 1998/11/06 14:32:17 mike Exp $"
// "$Id: Fl_win32.cxx,v 1.13 1998/11/08 14:36:56 mike Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -220,9 +220,9 @@ static int ms2fltk(int vk, int extended) {
for (i = 0; i < sizeof(vktab)/sizeof(*vktab); i++) {
vklut[vktab[i].vk] = vktab[i].fltk;
extendedlut[vktab[i].vk] = vktab[i].extended;
}
for (i = 0; i < 256; i++) if (!extendedlut[i]) extendedlut[i] = vklut[i];
}
for (i = 0; i < 256; i++) if (!extendedlut[i]) extendedlut[i] = vklut[i];
}
return extended ? extendedlut[vk] : vklut[vk];
}

Expand Down Expand Up @@ -251,6 +251,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
return 0;

case WM_PAINT: {

#if USE_COLORMAP
// Before we do a paint we need to tell Windows what color palette to
// use. This is because Windows will map our color indices to the
Expand All @@ -259,7 +260,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar

fl_GetDC(hWnd);
fl_select_palette();

#endif

// This might be a better alternative, where we fully ignore NT's
// "facilities" for painting. MS expects applications to paint according
// to a very restrictive paradigm, and this is the way I found of
Expand Down Expand Up @@ -408,6 +410,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
fl_GetDC(hWnd);
fl_select_palette();
break;

#endif

default:
Expand All @@ -427,26 +430,51 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
//
// value | border | title bar
// 0 | none | no
// 1 | fix | no
// 2 | fix | yes
// 3 | size | yes
// 1 | fix | yes
// 2 | size | yes

int Fl_X::get_border(const Fl_Window* w,int &T, int &X, int &Y) {
int ret = T = X = Y = 0;
int Fl_X::fake_X_wm(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by) {
int W, H, xoff, yoff, dx, dy;
int ret = bx = by = bt = 0;
if (w->border() && !w->parent()) {
ret = 2;
if ((w->maxw != w->minw || w->maxh != w->minh) && !w->non_modal()) {
ret |= 1;
X = GetSystemMetrics(SM_CXSIZEFRAME);
Y = GetSystemMetrics(SM_CYSIZEFRAME);
if (w->maxw != w->minw || w->maxh != w->minh) {
ret = 2;
bx = GetSystemMetrics(SM_CXSIZEFRAME);
by = GetSystemMetrics(SM_CYSIZEFRAME);
} else {
X = GetSystemMetrics(SM_CXFIXEDFRAME);
Y = GetSystemMetrics(SM_CYFIXEDFRAME);
}
if (w->modal())
ret = 1;
else T = GetSystemMetrics(SM_CYCAPTION);
bx = GetSystemMetrics(SM_CXFIXEDFRAME);
by = GetSystemMetrics(SM_CYFIXEDFRAME);
}
bt = GetSystemMetrics(SM_CYCAPTION);
}
//The coordinates of the whole window, including non-client area
xoff = bx;
yoff = by + bt;
dx = 2*bx;
dy = 2*by + bt;
X = w->x()-xoff;
Y = w->y()-yoff;
W = w->w()+dx;
H = w->h()+dy;

//Proceed to positioning the window fully inside the screen, if possible
//Make border's lower right corner visible
if (Fl::w() < X+W) X = Fl::w() - W;
if (Fl::h() < Y+H) Y = Fl::h() - H;
//Make border's upper left corner visible
if (X<0) X = 0;
if (Y<0) Y = 0;
//Make client area's lower right corner visible
if (Fl::w() < X+dx+ w->w()) X = Fl::w() - w->w() - dx;
if (Fl::h() < Y+dy+ w->h()) Y = Fl::h() - w->h() - dy;
//Make client area's upper left corner visible
if (X+xoff < 0) X = -xoff;
if (Y+yoff < 0) Y = -yoff;
//Return the client area's top left corner in (X,Y)
X+=xoff;
Y+=yoff;

return ret;
}

Expand All @@ -464,15 +492,18 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
if (shown()) {redraw(); i->wait_for_expose = 1;}
} else {
x(X); y(Y);
flags |= SWP_NOSIZE;
}
if (resize_from_program && shown()) {
int bt, bx, by;
if (Fl_X::get_border(this, bt, bx, by)) {
int dummy, bt, bx, by;
//Ignore window managing when resizing, so that windows (and more
//specifically menus) can be moved offscreen.
if (Fl_X::fake_X_wm(this, dummy, dummy, bt, bx, by)) {
X -= bx;
Y -= by+bt;
W += 2*bx;
H += 2*by+bt;
} else {flags |= SWP_NOSIZE;}
}
SetWindowPos(i->xid, 0, X, Y, W, H, flags);
}
}
Expand Down Expand Up @@ -535,33 +566,32 @@ Fl_X* Fl_X::make(Fl_Window* w) {
}
}
styleEx |= WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
int bt, bx, by;
switch (Fl_X::get_border(w, bt, bx, by)) {
int xwm = xp , ywm = yp , bt, bx, by;
switch (fake_X_wm(w, xwm, ywm, bt, bx, by)) {
// No border (user for menus)
case 0: style |= WS_POPUP; break;

// Thin border
case 1: style |= WS_POPUP | WS_DLGFRAME; break;

// Thin border and title bar
case 2: style |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU;
if (!w->non_modal()) style |= WS_MINIMIZEBOX; break;
case 1: style |= WS_DLGFRAME | WS_CAPTION; break;

// Thick, resizable border and title bar, with maximize button
case 3: style |= WS_THICKFRAME | WS_MAXIMIZEBOX | WS_CAPTION |
WS_SYSMENU | WS_MINIMIZEBOX;
case 2: style |= WS_THICKFRAME | WS_MAXIMIZEBOX | WS_CAPTION ; break;
}
if (by+bt) {
if (!w->non_modal()) style |= WS_SYSMENU | WS_MINIMIZEBOX;
wp += 2*bx;
hp += 2*by+bt;
}
wp += 2*bx;
hp += 2*by+bt;

if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) {
xp = yp = CW_USEDEFAULT;
} else {
if (!Fl::grab()) {
xp = xwm; yp = ywm;
w->x(xp);w->y(yp);
}
xp -= bx;
yp -= by+bt;
}
// if (xp<0) xp = 0;
// if (yp<0) yp = 0;

parent = 0;
if (w->non_modal() && !fl_disable_transient_for) {
Expand Down Expand Up @@ -634,9 +664,9 @@ void Fl_Window::size_range_() {

void Fl_X::set_minmax(LPMINMAXINFO minmax)
{
int td, wd, hd;
int td, wd, hd, dummy;

get_border(w, td, wd, hd);
fake_X_wm(w, dummy, dummy, td, wd, hd);
wd *= 2;
hd *= 2;
hd += td;
Expand Down Expand Up @@ -783,5 +813,5 @@ void Fl_Window::flush() {
}

//
// End of "$Id: Fl_win32.cxx,v 1.12 1998/11/06 14:32:17 mike Exp $".
// End of "$Id: Fl_win32.cxx,v 1.13 1998/11/08 14:36:56 mike Exp $".
//

0 comments on commit 37d1178

Please sign in to comment.