Open GoogleCodeExporter opened 8 years ago
I should mention that the windows need to be console windows (the kind that
have to be multiples of the console character size) to trigger the configure
events.
Also, here is a much simpler version of the code.
#include <assert.h>
#include <errno.h>
#include <poll.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int error_status = 0;
Display * display = XOpenDisplay(NULL);
if (NULL == display) {
perror("XOpenDisplay");
}
unsigned screen_number = XDefaultScreen(display);
/* Query framebuffer configurations */
XVisualInfo visual_info;
{
static int const attrib_list[] = {
GLX_RGBA, True,
GLX_RED_SIZE, 5,
GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 3,
GLX_DOUBLEBUFFER, True,
GLX_DEPTH_SIZE, 16,
None
};
XVisualInfo *ptr = glXChooseVisual(display, screen_number,
(int*)attrib_list);
if (NULL == ptr) {
error_status = ENOSYS;
goto disconnect;
}
visual_info = *ptr;
XFree(ptr);
}
Colormap cmap = XCreateColormap(display, DefaultRootWindow(display),
visual_info.visual, AllocNone);
XSetWindowAttributes attributes;
memset(&attributes, 0, sizeof attributes);
attributes.colormap = cmap;
attributes.event_mask = StructureNotifyMask;
Window window = XCreateWindow(display,
RootWindow(display, visual_info.screen),
0, 0,
600, 600,
0,
visual_info.depth,
InputOutput, visual_info.visual,
CWColormap | CWEventMask, &attributes);
XMapWindow(display, window);
GLXContext glx_context = glXCreateContext(display, &visual_info, NULL, GL_TRUE);
if (NULL == glx_context) {
error_status = ENOSYS;
goto destroy_window;
}
if (!glXMakeContextCurrent(display,
window,
window,
glx_context)) {
error_status = ENOSYS;
goto destroy_window;
}
for (;;) {
/* Handle GUI events first before rendering */
/* We have to use the Xlib event queue because of broken Mesa
* libraries which abuse it.
*/
XEvent event;
XNextEvent(display, &event);
switch (event.type) {
{
case ConfigureNotify:;
XConfigureEvent* configure_event = &event.xconfigure;
fprintf(stderr,
"Configure:\n"
"serial: %lu\n"
"send_event: %u\n"
"display: %p\n"
"x: %i y: %i\n"
"width: %i height: %i!\n"
"border_width: %u\n",
configure_event->serial,
configure_event->send_event,
configure_event->display,
configure_event->x, configure_event->y,
configure_event->width, configure_event->height,
configure_event->border_width);
glViewport(0, 0, configure_event->width, configure_event->height);
glClear(GL_COLOR_BUFFER_BIT);
glXSwapBuffers(display, window);
break;
}
case ClientMessage:;
goto destroy_glx_context;
default:
/* Unknown event type, ignore it */
break;
}
}
destroy_glx_context:
glXMakeContextCurrent(display, None, None, NULL);
glXDestroyContext(display, glx_context);
destroy_window:
XDestroyWindow(display, window);
disconnect:
XCloseDisplay(display);
shutdown:
return error_status;
}
Original comment by StevensE...@gmail.com
on 3 May 2014 at 7:43
Does this happen with the default configuration? If not, could you spend a
little bit of time to try to minimize your config for us?
For others reading: compiling the given C program requires -lX11 -lGL in the
compile line.
Original comment by daniel.w...@gmail.com
on 4 May 2014 at 9:57
(I do not see configure events happening in my config, even when testing with a
terminal and a gvim open, which both specify resize increments in their window
manager hints.)
Original comment by daniel.w...@gmail.com
on 4 May 2014 at 9:58
I'm not having a good weekend so have not been looking closely at this, but the
first comment points to (and my initial suspicion was) the layout hints module,
and probably hintsEventHook in particular. (Also my personal observation is
that that module seems to cause more problems than it fixes....)
Original comment by allber...@gmail.com
on 4 May 2014 at 10:02
Yep layoutHints seems to be causing the problem. Thank you, very much.
Original comment by StevensE...@gmail.com
on 8 May 2014 at 9:30
Original issue reported on code.google.com by
StevensE...@gmail.com
on 3 May 2014 at 5:11