简体   繁体   English

如何在 Linux 上删除 FLTK 中的标题栏/取消装饰窗口?

[英]How can I remove the title bar / undecorate the window in FLTK on Linux?

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.我最近一直在 Linux 上使用 FLTK 做一些事情,现在我想知道如何删除标题栏/取消装饰窗口。 The target Operating System is Linux, but it would be preferrable if it runs on wayland as well as on xorg.目标操作系统是 Linux,但如果它在 wayland 和 xorg 上运行会更好。

There are two functions that can be used: border(int b) and clear_border() .可以使用两个函数: border(int b)clear_border()

The border(int b) function tells to the window manager to show or not the border: see here the documentation. border(int b)函数告诉窗口管理器是否显示边框:请参阅此处的文档。 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.另一个有用的函数是clear_border() :在Fl_Window::show()函数之前调用它会使窗口管理器隐藏边框。 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();

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM