[xmonad] Issue 566 in xmonad: xmonad gives bogus configure events

codesite-noreply at google.com codesite-noreply at google.com
Sat May 3 19:43:29 UTC 2014


Comment #1 on issue 566 by StevensE... at gmail.com: xmonad gives bogus  
configure events
http://code.google.com/p/xmonad/issues/detail?id=566

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;
}


-- 
You received this message because this project is configured to send all  
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings


More information about the xmonad mailing list