options=opts;
#ifdef WIN32
- // XXX Preserve position
- MoveWindow(window, 0, 0, options.width, options.height, false);
+ RECT rect;
+ SetRect(&rect, 0, 0, options.width, options.height);
+
+ int style=(options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
+ if(!options.resizable)
+ style&=~WS_THICKFRAME;
+ int exstyle=(options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
+ AdjustWindowRectEx(&rect, style, false, exstyle);
+
+ if(fullscreen_changed)
+ {
+ hide();
+ SetWindowLong(window, GWL_EXSTYLE, exstyle);
+ SetWindowLong(window, GWL_STYLE, style);
+ show();
+ }
+
+ if(options.fullscreen)
+ SetWindowPos(window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
+ else
+ SetWindowPos(window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE|SWP_NOZORDER);
(void)fullscreen_changed;
#else
::Display *dpy=display.get_display();
- XMoveResizeWindow(dpy, window, 0, 0, options.width, options.height);
-
if(fullscreen_changed)
{
hide();
show();
}
+ XSizeHints hints;
+ if(options.resizable)
+ hints.flags=0;
+ else
+ {
+ hints.flags=PMinSize|PMaxSize;
+ hints.min_width=hints.max_width=options.width;
+ hints.min_height=hints.max_height=options.height;
+ }
+ XSetWMNormalHints(dpy, window, &hints);
+
+ if(options.fullscreen)
+ XMoveResizeWindow(dpy, window, 0, 0, options.width, options.height);
+ else
+ XResizeWindow(dpy, window, options.width, options.height);
+#endif
+
if(options.fullscreen)
display.set_mode(VideoMode(options.width, options.height));
else if(fullscreen_changed)
display.restore_mode();
-#endif
}
void Window::show()
}
RECT rect;
- rect.left=0;
- rect.top=0;
- rect.right=options.width;
- rect.bottom=options.height;
- AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, false, WS_EX_OVERLAPPEDWINDOW);
+ SetRect(&rect, 0, 0, options.width, options.height);
- window=CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
+ int style=(options.fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW);
+ if(!options.resizable)
+ style&=~WS_THICKFRAME;
+ int exstyle=(options.fullscreen ? WS_EX_APPWINDOW : WS_EX_OVERLAPPEDWINDOW);
+ AdjustWindowRectEx(&rect, style, false, exstyle);
+
+ window=CreateWindowEx(exstyle,
"mspgbase",
"Window",
- WS_OVERLAPPEDWINDOW,
+ style,
CW_USEDEFAULT, CW_USEDEFAULT,
rect.right-rect.left, rect.bottom-rect.top,
0,
if(!window)
throw Exception("CreateWindowEx failed");
+ if(options.fullscreen)
+ display.set_mode(VideoMode(options.width, options.height));
+
#else
::Display *dpy=display.get_display();
XSetWMProtocols(dpy, window, &wm_delete_window, 1);
+ if(!options.resizable)
+ {
+ XSizeHints hints;
+ hints.flags=PMinSize|PMaxSize;
+ hints.min_width=hints.max_width=options.width;
+ hints.min_height=hints.max_height=options.height;
+ XSetWMNormalHints(dpy, window, &hints);
+ }
+
if(options.fullscreen)
{
display.set_mode(VideoMode(options.width, options.height));
case WM_MOUSEMOVE:
signal_pointer_motion.emit(GET_X_LPARAM(lp), GET_Y_LPARAM(lp));
break;
+ case WM_SIZE:
+ options.width=LOWORD(lp);
+ options.height=HIWORD(lp);
+ signal_resize.emit(options.width, options.height);
+ break;
case WM_CLOSE:
signal_close.emit();
break;