Khiêu chuyển đáo nội dung

Xlib

本页使用了标题或全文手工转换
Duy cơ bách khoa, tự do đích bách khoa toàn thư
Xlib
Khai phát giảX.Org cơ kim hội
Thủ thứ phát bốĐại ước 1985 niên
Đương tiền bản bổn
  • 1.8.9(2024 niên 4 nguyệt 5 nhật; ổn định bản bổn )[1]
編輯維基數據鏈接
Nguyên đại mã khố編輯維基數據鏈接
Biên trình ngữ ngônC
Loại hìnhKhố
Hứa khả hiệp nghị
編輯維基數據鏈接
Võng trạmwww.x.org,Văn đương:www.x.org/releases/current/doc/libX11/libX11/libX11.html

XlibThị nhất chủngX Window SystemHiệp định đích dụng hộ đoan, dĩC ngữ ngônSoạn tả. Kỳ công năng thị dữ X server câu thông. Giá dạng đích công năng khả dĩ nhượng trình thức nhân viên soạn tả trình thức thời, vô tu liễu giải kỳ hiệp định đích tế tiết. Đãn thậm thiếu ứng dụng trình thức hội trực tiếp sử dụng Xlib; thông thường thị thấu quá kỳ tha đích hàm thức khố lai hô khiếu Xlib dụng dĩ đề cungBộ kiện công cụ tương( widget toolkits ):

Xlib cập kỳ ứng dụng

Xlib phát biểu ô 1985 niên, mục tiền sử dụng tại hứa đa đíchUnix-like tác nghiệp hệ thống thượng.

Mục tiềnXCBHữu khả năng thủ đại Xlib.

Tư liêu hình biệt

[Biên tập]

Xlib chủ yếu đích tư liêu hình biệt thịDisplay[2]Kết cấu.

Phạm lệ

[Biên tập]

Hạ diện thị nhất cá XLib đích phạm liệt, sản sinh nhất cá thị song.

/*
Simple Xlib application drawing a box in a window.
gcc input.c -o output -lX11
*/

#include<X11/Xlib.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>

intmain(void)
{
Display*d;
Windoww;
XEvente;
char*msg="Hello, World!";
ints;

booldone=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,640,480,0,
BlackPixel(d,s),WhitePixel(d,s));

/* register interest in the delete window message */
AtomwmDeleteMessage=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){
XFillRectangle(d,w,DefaultGC(d,s),20,20,10,10);
XDrawString(d,w,DefaultGC(d,s),50,50,msg,strlen(msg));
}

/* exit on key press */
switch(e.type){

caseKeyPress:
XDestroyWindow(d,w);
break;

caseDestroyNotify:
done=true;
break;

caseClientMessage:
if(e.xclient.data.l[0]==wmDeleteMessage){
done=true;
}
break;
}
}

/* close connection to server */
XCloseDisplay(d);

return0;
}

Chú thích

[Biên tập]
  1. ^https://lists.x.org/archives/xorg-announce/2024-April/003501.html;Kiểm tác nhật kỳ: 2024 niên 4 nguyệt 7 nhật; tác giả tính danh tự phù xuyến: Alan Coopersmith.
  2. ^Display Structure on freedesktop CVS.Tip search for: typedef struct _XDisplay Display.[2009-07-09].(Nguyên thủy nội dungTồn đương vu 2008-01-31 ).

Ngoại bộ liên kết

[Biên tập]