}
if (drawable->visible &&
- width <= glretrace::drawable->width &&
- height <= glretrace::drawable->height) {
+ width <= drawable->width &&
+ height <= drawable->height) {
return;
}
return;
}
- glretrace::drawable->resize(width, height);
- if (!drawable->visible) {
- drawable->show();
- }
+ drawable->resize(width, height);
+ drawable->show();
+
glScissor(0, 0, width, height);
}
}
}
-static void waitForEvent(Window window, int type) {
- XFlush(display);
- XEvent event;
- do {
- XNextEvent(display, &event);
- describeEvent(event);
- } while (event.type != type ||
- event.xany.window != window);
-}
-
-
class GlxDrawable : public Drawable
{
public:
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
- attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ attr.event_mask = StructureNotifyMask;
unsigned long mask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
glXWaitX();
}
+ void waitForEvent(int type) {
+ XEvent event;
+ do {
+ XWindowEvent(display, window, StructureNotifyMask, &event);
+ describeEvent(event);
+ } while (event.type != type);
+ }
+
~GlxDrawable() {
XDestroyWindow(display, window);
}
void
resize(int w, int h) {
+ if (w == width && h == height) {
+ return;
+ }
+
glXWaitGL();
// We need to ensure that pending events are processed here, and XSync
XResizeWindow(display, window, w, h);
// Tell the window manager to respect the requested size
- XSizeHints *size_hints;
- size_hints = XAllocSizeHints();
- size_hints->max_width = size_hints->min_width = w;
- size_hints->max_height = size_hints->min_height = h;
- size_hints->flags = PMinSize | PMaxSize;
- XSetWMNormalHints(display, window, size_hints);
- XFree(size_hints);
+ XSizeHints size_hints;
+ size_hints.max_width = size_hints.min_width = w;
+ size_hints.max_height = size_hints.min_height = h;
+ size_hints.flags = PMinSize | PMaxSize;
+ XSetWMNormalHints(display, window, &size_hints);
- waitForEvent(window, ConfigureNotify);
+ waitForEvent(ConfigureNotify);
glXWaitX();
}
void show(void) {
- if (!visible) {
- XMapWindow(display, window);
+ if (visible) {
+ return;
+ }
- waitForEvent(window, Expose);
+ glXWaitGL();
- Drawable::show();
- }
+ XMapWindow(display, window);
+
+ waitForEvent(MapNotify);
+
+ glXWaitX();
+
+ Drawable::show();
}
void swapBuffers(void) {
bool
processEvents(void) {
- XFlush(display);
while (XPending(display) > 0) {
XEvent event;
XNextEvent(display, &event);
void
resize(int w, int h) {
- Drawable::resize(w, h);
+ if (w == width && h == height) {
+ return;
+ }
+
RECT rClient, rWindow;
GetClientRect(hWnd, &rClient);
GetWindowRect(hWnd, &rWindow);
w += (rWindow.right - rWindow.left) - rClient.right;
h += (rWindow.bottom - rWindow.top) - rClient.bottom;
SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, w, h, SWP_NOMOVE);
+
+ Drawable::resize(w, h);
}
void show(void) {
- if (!visible) {
- ShowWindow(hWnd, SW_SHOW);
-
- Drawable::show();
+ if (visible) {
+ return;
}
+
+ ShowWindow(hWnd, SW_SHOW);
+
+ Drawable::show();
}
void swapBuffers(void) {