Thread: enlarging a window produces clipping

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    127

    enlarging a window produces clipping

    Hello,
    I am studying X, and confused some problems. If I enlarge the window, the drawing is clipped to the size of the window before enlarging. there is a test program

    Code:
    #include <X11/Xlib.h>
    #include <iostream>
    
    int main()
    {
    	// Open the display
    	Display *dpy = XOpenDisplay(NIL);
    	Window desktop = DefaultRootWindow(dpy);
    
    	// Get some colors
    	int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
    
    
    	// Create the window
    	hwnd_t wnd = XCreateSimpleWindow(dpy, desktop,
    
    										10, 10, 300, 200, 0,0,
    
    										whiteColor);
    
    
    
    	XSelectInput(dpy, wnd, StructureNotifyMask | ButtonPressMask | ExposureMask| ResizeRedirectMask); //POINT A
    
          XMapWindow(dpy, wnd);
    
          XFlush(dpy);
    
    	XEvent event;
    	while(true)
    	{
    		XNextEvent(dpy, &event);
    		switch(event.type)
    		{
    		case ButtonPress:
    			std::cout<<"button clicked"<<std::endl;
    		}
    	}
    }
    the code shows when a mouse clicked on the window, it prints "button clicked" in terminal. but after enlarging the window, the event just effects the original rectangle before enlarging, if a mouse clicked on the new rectangle, "button clicked" is not printed in terminal.

    at the comment POINT A, if i modify the line to
    XSelectInput(dpy, wnd, StructureNotifyMask | ButtonPressMask | ExposureMask);
    the window is allright. please show me a solution on the problem.

    thanks in advance
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > switch(event.type)
    You need to respond to resize events as well (I guess).
    Been over a decade since I last rummaged in low-level X11
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    Sorry, I don't know what your meaning is...
    essentially, i think iit is ResizeRedirectMask
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
    		case default:
    			std::cout<<"An ignored event"<<std::endl;
    Get many of these?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    >>Get many of these?

    yes. if i resize the window
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  4. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM