Xlib这个(移除窗户装饰)如何工作? [英] Xlib How Does This (Removing Window Decoration) Work?

查看:91
本文介绍了Xlib这个(移除窗户装饰)如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码如何删除窗口边框?

How does the following code remove window borders?

//note the struct is declared elsewhere, is here just for clarity.
//code is from [http://tonyobryan.com/index.php?article=9][1]
typedef struct Hints
{
    unsigned long   flags;
    unsigned long   functions;
    unsigned long   decorations;
    long            inputMode;
    unsigned long   status;
} Hints;

//code to remove decoration
Hints hints;
Atom property;
hints.flags = 2;
hints.decorations = 0;
property = XInternAtom(display, "_MOTIF_WM_HINTS", true);
XChangeProperty(display,window,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
XMapWindow(display, window);

到目前为止,我已经了解到Atom是类似于Window和Display的一种标识符,但是我不知道Hints结构或"_MOTIF_WM_HINTS"来自何处.谁能为我解释所有这些代码?预先感谢,好吧.

So far I have gathered that an Atom is a sort of identifier similar to Window and Display but I can't figure out where the Hints structure or the "_MOTIF_WM_HINTS" came from. Can anyone explain all of this code for me? Thanks in advance, ell.

推荐答案

很难通过任何看起来正式"的标准来实现,但是 _MOTIF_WM_HINTS属性似乎确实来自... Motif工具包(好吧,您 猜到了:-)). 请参见 MotifZone网站.

It's hard to come by any sort of "official"-looking standard or such, but the _MOTIF_WM_HINTS property does seem to come from the... Motif toolkit (ok, you guessed that :-) ). See the MotifZone site.

警告:接下来的内容还不完整,但我希望可以有所启发.

Warning: what follows is incomplete, but should shed some light I hope.

XmNmwmDecorations,XmNmwmFunctions和XmNmwmInputMode的文档 该工具包的功能表明该属性是各种 用于控制外观,功能(调整大小,移动,...)和输入的值 窗口管理器应提供/提供给窗口的模式. 参见 man vendorshell ,或

Documentation for the XmNmwmDecorations, XmNmwmFunctions and XmNmwmInputMode functions of the toolkit indicates that that property is a bitmask of various values used to control the appearance, functions (resize, move, ...) and input mode that the window manager should provide/give to the window. See man vendorshell, or Oreilly Motif reference books, Vol6a chapter 16.

属性是整个X11事物的一部分.一个窗口可以有任意数量的 在其上定义的属性.属性有名称,但设置/获取 属性是通过原子"(种类标识符)完成的,以避免发送 每个get/set调用中的整个字符串. 参见属性和原子

Properties are a part of the whole X11 thing. A window can have any number of properties defined on it. Properties have a name, but setting/getting properties is done through an "atom" (identifier of sorts) to avoid sending the whole string on the wire for every get/set call. See Properties and Atoms

当前的窗口管理器(如果有)可以对窗口属性做出反应 通过设置适当的事件过滤器并作用于PropertyNotify来进行更改 事件,或仅检查窗口在映射(或移动)时所具有的属性.如果窗口管理器知道_MOTIF_WM_HINT属性,它将 解释这些并(希望)做您想做的. (注意:我不确定是否将该特权移交给了窗口 管理员,或者其他窗口是否可以收听那些"PropertyNotify"事件.不是 确保这实际上与您的问题有关.)

The currently window manager (if any) can react to window property changes by setting the appropriate event filter and acting on PropertyNotify events, or simply inspecting the properties the window has when it gets mapped (or moved, or whatever). If the window manager knows of the _MOTIF_WM_HINT property, it'll interpret those and (hopefully) do what you want. (Note: I'm not entierly sure if that privilege is devolved to the window manager, or if other windows can listen to those "PropertyNotify" events. Not sure that's actually relevant to your question.)

因此,只要您的窗口管理器知道,您所拥有的代码就可以正常工作 关于_MOTIF_WM_HINTS属性.

So the code you have works just fine as long as your window manager knows about the _MOTIF_WM_HINTS property.

从获得原子开始 (标识符/快捷方式)使用XInternAtom,并通过XChangeProperty()设置其值 在通过MapWindow()实际绘制窗口之前(不确定是否会 如果您在MapWindow()之后执行此操作,则可能取决于您的窗口 经理).

You start by getting the atom (identifier/shortcut) for it with XInternAtom, and setting its value via XChangeProperty() before the window is actually drawn via MapWindow() (not sure if that would work if you do it after the MapWindow(), that could depend on your window manager).

我无法在某个正式"的地方提出该结构的定义.它在openmotif-2.3.3发行版的lib/X11/MwmUtils.h中定义.不确定如何使用.flags条目(找不到我一生的代码:-/),但我怀疑它用于指示您使用的{decoration,function,inputMode}"sub-properties"中的哪个作用于. (不要相信我.)

I can't come up with somewhere "official" with the definition of that struct. It's defined in lib/X11/MwmUtils.h of the openmotif-2.3.3 distribution. Not sure how the .flags entry is used (can't find the code for the life of me :-/ ) but I suspect it's used to indicate which of the {decoration, function, inputMode} "sub-properties" you're acting on. (Don't take my word for that.)

作为旁注,使用_MOTIF_WM_HINTS可能不是您的最佳选择 现在.您是否看过扩展的窗口管理器提示 规范和其他信息/标准/草稿在freedesktop上?我敢打赌,大多数现代"窗口管理器/桌面环境/厨房水槽将倾向于遵守该规范,而不是保持与Motif的向后兼容性.一切取决于我猜您要编码的内容.

As a side note, using _MOTIF_WM_HINTS might not be your best option right now. Have you looked at the Extended Window Manager hints specification and other information/standards/drafts over at freedesktop? I'll wager most "modern" window managers/desktop environments/kitchen sinks will tend to adhere to that rather than keeping backwards compatibility with Motif. All depends on what you're coding for I guess.

感谢您的阅读:-)

这篇关于Xlib这个(移除窗户装饰)如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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