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