C++ (Qt)#include <X11/Xlib.h> void showFullScreen( Display* dpy, Window wid ){ XWindowAttributes xwa; XGetWindowAttributes( dpy, wid, &xwa ); XEvent e; e.xclient.type = ClientMessage; e.xclient.message_type = XInternAtom( dpy, "_NET_WM_STATE", false ); e.xclient.display = dpy; e.xclient.window = wid; e.xclient.format = 32; e.xclient.data.l[0] = 1; e.xclient.data.l[1] = XInternAtom( dpy, "_NET_WM_STATE_FULLSCREEN", false ); e.xclient.data.l[2] = 0; e.xclient.data.l[3] = 0; e.xclient.data.l[4] = 0; XSendEvent( dpy, xwa.root, false, SubstructureNotifyMask | SubstructureRedirectMask, &e );}
void MyClass::ToggleFullScreen(){ //переменная isFullScreen в классе, display и window тоже есть в классе isFullScreen = !isFullScreen; if(isFullScreen) { XWindowAttributes xwa; XGetWindowAttributes(display, window, &xwa ); XEvent e; e.xclient.type = ClientMessage; e.xclient.message_type = XInternAtom( display, "_NET_WM_STATE", false ); e.xclient.display = display; e.xclient.window = window; e.xclient.format = 32; e.xclient.data.l[0] = 1; e.xclient.data.l[1] = XInternAtom( display, "_NET_WM_STATE_FULLSCREEN", false ); e.xclient.data.l[2] = 0; e.xclient.data.l[3] = 0; e.xclient.data.l[4] = 0; XSendEvent( display, xwa.root, false, SubstructureNotifyMask | SubstructureRedirectMask, &e ); XFlush(display); }}
Bashxprop -root | grep _NET_SUPPORTED | grep _NET_WM_STATE_FULLSCREEN
C++ (Qt)#include <QApplication>#include <QLabel> #include <X11/Xlib.h>#include <QX11Info> void showFullScreen( Display* dpy, Window wid ){ XWindowAttributes xwa; XGetWindowAttributes( dpy, wid, &xwa ); XEvent e = { 0 }; e.xclient.type = ClientMessage; e.xclient.message_type = XInternAtom( dpy, "_NET_WM_STATE", false ); e.xclient.display = dpy; e.xclient.window = wid; e.xclient.format = 32; e.xclient.data.l[0] = 1; e.xclient.data.l[1] = XInternAtom( dpy, "_NET_WM_STATE_FULLSCREEN", false ); XSendEvent( dpy, xwa.root, false, SubstructureNotifyMask | SubstructureRedirectMask, &e );} int main( int argc, char** argv ){ QApplication app( argc, argv ); QLabel label( "Hello!" ); label.setAlignment( Qt::AlignCenter ); label.show(); showFullScreen( QX11Info::display(), label.winId() ); return app.exec();}