有没有命令来安装谢维(用于 X11 编程)来自存储库?
(以便Xevie.h
可以进行编程)
我需要它来在 Qt Creator 中编译此示例:
/* xeviedemo.c */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/X.h>
#include <X11/extensions/Xevie.h>
#include <X11/Xutil.h>
static void
print_key_event (XEvent *ev)
{
XKeyEvent *key_ev;
char buffer[20];
int bufsize = 19;
KeySym key;
XComposeStatus compose;
int char_count;
key_ev = (XKeyEvent *)ev;
printf (" State: %x KeyCode: %x\n", key_ev->state & ShiftMask, key_ev->keycode);
char_count = XLookupString(key_ev, buffer, bufsize, &key, &compose);
buffer[char_count] = '\0';
printf (" Char Count: %d KeySym: %x char: |%c|\n", char_count, key, buffer[0]);
}
int
main(int argc, char **argv)
{
Display *dpy;
int major, minor;
XEvent event;
XClientMessageEvent *xcme;
int count = 0;
long delay = 0;
int ret;
if (argc > 2)
{
printf ("Usage: xeviedemo delay (in milliseconds)\n");
exit(1);
}
else if (argc == 2)
{
delay = strtol(argv[1], 0, 0);
}
printf("Delay is %d milliseconds\n", delay);
delay *= 1000;
dpy = XOpenDisplay(NULL);
XevieQueryVersion(dpy, &major, &minor);
printf("major = %d, minor = %d\n", major, minor);
if(XevieStart(dpy))
printf("XevieStart(dpy) finished \n");
else
{
printf("XevieStart(dpy) failed, only one client is allowed to do event interception\n");
exit(1);
}
XevieSelectInput(dpy, KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
while(1)
{
XNextEvent(dpy, &event);
xcme = (XClientMessageEvent *)&event;
/* for readOnly users, send events back to Xserver immediately */
printf("(%4d)", count++);
switch(event.type)
{
case KeyPress:
usleep(delay);
printf(" KeyPress\n");
print_key_event (&event);
break;
case KeyRelease:
printf(" KeyRelease\n");
break;
case ButtonPress:
usleep(delay);
printf(" ButtonPress\n");
break;
case ButtonRelease:
printf(" ButtonRelease\n");
break;
case MotionNotify:
printf(" MotionNotify\n");
break;
case ClientMessage:
printf("ClientMessage: <%s>\n", &xcme->data.b[1]);
break;
default:
printf(" unknown event %x\n", event.type);
break;
}
XevieSendEvent(dpy, &event, XEVIE_UNMODIFIED);
if(count > 10000)
{
break;
}
}
XevieEnd(dpy);
printf("XevieEnd(dpy) finished \n");
exit(0);
}
答案1
我认为没有任何软件包提供Xevie.h
。有另一个库称为,xevie.h
由提供,libxcb-xevie0-dev
但这不是您所需要的。
然而我发现这一页它包含看起来像源包的内容。我尝试下载libXevie-1.0.3.tbz
,可以确认它包含一个名为的文件Xevie.h
,其中包含您评论中的函数。事实上,文件太小了,我在这里重现了整个内容:
/************************************************************
Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
************************************************************/
#ifndef _XEVIE_H_
#define _XEVIE_H_
#include <X11/Xfuncproto.h>
#define XEVIE_UNMODIFIED 0
#define XEVIE_MODIFIED 1
#ifndef _XEVIE_SERVER_
_XFUNCPROTOBEGIN
Bool XevieQueryVersion(
Display* /* dpy */,
int* /* major_version */,
int* /* minor_version */
);
extern Status XevieStart(
Display* /* dpy */
);
Status XevieEnd(
Display* /* dpy */
);
Status XevieSendEvent(
Display* /* dpy */,
XEvent* /* event */,
int /* data type */
);
Status XevieSelectInput(
Display* /* dpy */,
long
);
_XFUNCPROTOEND
#endif /* _XEVIE_SERVER_ */
#endif /* _XEVIE_H_ */
当查找特定文件时,您可以在以下位置搜索http://packages.ubuntu.com或使用apt-file
:
$ apt-file search xevie.h
libxcb-xevie0-dev: /usr/include/xcb/xevie.h
如您所见,使用apt-file search filename
将返回提供该文件的包(如果有)。如果apt-file
没有安装,则需要在运行它之前安装它并生成其包列表:
sudo apt-get install apt-file
sudo apt-file update
答案2
2009 年,Xorg 在 X11R7.5 中取消了对 Xevie 的支持自从它已经坏了一段时间了,没有人需要它或有兴趣修理它。即使您找到了构建客户端的库和头文件,它们也无法与任何最新的 Xorg 服务器一起工作。