http://www.politiker-stopp.de/gfx/politiker-stopp-print.png

Benjamin Schieder

[SOLUTIONS] RUNNING A FLTK 1.1 APP IN ACTUAL FULLSCREEN

2010 February 16 | 2 comments

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


2 Comments

From: Tardigrade
2010-07-21 18:50:33 +0200

Thanks for this,
It's the only method that worked for me.
It will be used in a Vjiing application (Gnu/Linux only, GPL).
Is it ok if i add a link to your blog (and maybe your name, which i can't find ;) ) in the readme file ?
Florent

From: blindcoder
2010-07-22 07:53:02 +0200

Be my guest to use the code, but I can't claim authorship for it.
http://www.google.com/search?hl=en&q=%22finally+send+that+damn+thing%22
Greetings,
Benjamin

Post a comment

All comments are held for moderation; basic HTML formatting is accepted.

Name: (required)
E-mail: (required, not published)
Website: (optional)
Comment: