没有标题栏的简单窗口 [英] simple window without titlebar

查看:612
本文介绍了没有标题栏的简单窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家下午好!我一直在从事一个需要没有标题栏的基本窗口的项目.在网络上浏览了一段时间后,我遇到了这篇文章创建没有标题栏的窗口,其中包含一个答复中提到了"_NET_WM_WINDOW_TYPE_DOCK"原子的使用.我尝试使用以下代码在我的项目中创建一个:

Good afternoon everyone! I have been working on a project that requires a basic window without a titlebar. After browsing a bit on the web I came across this post create window without titlebar with a reply mentioning the use of the "_NET_WM_WINDOW_TYPE_DOCK" atom. I attempted to create one in my project using the following code:

Display* d = fl_display;
XWindow w = XCreateSimpleWindow(d, RootWindow(d, fl_screen),
    0, 0,
    400, 100,
    0,
    0x000000, 0x000000);

Atom window_type = XInternAtom(d, "_NET_WM_WINDOW_TYPE", False);
long value = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);
XChangeProperty(d, w, window_type, XA_ATOM, 32, PropModeReplace, (uchar*) &value, 1);

窗口确实显示,但是它仍然具有标题栏.我在网络上发现了其他一些资源,但是我无法停止显示标题栏.我确实意识到引用的帖子正在使用XCreateWindow,但是原子也不应该在XCreateSimpleWindow上工作.任何帮助将不胜感激!

The window does show, but it still has a titlebar. I have found several other resources around the web, but I can't get this to stop showing the titlebar. I do realize that the referenced post is using XCreateWindow, but shouldn't atoms work on XCreateSimpleWindow too. Any help would be appreciated!

谢谢

推荐答案

我已经对您的示例进行了扩展,以便能够对其进行测试,并且它对我有用-查看您的代码是否存在任何有意义的区别. /p>

I have extended your example a bit to be able to test it out, and it works for me - see if there are any meaningful differences to your code.

#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>

int main(int argc, char **argv) {
  Display* d = XOpenDisplay(NULL);
  int s = DefaultScreen(d);
  Window w = XCreateSimpleWindow(d, RootWindow(d, s), 100, 100, 400, 100, 1,
                                 BlackPixel(d, s), WhitePixel(d, s));
  Atom window_type = XInternAtom(d, "_NET_WM_WINDOW_TYPE", False);
  long value = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);
  XEvent e;
  XChangeProperty(d, w, window_type, XA_ATOM, 32, PropModeReplace, (unsigned char *) &value, 1);
  XMapWindow(d, w);
  while (1) {
    XNextEvent(d, &e);
    if (e.type == Expose) {
      XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
    }
    if (e.type == KeyPress)
      break;
  }
  XCloseDisplay(d);
  return 0;
}

这篇关于没有标题栏的简单窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆