1
하여 시작 화면에 문자열을 그리는 어떻게 여기에 내 코드와 나는 (완료!) 그동안 기능에서 점프 할 수는 Xlib를
XFlush (d)는 디스플레이 형태로 버퍼를 표시하지 할 수사용 XCloseDisplay (D)
내가 무승부 문자열처럼 만들고 싶어하기 전에 사라지고 그
g ++ -o youname youcppname -lX11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(void)
{
Display *d;
Window w;
XEvent e;
const char *msg = "Hello, World!";
int s;
bool done = false;
/* open connection with the server */
d = XOpenDisplay(NULL);
if (d == NULL)
{
fprintf(stderr, "Cannot open display\n");
exit(1);
}
s = DefaultScreen(d);
/* create window */
w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 480, 320, 0,BlackPixel(d, s), WhitePixel(d, s));
Atom type = XInternAtom(d,"_NET_WM_WINDOW_TYPE", False);
Atom value = XInternAtom(d,"_NET_WM_WINDOW_TYPE_SPLASH", False);
XChangeProperty(d, w, type, XA_ATOM, 32, PropModeReplace, reinterpret_cast<unsigned char*>(&value), 1);
/* register interest in the delete window message */
Atom wmDeleteMessage = XInternAtom(d, "WM_DELETE_WINDOW", False);
XSetWMProtocols(d, w, &wmDeleteMessage, 1);
/* select kind of events we are interested in */
XSelectInput(d, w, ExposureMask | KeyPressMask | StructureNotifyMask);
/* map (show) the window */
XMapWindow(d, w);
/* event loop */
while (!done)
{
XNextEvent(d, &e);
/* draw or redraw the window */
if (e.type == Expose)
{
XDrawString(d, w, DefaultGC(d, s), 50, 50, msg, strlen(msg));
}
/* exit on key press */
switch(e.type)
{
case KeyPress:
XDestroyWindow(d, w);
break;
case DestroyNotify:
done = true;
break;
case ClientMessage:
if (e.xclient.data.l[0] == wmDeleteMessage)
{
done = true;
}
break;
}
}
/* close connection to server */
XCloseDisplay(d);
return 0;
}
내가 XFlush 작동하지 않았는지 정말 모르겠어요
그래서 실제로 DestroyNotify 이벤트에 등록하는 방법을 묻습니다. 텍스트 렌더링이 잘 작동하는 것을 볼 수 있습니다. –
case DestroyNotify : done = true; while()에서이 문제를 참조하십시오. http://stackoverflow.com/questions/16603525/i-wanna-make-splash-screen-and-now-i-have-two-problems?rq=1 –