I have been doing some things with FLTK on Linux lately, and now I've wondered how I can remove the title bar / undecorate the window. The target Operating System is Linux, but it would be preferrable if it runs on wayland as well as on xorg.
CodePudding user response:
There are two functions that can be used: border(int b)
and clear_border()
.
The border(int b)
function sets tells to the window manager to show or not the border: see here the documentation. This can be used during the execution.
The other useful function is clear_border()
: calling it before the Fl_Window::show()
function makes the window manager hide the border. See here the documentation.
The (simple) code below shows how to use these functions.
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
void borderHide(Fl_Widget* w, void* p){
Fl_Double_Window* win = (Fl_Double_Window*) p;
// When the input of border() is 0 it tells to the window manager to hide the border.
win->border(0);
}
void borderShow(Fl_Widget* w, void* p){
Fl_Double_Window* win = (Fl_Double_Window*) p;
// When the input of border() is nonzero it tells to the window manager to show the border.
win->border(1);
}
int main(){
Fl_Double_Window* W = new Fl_Double_Window(200, 200,"Test");
// Hide the border from the first execution.
W->clear_border();
// Button which implements the border() function for showing the border.
Fl_Button* S = new Fl_Button(80,150,100,30,"Border on");
S -> callback(borderShow,W);
// Button which implements the border() function for hiding the border.
Fl_Button* H = new Fl_Button(80,100,100,30,"Border off");
H -> callback(borderHide,W);
W->end();
W->show();
return Fl::run();
}