Toggling FullScreen - Xwindows

This is a discussion on Toggling FullScreen - Xwindows ; I've been tinkering around with fullscreen windows I can get a window to enter fullscreen mode no problem using XChangeProperty before it's mapped or XSendEvent after it's mapped but I cannot seem to get a window to toggle out of ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Toggling FullScreen

  1. Toggling FullScreen

    I've been tinkering around with fullscreen windows I can get a window
    to enter fullscreen mode no problem using XChangeProperty before it's
    mapped or XSendEvent after it's mapped but I cannot seem to get a
    window to toggle out of fullscreen mode back to windowed. What's
    missing from the following source:

    #include

    enum
    {
    _NET_WM_STATE_REMOVE =0,
    _NET_WM_STATE_ADD = 1,
    _NET_WM_STATE_TOGGLE =2
    };

    int main()
    {
    Display * pDisplay = XOpenDisplay(NULL);
    int screen = DefaultScreen(pDisplay);

    XSetWindowAttributes attr;
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.event_mask = ExposureMask | StructureNotifyMask;

    Window parentWindow = RootWindow(pDisplay, screen);
    Window window = XCreateWindow(pDisplay,
    parentWindow,
    0,0, //left top
    640, 480,
    0,
    0,
    InputOutput,
    CopyFromParent,
    CWBackPixel | CWBorderPixel |
    CWEventMask,
    &attr);

    XWarpPointer(pDisplay, None, window, 0, 0, 0, 0, 100, 100);
    XGrabKeyboard(pDisplay, window, True, GrabModeAsync, GrabModeAsync,
    CurrentTime);
    XMapRaised(pDisplay, window);

    XSelectInput(pDisplay, window, KeyPressMask | ButtonPressMask);
    bool fullScreen = false;
    bool run = true;
    while (run)
    {
    XEvent event;
    KeySym keySym;

    while (XPending(pDisplay) > 0)
    {
    XNextEvent(pDisplay, &event);

    switch(event.type)
    {
    case KeyPress:
    {
    fullScreen = !fullScreen;

    Atom wmState = XInternAtom(pDisplay, "_NET_WM_STATE", False);
    Atom fullScreen = XInternAtom(pDisplay,
    "_NET_WM_STATE_FULLSCREEN", False);

    XEvent xev;
    xev.xclient.type=ClientMessage;
    xev.xclient.serial = 0;
    xev.xclient.send_event=True;
    xev.xclient.window=window;
    xev.xclient.message_type=wmState;
    xev.xclient.format=32;
    xev.xclient.data.l[0] = (fullScreen ? _NET_WM_STATE_ADD :
    _NET_WM_STATE_REMOVE);
    xev.xclient.data.l[1] = fullScreen;
    xev.xclient.data.l[2] = 0;

    XSendEvent(pDisplay, DefaultRootWindow(pDisplay), False,
    SubstructureRedirectMask | SubstructureNotifyMask,
    &xev);
    break;
    }
    case ButtonPress:
    {
    run = false;
    break;
    }
    default:
    {
    break;
    }

    }
    }
    }
    XCloseDisplay(pDisplay);
    }

    thanks

    Kyle


  2. Re: Toggling FullScreen

    theycallmecoach@gmail.com writes:

    > I've been tinkering around with fullscreen windows I can get a window
    > to enter fullscreen mode no problem using XChangeProperty before it's
    > mapped or XSendEvent after it's mapped but I cannot seem to get a
    > window to toggle out of fullscreen mode back to windowed. What's
    > missing from the following source:
    >
    > bool fullScreen = false;


    [...]

    > Atom fullScreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", False);


    Reusing the variable name might have something to do with it.

    Other than that I don't see anything wrong.

    --
    Måns Rullgård
    mru@inprovide.com

  3. Re: Toggling FullScreen


    > > Atom fullScreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", False);

    >
    > Reusing the variable name might have something to do with it.
    >
    > Other than that I don't see anything wrong.
    >


    DOH!

    thanks

    Kyle


+ Reply to Thread