Benjamin Schieder

[SOLUTIONS] RUNNING A FLTK 1.1 APP IN ACTUAL FULLSCREEN

2010 February 16

The Fl_Window class in FLTK 1.1 has a fullscreen() method, but that only resizes it to the maximum screen width and height and does not make the window manager actually run the application in fullscreen. Here's how to make it actually fullscreen.

#include
#include

extern Display *fl_display;
extern Window fl_window;
extern GC fl_gc;
extern int fl_screen;
extern XVisualInfo *fl_visual;
extern Colormap fl_colormap;

bool isfullscreen = false;

void FullscreenCallbackMenu(Fl_Widget *w, void *p) {
fl_open_display(); // make sure display connection is open
XEvent xev;

ROOTWINDOW->make_current(); // ROOTWINDOW is the window you want to make fullscreen
/* init X event structure for _NET_WM_FULLSCREEN client msg */
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.message_type = XInternAtom(fl_display, "_NET_WM_STATE", False);
xev.xclient.window = fl_window;
xev.xclient.format = 32;
xev.xclient.data.l[0] = (isfullscreen ? 0 : 1);
xev.xclient.data.l[1] = XInternAtom(fl_display, "_NET_WM_STATE_FULLSCREEN", False);
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;

isfullscreen = ! isfullscreen;
/* finally send that damn thing */
XSendEvent(fl_display, DefaultRootWindow(fl_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XSync(fl_display, False);
}


The function can be used as a callback for any Fl_Widget and is mostly taken from mplayers code for OMAP video output and adapted for FLTK variable names.


EOF

Category: blog

Tags: Solutions FLTK fullscreen