From 79cf72d17ff42e5bc8eb1adbd98bb42aa71fb085 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 14 Jun 2010 12:15:02 -0400 Subject: Fix the EXTENTS reported on window frames. Change the order things are done on map, so we apply startup state without any states set first, thus getting all the functions possible for the window type etc. then change the order states are applied, as some remove the ability to apply others (ie fullscreen comes last). Add an oldsize to ObFrame that remembers the size of the frame last reported to the world through the EXTENTS property. If you frame_adjust_area(FAKE) then frame_adjust_area(NONFAKE), the EXTENTS would not be updated since the oldsize wasn't remembered across fake updates. Make the extentsrequest test ask about windows with states set also. --- tests/extentsrequest.c | 136 +++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 67 deletions(-) (limited to 'tests') diff --git a/tests/extentsrequest.c b/tests/extentsrequest.c index 3fb0c7ac..055624d5 100644 --- a/tests/extentsrequest.c +++ b/tests/extentsrequest.c @@ -21,35 +21,8 @@ #include #include -int main () { - Display *display; - Window win; - XEvent report; - Atom _request, _extents, _type, _normal, _desktop; +void request (Display *display, Atom _request, Atom _extents, Window win) { XEvent msg; - int x=10,y=10,h=100,w=400; - - display = XOpenDisplay(NULL); - - if (display == NULL) { - fprintf(stderr, "couldn't connect to X server :0\n"); - return 0; - } - - _type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); - _normal = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); - _desktop = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DESKTOP", False); - _request = XInternAtom(display, "_NET_REQUEST_FRAME_EXTENTS", False); - _extents = XInternAtom(display, "_NET_FRAME_EXTENTS", False); - - win = XCreateWindow(display, RootWindow(display, 0), - x, y, w, h, 10, CopyFromParent, CopyFromParent, - CopyFromParent, 0, NULL); - XSelectInput(display, win, PropertyChangeMask); - - printf("requesting for type normal\n"); - XChangeProperty(display, win, _type, XA_ATOM, 32, - PropModeReplace, (unsigned char*)&_normal, 1); msg.xclient.type = ClientMessage; msg.xclient.message_type = _request; msg.xclient.display = display; @@ -63,9 +36,12 @@ int main () { XSendEvent(display, RootWindow(display, 0), False, SubstructureNotifyMask | SubstructureRedirectMask, &msg); XFlush(display); +} - printf("waiting for extents\n"); +void reply (Display* display, Atom _extents) { + printf(" waiting for extents\n"); while (1) { + XEvent report; XNextEvent(display, &report); if (report.type == PropertyNotify && @@ -75,57 +51,83 @@ int main () { int ret_format; unsigned long ret_items, ret_bytesleft; unsigned long *prop_return; - XGetWindowProperty(display, win, _extents, 0, 4, + XGetWindowProperty(display, report.xproperty.window, _extents, 0, 4, False, XA_CARDINAL, &ret_type, &ret_format, &ret_items, &ret_bytesleft, (unsigned char**) &prop_return); if (ret_type == XA_CARDINAL && ret_format == 32 && ret_items == 4) - printf("got new extents %d, %d, %d, %d\n", + printf(" got new extents %d, %d, %d, %d\n", prop_return[0], prop_return[1], prop_return[2], prop_return[3]); break; } } +} - printf("requesting for type desktop\n"); - XChangeProperty(display, win, _type, XA_ATOM, 32, - PropModeReplace, (unsigned char*)&_desktop, 1); - msg.xclient.type = ClientMessage; - msg.xclient.message_type = _request; - msg.xclient.display = display; - msg.xclient.window = win; - msg.xclient.format = 32; - msg.xclient.data.l[0] = 0l; - msg.xclient.data.l[1] = 0l; - msg.xclient.data.l[2] = 0l; - msg.xclient.data.l[3] = 0l; - msg.xclient.data.l[4] = 0l; - XSendEvent(display, RootWindow(display, 0), False, - SubstructureNotifyMask | SubstructureRedirectMask, &msg); - XFlush(display); +int main () { + Display *display; + Window win; + Atom _request, _extents, _type, _normal, _desktop, _state; + Atom _state_fs, _state_mh, _state_mv; + int x=10,y=10,h=100,w=400; - printf("waiting for extents\n"); - while (1) { - XNextEvent(display, &report); + display = XOpenDisplay(NULL); - if (report.type == PropertyNotify && - report.xproperty.atom == _extents) - { - Atom ret_type; - int ret_format; - unsigned long ret_items, ret_bytesleft; - unsigned long *prop_return; - XGetWindowProperty(display, win, _extents, 0, 4, - False, XA_CARDINAL, &ret_type, &ret_format, - &ret_items, &ret_bytesleft, - (unsigned char**) &prop_return); - if (ret_type == XA_CARDINAL && ret_format == 32 && ret_items == 4) - printf("got new extents %d, %d, %d, %d\n", - prop_return[0], prop_return[1], prop_return[2], - prop_return[3]); - break; - } + if (display == NULL) { + fprintf(stderr, "couldn't connect to X server :0\n"); + return 0; } + _type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + _normal = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + _desktop = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + _request = XInternAtom(display, "_NET_REQUEST_FRAME_EXTENTS", False); + _extents = XInternAtom(display, "_NET_FRAME_EXTENTS", False); + _state = XInternAtom(display, "_NET_WM_STATE", False); + _state_fs = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False); + _state_mh = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + _state_mv = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False); + + win = XCreateWindow(display, RootWindow(display, 0), + x, y, w, h, 10, CopyFromParent, CopyFromParent, + CopyFromParent, 0, NULL); + XSelectInput(display, win, PropertyChangeMask); + + printf("requesting for type normal\n"); + XChangeProperty(display, win, _type, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_normal, 1); + request(display, _request, _extents, win); + reply(display, _extents); + + printf("requesting for type normal+fullscreen\n"); + XChangeProperty(display, win, _type, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_normal, 1); + XChangeProperty(display, win, _state, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_state_fs, 1); + request(display, _request, _extents, win); + reply(display, _extents); + + printf("requesting for type normal+maxv\n"); + XChangeProperty(display, win, _type, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_normal, 1); + XChangeProperty(display, win, _state, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_state_mv, 1); + request(display, _request, _extents, win); + reply(display, _extents); + + printf("requesting for type normal+maxh\n"); + XChangeProperty(display, win, _type, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_normal, 1); + XChangeProperty(display, win, _state, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_state_mh, 1); + request(display, _request, _extents, win); + reply(display, _extents); + + printf("requesting for type desktop\n"); + XChangeProperty(display, win, _type, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&_desktop, 1); + request(display, _request, _extents, win); + reply(display, _extents); + return 1; } -- cgit v1.2.3