start x11 application in specified workspace

本文提供了一个使用X Toolkit(Xt)实现的简单示例程序,演示如何创建一个窗口并将其移动到桌面的不同区域。程序通过发送客户端消息事件来改变窗口的位置。
/**
* 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) |
给主人留下些什么吧!~~
评论热议
[gzserver-1] [Err] [RenderEngine.cc:749] Can't open display: :0 [gzserver-1] [Wrn] [RenderEngine.cc:89] Unable to create X window. Rendering will be disabled [gzserver-1] [Wrn] [RenderEngine.cc:292] Cannot initialize render engine since render path type is NONE. Ignore this warning ifrendering has been turned off on purpose. [gzserver-1] ALSA lib confmisc.c:855:(parse_card) cannot find card '0' [gzserver-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory [gzserver-1] ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings [gzserver-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory [gzserver-1] ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name [gzserver-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory [gzserver-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory [gzserver-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default [gzserver-1] AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory [gzserver-1] [Err] [OpenAL.cc:84] Unable to open audio device[default] [gzserver-1] Audio will be disabled. [gzserver-1] [Msg] Loading world file [/workspace/install/target_model_pkg/share/target_model_pkg/worlds/arena_with_targets.world] [gzserver-1] [INFO] [1757077076.907426001] [gazebo.gazebo_ros_state]: Publishing states of gazebo models at [/gazebo/model_states] [gzserver-1] [INFO] [1757077076.907921874] [gazebo.gazebo_ros_state]: Publishing states of gazebo links at [/gazebo/link_states] [spawn_entity.py-4] [INFO] [1757077076.935001843] [spawn_entity]: Calling service /spawn_entity [gzserver-1] SinModelPlugin constructed [gzserver-1] ModelPlugin loaded for model: sphere_sin [gzserver-1] ModelPlugin initialized [gzserver-1] RandomModelPlugin constructed [gzserver-1] ModelPlugin loaded for model: sphere_random [gzserver-1] ModelPlugin initialized [gzserver-1] CircleModelPlugin constructed [gzserver-1] ModelPlugin loaded for model: sphere_circle [gzserver-1] ModelPlugin initialized [gzserver-1] [Err] [CameraSensor.cc:125] Unable to create CameraSensor. Rendering is disabled. [spawn_entity.py-4] [INFO] [1757077077.098121647] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [camera_robot] [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 192] [gzclient-2] [Msg] Waiting for master. [gzclient-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [gzclient-2] [Msg] Publicized address: 172.17.0.2 [gzclient-2] [Wrn] [GuiIface.cc:298] Couldn't locate specified .ini. Creating file at "/root/.gazebo/gui.ini" [gzclient-2] [Err] [RenderEngine.cc:749] Can't open display: :0 [gzclient-2] [Wrn] [RenderEngine.cc:89] Unable to create X window. Rendering will be disabled [gzclient-2] [Wrn] [RenderEngine.cc:292] Cannot initialize render engine since render path type is NONE. Ignore this warning ifrendering has been turned off on purpose. [gzclient-2] [Wrn] [GuiIface.cc:120] could not connect to display :0 [gzclient-2] [Msg] Could not load the Qt platform plugin "xcb" in "" even though it was found. [gzclient-2] [Err] [GuiIface.cc:124] This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. [gzclient-2] [gzclient-2] Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb. [gzclient-2] [ERROR] [gzclient-2]: process has died [pid 188, exit code -6, cmd 'gzclient --gui-client-plugin=libgazebo_ros_eol_gui.so --verbose']. [gzclient-2] [gzclient-2]
最新发布
09-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值