start x11 application in specified workspace

本文提供了一个使用X Toolkit(Xt)实现的简单示例程序,演示如何创建一个窗口并将其移动到桌面的不同区域。程序通过发送客户端消息事件来改变窗口的位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/**
* cc -o memo memo.c -lXm -lXt -lX11 -I/usr/X11R6/include/
-L/usr/X11R6/lib/
*/


#include <Xm/Xm.h>
#include <X11/X.h>
#include <Xm/Label.h>
#include <X11/Xatom.h>
#include <stdlib.h>
#include <stdio.h>

void main(int argc, char **argv)
{
Widget shell, msg;
XtAppContext app;
XmString xmstr;
XClientMessageEvent xev;
Display *display;

shell = XtAppInitialize(&app, "Memo", NULL, 0, &argc, argv, NULL,
NULL, 0);

xmstr = XmStringCreateLtoR("move window test",
XmFONTLIST_DEFAULT_TAG);

msg = 
XtVaCreateManagedWidget(
"message", xmLabelWidgetClass, shell, XmNlabelString, xmstr,
NULL);

XmStringFree(xmstr);

XtRealizeWidget(shell);


/* Now move the window to a different area */
display = XtDisplay(shell);


xev.type = ClientMessage;
xev.window = XtWindow(shell);
xev.message_type = XInternAtom(display, "_NET_WM_DESKTOP", False); 
xev.format = 32;

/* Force into desktop 2 */
xev.data.l[0] = 2;


XSendEvent(
display,
RootWindowOfScreen(XtScreen(shell)), 
False, 
SubstructureNotifyMask|SubstructureRedirectMask, 
(XEvent *) &xev);


XtAppMainLoop(app);
}
阅读(93) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值