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

codesite-noreply at google.com codesite-noreply at google.com
Sat May 3 05:11:34 UTC 2014


Status: New
Owner: ----

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

What steps will reproduce the problem?
1. Compile the program below.
2. Run it.
3. Move the mouse pointer between windows.

What is the expected output? What do you see instead?

I don't expect to see configure events being generated and I certainly  
don't expect bogus broken ones to be generated.

What version of the product are you using? On what operating system?
xmonad 0.10, Linux

Are you using an xmonad.hs?  Please attach it and the output of "xmonad
--recompile".

import XMonad

import qualified XMonad.StackSet as W

import XMonad.Layout.MouseResizableTile
import XMonad.Layout.WindowNavigation
import XMonad.Layout.LayoutHints
import XMonad.Layout.Fullscreen

import XMonad.Hooks.Minimize
import XMonad.Layout.Minimize
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.FadeInactive

import XMonad.Util.EZConfig
import XMonad.Util.Run

import XMonad.Prompt
import XMonad.Prompt.RunOrRaise
import XMonad.Prompt.Shell

import XMonad.Config.Kde


main = do
   spawn "xmodmap -e 'keycode 135 = Super_R'"
   xmonad myConfig

baseConfig = kde4Config

myConfig = baseConfig
  { modMask = mod4Mask
  , borderWidth = 0
  , workspaces = fmap show [1 .. 4]
  , handleEventHook = myEventHook (handleEventHook baseConfig)
  , layoutHook = myLayout
  , manageHook = myManageHook (manageHook baseConfig)
  , logHook = myLogHook (logHook baseConfig)
  } `additionalKeysP`
  [ ("M-a", windows W.focusUp)
  , ("M-e", windows W.focusDown)

  , ("M-C-a", windows W.swapUp)
  , ("M-C-e", windows W.swapDown)

  , ("M-k", sendMessage ShrinkSlave)
  , ("M-j", sendMessage ExpandSlave)

  , ("M-p", shellPrompt $ defaultXPConfig {
            position = Top,
            height = 20
        })

  , ("M-<Return>", spawn "exec emacs")
  , ("M-S-<Return>", spawn "exec abrowser")
  ]

myEventHook baseHook =
   minimizeEventHook
   <+> hintsEventHook
   <+> baseHook
   <+> fullscreenEventHook

myManageHook baseHook = composeAll [
   baseHook
   , className =? "Do" --> doFloat
   , className =? "plasma-desktop" --> doFloat
   , className =? "Plasma-desktop" --> doFloat
   , className =? "klipper" --> doFloat
   , className =? "Klipper" --> doFloat
   , fullscreenManageHook]

myLayout =
   ( fullscreenFull
   . windowNavigation
   . avoidStrutsOn []
   . layoutHintsToCenter
   . minimize
   ) myBasicLayout

myBasicLayout = tileLayout ||| tileLayout { isMirrored = True } ||| Full  
where
   tileLayout = mouseResizableTile {
     draggerType = FixedDragger {
                 gapWidth = 5
                 , draggerWidth = 6
        }
     }

myLogHook baseLogHook = do
   baseLogHook
   fadeInactiveLogHook 0xee000000


Please provide any additional information below.

The C program:

#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 <xcb/xcb.h>
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
#include <unistd.h>

static int errnum_from_connection(xcb_connection_t * connection)
{
     switch (xcb_connection_has_error(connection)) {
     case 0:
         return 0;

     case XCB_CONN_ERROR:
         return EPROTO;

     case XCB_CONN_CLOSED_EXT_NOTSUPPORTED:
         return ENOSYS;

     case XCB_CONN_CLOSED_MEM_INSUFFICIENT:
         return ENOMEM;

     case XCB_CONN_CLOSED_REQ_LEN_EXCEED:
         return EINVAL;

     case XCB_CONN_CLOSED_PARSE_ERR:
         return EINVAL;

     default:
         assert(false);
     }
}

int main(int argc, char *argv[])
{
     int error_status = 0;

     Display * display = XOpenDisplay(NULL);
     if (NULL == display) {
         perror("XOpenDisplay");
     }

     xcb_connection_t * connection = XGetXCBConnection(display);
     unsigned screen_number = XDefaultScreen(display);

     xcb_screen_t * screen = NULL;
     {
         xcb_screen_iterator_t iter =  
xcb_setup_roots_iterator(xcb_get_setup(connection));
         for (size_t ii = 0; ii < screen_number; ++ii) {
             if (0 == iter.rem) {
                 break;
             }

             xcb_screen_next (&iter);
         }

         if (0 == iter.rem) {
             error_status = EINVAL;
             goto disconnect;
         }

         screen = iter.data;
     }

     /* Query framebuffer configurations */
     GLXFBConfig fb_config;
     {
         static int const attrib_list[] = {
             GLX_BUFFER_SIZE, 0,       /* color index buffer size */
             GLX_LEVEL, 0    ,         /* buffer-level */
             GLX_DOUBLEBUFFER, True,   /* double buffer */

             GLX_STEREO, False,
             GLX_AUX_BUFFERS, 0,

             GLX_RED_SIZE, GLX_DONT_CARE,
             GLX_GREEN_SIZE, GLX_DONT_CARE,
             GLX_BLUE_SIZE, GLX_DONT_CARE,
             GLX_ALPHA_SIZE, GLX_DONT_CARE,

             GLX_DEPTH_SIZE, 16,

             GLX_STENCIL_SIZE, 0,
             GLX_ACCUM_RED_SIZE, 0,
             GLX_ACCUM_GREEN_SIZE, 0,
             GLX_ACCUM_BLUE_SIZE, 0,
             GLX_ACCUM_ALPHA_SIZE, 0,
             GLX_RENDER_TYPE, GLX_RGBA_BIT,

             GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,

             GLX_X_RENDERABLE, True,

             GLX_X_VISUAL_TYPE, GLX_DONT_CARE,

             GLX_CONFIG_CAVEAT, GLX_DONT_CARE,

             GLX_TRANSPARENT_TYPE, GLX_NONE,

             GLX_TRANSPARENT_INDEX_VALUE, GLX_DONT_CARE,
             GLX_TRANSPARENT_RED_VALUE, GLX_DONT_CARE,
             GLX_TRANSPARENT_GREEN_VALUE, GLX_DONT_CARE,
             GLX_TRANSPARENT_BLUE_VALUE, GLX_DONT_CARE,
             GLX_TRANSPARENT_ALPHA_VALUE, GLX_DONT_CARE,
             None
         };

         int configs_count;
         GLXFBConfig *configs = glXChooseFBConfig(display, screen_number,
                                                  attrib_list,
                                                  &configs_count);
         if (NULL == configs) {
             error_status = ENOSYS;
             goto disconnect;
         }
         fb_config = configs[0];
         XFree(configs);
     }

     int visual_id;
     switch (glXGetFBConfigAttrib(display, fb_config, GLX_VISUAL_ID,  
&visual_id)) {
     case GLX_NO_EXTENSION:
     case GLX_BAD_ATTRIBUTE:
         error_status = ENOSYS;
         goto disconnect;

     default:
         break;
     }

     GLXContext glx_context = glXCreateNewContext(display, fb_config,  
GLX_RGBA_TYPE, 0, true);
     if (NULL == glx_context) {
         error_status = ENOSYS;
         goto disconnect;
     }

     xcb_colormap_t colormap = xcb_generate_id(connection);
     if ((error_status = errnum_from_connection(connection)) != 0) {
         goto destroy_glx_context;
     }

     xcb_create_colormap(connection, XCB_COLORMAP_ALLOC_NONE,
                         colormap,
                         screen->root,
                         visual_id);
     if ((error_status = errnum_from_connection(connection)) != 0) {
         goto destroy_glx_context;
     }

     xcb_window_t window = xcb_generate_id(connection);
     if ((error_status = errnum_from_connection(connection)) != 0) {
         goto destroy_glx_context;
     }

     {
         uint32_t values[] = {XCB_EVENT_MASK_STRUCTURE_NOTIFY, colormap, 0};
         xcb_create_window(connection,
                           XCB_COPY_FROM_PARENT,
                           window,
                           screen->root,
                           0, 0,
                           540, 480,
                           0,
                           XCB_WINDOW_CLASS_INPUT_OUTPUT,
                           visual_id,
                           XCB_CW_EVENT_MASK | XCB_CW_COLORMAP, values);
     }
     if ((error_status = errnum_from_connection(connection)) != 0) {
         goto disconnect;
     }

     xcb_map_window(connection, window);
     if ((error_status = errnum_from_connection(connection)) != 0) {
         goto destroy_window;
     }

     xcb_flush(connection);
     if ((error_status = errnum_from_connection(connection)) != 0) {
         goto destroy_window;
     }

     GLXWindow glxwindow = glXCreateWindow(display,
                                           fb_config,
                                           window,
                                           0);
     if (!window) {
         error_status = ENOSYS;
         goto destroy_window;
     }

     xcb_atom_t wm_delete_window;
     {
         xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 1, 12,
                                                           "WM_PROTOCOLS");
         if ((error_status = errnum_from_connection(connection)) != 0) {
             goto destroy_glx_window;
         }

         xcb_generic_error_t *error = NULL;
         xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(connection,  
cookie, &error);
         if ((error_status = errnum_from_connection(connection)) != 0) {
             goto destroy_glx_window;
         }
         if (error != NULL) {
             free(error);
             error_status = ENOSYS;
             goto destroy_glx_window;
         }

         xcb_atom_t wm_protocols = reply->atom;
         free(reply);

         xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(connection, 0,  
16,
                                                            "WM_DELETE_WINDOW");
         if ((error_status = errnum_from_connection(connection)) != 0) {
             goto destroy_glx_window;
         }

         xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(connection,  
cookie2, &error);
         if ((error_status = errnum_from_connection(connection)) != 0) {
             goto destroy_glx_window;
         }
         if (error != NULL) {
             free(error);
             error_status = ENOSYS;
             goto destroy_glx_window;
         }

         wm_delete_window = reply2->atom;
         free(reply2);

         xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window,  
wm_protocols, 4, 32, 1,
                             &wm_delete_window);
         if ((error_status = errnum_from_connection(connection)) != 0) {
             goto destroy_glx_window;
         }
     }

     if (!glXMakeContextCurrent(display,
                                glxwindow,
                                glxwindow,
                                glx_context)) {
         error_status = ENOSYS;
         goto destroy_glx_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 = (void*)&event;

                 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, glxwindow);
                 break;
             }

         case ClientMessage:;
             goto cleanup_gl;

         default:
             /* Unknown event type, ignore it */
             break;
         }
     }

  cleanup_gl:

  destroy_glx_window:
     glXDestroyWindow(display, glxwindow);

  destroy_window:
     xcb_destroy_window(connection, window);
     {
         int errnum = errnum_from_connection(connection);
         if (0 == error_status) {
             error_status = errnum;
         }
     }

  destroy_glx_context:
     glXMakeContextCurrent(display, None, None, NULL);
     glXDestroyContext(display, glx_context);

  disconnect:
     xcb_flush(connection);
     {
         int errnum = errnum_from_connection(connection);
         if (0 == error_status) {
             error_status = errnum;
         }
     }

     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