Motif主窗口没有系统菜单,如何最小化和最大化框? (C++)

发布于 2024-08-04 06:00:52 字数 350 浏览 9 评论 0原文

如何创建没有系统菜单、最小化和最大化框的 Motif 主窗口?我只是无法通过谷歌搜索和阅读文档和教程来找到方法。我相信使用 XtVaCreateManagedWindow 的一些附加参数应该是可能的,但是哪个呢?

我尝试了 XtVaSetValues 的几种变体(topWidXmNmwmDecorations,...),但没有一个起作用。相反,我收到一条错误消息,提示我需要使用供应商 shell 来执行此操作。然而,大多数小部件类型并不是从供应商 shell 派生的,当我尝试使用对话框 shell 并将可滚动文本小部件放入其中时,文本小部件似乎控制了对话框。

How do I create a Motif main window that doesn't have a system menu, minimize and maximize boxes? I just cannot find out how by googling and reading docs and tutorials. I believe that it should be possible with some additional parameters for XtVaCreateManagedWindow, but which?

I have tried several variants of XtVaSetValues (topWid, XmNmwmDecorations, ...) but none worked. Instead I get an error message that I need to use a vendor shell for this. Most widget types aren't derived from vendor shells however, and when I e.g. try to use a dialog shell and put a scrollable text widget inside of it, then then text widget seems to control the dialog.

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

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

发布评论

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

评论(3

小女人ら 2024-08-11 06:00:52

显然,不可能(轻易)摆脱窗口(系统)菜单,但似乎可以使用如下代码禁用窗口菜单项:

int i;
XtVaGetValues (widget, XmNmwmFunctions, &i);
i &= ~(MWM_FUNC_ALL | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_CLOSE);
XtVaSetValues (widget, XmNmwmFunctions, i);

它也删除了相关的窗口装饰,显然甚至适用于非供应商外壳小部件。

Apparently it's not (easily) possible to get rid of the window (system) menu, but it seems to be possible to disable window menu items with some code like this:

int i;
XtVaGetValues (widget, XmNmwmFunctions, &i);
i &= ~(MWM_FUNC_ALL | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_CLOSE);
XtVaSetValues (widget, XmNmwmFunctions, i);

which removes the related window decoration too and apparently even works for non vendor shell widgets.

跨年 2024-08-11 06:00:52

还应该可以去除装饰(即使它们不可见)。但是,请注意这些“系统菜单”装饰属于窗口管理器,而不是您的 Motif 程序本身。由窗口管理器来处理您的请求或忽略它们——您可能会使用任何 MWM 资源获得特定于供应商的行为。

无论如何,这是要尝试的代码示例:

int decors; //bit-mask of flags defining the decorations, from Xm/MwmUtil.h
XtVaGetValues(dlg, XmNmwmDecorations, &decors, NULL);
decors &= ~MWM_DECOR_MENU;
decors &= ~MWM_DECOR_MAXIMIZE;
decors &= ~MWM_DECOR_MINIMIZE;
XtVaSetValues(dlg, XmNmwmDecorations, decors, NULL);

There should also be the possibility to remove the decorations (i.e. make them invisible). However, please note that these "system menu" decorations belong to the Window Manager, not your Motif program itself. It is up to the Window Manager to handle your requests or disregard them--you might get vendor-specific behavior with any MWM resources.

Anyway, here's the code sample to try out:

int decors; //bit-mask of flags defining the decorations, from Xm/MwmUtil.h
XtVaGetValues(dlg, XmNmwmDecorations, &decors, NULL);
decors &= ~MWM_DECOR_MENU;
decors &= ~MWM_DECOR_MAXIMIZE;
decors &= ~MWM_DECOR_MINIMIZE;
XtVaSetValues(dlg, XmNmwmDecorations, decors, NULL);
如果没有 2024-08-11 06:00:52

如果您打算从Mwm运行您的应用程序,您可以通过设置(例如通过XtVaAppInitialize())以下X11资源来实现所需的行为:

! Title bar buttons
Mwm*YourApplicationClassHere.clientDecoration: -minimize -maximize
! Window menu functions
Mwm*YourApplicationClassHere.clientFunctions: -minimize -maximize

这些资源在更多内容中进行了解释详细信息此处此处

说到窗口菜单,这取决于所使用的特定窗口管理器。例如,Mwm 允许客户端使用 Mwm*YourApplicationClassHere.windowMenu 资源设置菜单名称,菜单本身必须在 ${HOME} 中定义/.mwmrc 或全局 mwmrc,或 VendorShellXmNmwmMenu 资源。生成的自定义窗口菜单作为 _MOTIF_WM_MENU 原子公开,现代窗口管理器似乎忽略了它。

示例 mwmrc 菜单定义可能如下所示

Menu CustomMenu0
{
        Restore         _R      Alt<Key>F5      f.restore
        Move            _M      Alt<Key>F7      f.move
        Size            _S      Alt<Key>F8      f.resize
        Minimize        _n      Alt<Key>F9      f.minimize
        Maximize        _x      Alt<Key>F10     f.maximize
        Lower           _L      Alt<Key>F3      f.lower
        no-label                                f.separator
        Pass\ Keys      _K                      f.pass_keys
        no-label                                f.separator
        Close           _C      Alt<Key>F4      f.kill
}

Menu CustomMenu1
{
        Your\ Application\ Name\ Here           f.title
        no-label                                f.separator
        Close           _C      Alt<Key>F4      f.kill
}

(请参阅功能描述< /a>)。可以使用 f.send_msg 添加自定义菜单项(示例 此处此处)。

我非常确定上述所有内容也适用于 Dtwm (CDE)。

If you intend to run your application from Mwm, you can achieve the desired behavior by setting (e.g. via XtVaAppInitialize()) the following X11 resources:

! Title bar buttons
Mwm*YourApplicationClassHere.clientDecoration: -minimize -maximize
! Window menu functions
Mwm*YourApplicationClassHere.clientFunctions: -minimize -maximize

These resources are explained in more detail here and here.

Speaking of window menu, this one depends on a specific window manager in use. Mwm, for instance, allows the client to set the menu name using Mwm*YourApplicationClassHere.windowMenu resource, the menu itself must be defined in either ${HOME}/.mwmrc or global mwmrc, or XmNmwmMenu resource of VendorShell. The resulting custom window menu is exposed as a _MOTIF_WM_MENU atom, which seems to be ignored by modern window managers.

Sample mwmrc menu definitions may look like this

Menu CustomMenu0
{
        Restore         _R      Alt<Key>F5      f.restore
        Move            _M      Alt<Key>F7      f.move
        Size            _S      Alt<Key>F8      f.resize
        Minimize        _n      Alt<Key>F9      f.minimize
        Maximize        _x      Alt<Key>F10     f.maximize
        Lower           _L      Alt<Key>F3      f.lower
        no-label                                f.separator
        Pass\ Keys      _K                      f.pass_keys
        no-label                                f.separator
        Close           _C      Alt<Key>F4      f.kill
}

Menu CustomMenu1
{
        Your\ Application\ Name\ Here           f.title
        no-label                                f.separator
        Close           _C      Alt<Key>F4      f.kill
}

(see the function descriptions). Custom menu items can be added using f.send_msg (examples here and here).

I'm pretty sure all of the above also applies to Dtwm (CDE).

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