如何在 FLTK 中编写面板任务栏以在 Linux 系统上使用

发布于 2024-11-10 03:25:19 字数 610 浏览 2 评论 0原文

我需要用 C/C++ 编写一个小应用程序来实现类似面板任务栏的东西,以在桌面窗口(特别是 Linux 系统上的 xorg 桌面)顶部显示信息。我需要避免 GUI 编程的臃肿和陡峭的学习曲线。

我的研究将我指向 GTK+/GTKmm 或 FLTK。看起来 FLTK 可能更容易掌握,并且最有可能提供具有最小依赖性的小型干净包。所以到目前为止我的研究都是基于 FLTK 的。

我一直在阅读一些内容,并且正在努力找出如何编写一个基本程序,该程序将创建一个狭窄的未装饰窗口,该窗口覆盖显示器的宽度,从而最大化其他应用程序不会遮挡它。到目前为止,我发现的 FLTK 教程(包括 FLTK 文档)仅实现了带有可在屏幕上移动边框的标准窗口。

我想首先在 FLTK(或 GTK+/GTKmm)中编写一个简单的程序,该程序在屏幕上创建一个 20 像素深的条,其中包含“hello world”消息。该栏的区域将保留在其他程序可以访问的区域之外,以便最大化另一个应用程序不会隐藏“hello world”消息。我认为这与 WM_STRUT_PARTIAL 属性有关,但我在 FLTK 中找不到有关此信息。

这样做部分是为了了解如何编写简单的 GUI 程序,部分是为了解决我的特定需求。

我正在寻找任何帮助/指导来让我朝着正确的方向开始。非常感谢。

I need to write a small application in C/C++ to implement a panel task bar like thing to display information along the top of a desktop window (specifically an xorg desktop on a Linux system). I need to avoid bloat and steep learning curves for the GUI programming.

My research is pointing me at GTK+/GTKmm or FLTK. It looks like FLTK is probably the simpler to get to grips with and the most likely to provide a small clean package with minimal dependencies. So I've based my research on FLTK so far.

I've been doing some reading and am struggling to find out how to write a basic program that will create a narrow undecorated window that covers the width of a monitor in such a way that maximising other applications would not obscure it. The FLTK tutorials I have found so far (including the FLTK documentation) only implement standard windows with borders that can be moved around the screen.

I'd like to start by writing a simple program in FLTK (or GTK+/GTKmm) that creates a 20 pixel deep bar across the with of the screen containing a "hello world" message. The bar's area would be reserved outside the area that other programs can access so that maximising another application would not hide the "hello world" message. I think this has something to do with a WM_STRUT_PARTIAL property but I can't find information about this in FLTK.

Doing this is partially to understand how to write a simple GUI program and partially to solve a specific need that I have.

I'm looking for any help/guidance to put me in the right direction to get started. Many thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

电影里的梦 2024-11-17 03:25:19

starfry,我相信这不是一项微不足道的任务。问题是您的桌面(例如 GNOME2/Metacity)保留了该空间,并将其面板绘制在您想要放置栏的区域。 -

如果您确实希望托盘栏小程序基于 FLTK,则必须“嵌入”它在 (GNOME) 小程序中。很久以前我用SDL应用程序做过类似的事情,但我恐怕忘记了怎么做。我想到的第一件事是使用某种方式从 GNOME 小程序获取 XID,并以某种方式将其传递给 FLTK 部分,然后让 FLTK 完成剩下的工作...

当然,您可以使用另一个桌面,例如 < a href="http://www.kde.org" rel="nofollow">KDE 或 i3 或 IceWM,它们都有自己的处理托盘栏的方法(没有标准! )所以,请原谅我的“法语”——它将成为一个支持所有环境的 PITA...

如果我在 GNOME< /a>,我会完全使用 GNOME/GTK 编写小程序。在这种情况下,请忘记 FLTK。这是我的建议。如果您的目标是 KDE,那么使用 KDE/QT 库来实现(Plasma 小部件将是您需要寻找的)。

但是,如果您仍然想使用 FLTK,请从 fltk::draw_into 开始() 函数(在 FLTK 1.x 中可能称为 fl_draw_into())、fltk::xid() 及相关函数。

starfry, it is not a trivial task I believe. The problem is that your desktop (say GNOME2/Metacity) reserved that space, and paints its panel in the area where you want your bar. -

If you really want your tray-bar applet to be based on FLTK, the you would have to "embed" it in a (GNOME) applet. It was long ago when I did similar thing with SDL application, but I am afraid I forgot how to do it. The first thing that comes to my mind is to use somehow get the XID from the GNOME applet and somehow pass it to the FLTK part of it, and then let FLTK do the rest...

Sure, you may use another desktop, like KDE, or i3 or IceWM, they ALL have their own ways of dealing with the tray bar (there is no standard for it!) so, pardon my "French" - it is going to be a PITA to support all environments...

If I was on GNOME, i would write the applet entirely using GNOME/GTK. Forget FLTK in that case. That is my recommendation. If you target KDE, then do it using KDE/QT libraries (Plasma widget would be what to look for).

However, if you still want to use FLTK, start with the fltk::draw_into() function (it is probably called fl_draw_into() in FLTK 1.x), fltk::xid() and related functions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文