fbpx
维基百科

Xlib

Xlib是一種X Window System協定的用戶端,以C語言撰寫。其功能是與X server溝通。這樣的功能可以讓程式人員撰寫程式時,毋須了解其協定的細節。但甚少應用程式會直接使用Xlib;通常是透過其他的函式庫來呼叫Xlib用以提供部件工具箱(widget toolkits):

Xlib
開發者X.Org基金会
首次发布大约1985年
当前版本
  • 1.8.8 (2024年3月24日;穩定版本)[1]
源代码库
  • gitlab.freedesktop.org/xorg/lib/libx11.git
编程语言C
类型
许可协议
网站www.x.org, 文档: www.x.org/releases/current/doc/libX11/libX11/libX11.html
Xlib及其應用

Xlib發表於1985年,目前使用在許多的Unix-like作業系統上。

目前XCB有可能取代Xlib.

資料型別 编辑

Xlib主要的資料型別是Display[2]結構。

範例 编辑

下面是一個XLib的範列,產生一個視窗。

/*  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> int main(void) {  Display *d;  Window w;  XEvent e;  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, 640, 480, 0,  BlackPixel(d, s), WhitePixel(d, s));  /* 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) {  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){    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; } 

注釋 编辑

  1. ^ "[ANNOUNCE libX11 1.8.8"]; 作者姓名字符串: Alan Coopersmith; 检索日期: 2024年3月25日.
  2. ^ . Tip search for: typedef struct _XDisplay Display. [2009-07-09]. (原始内容存档于2008-01-31). 

外部連結 编辑

xlib, 是一種x, window, system協定的用戶端, 以c語言撰寫, 其功能是與x, server溝通, 這樣的功能可以讓程式人員撰寫程式時, 毋須了解其協定的細節, 但甚少應用程式會直接使用, 通常是透過其他的函式庫來呼叫用以提供部件工具箱, widget, toolkits, 開發者x, org基金会首次发布大约1985年当前版本1, 2024年3月24日, 穩定版本, 源代码库gitlab, freedesktop, xorg, libx11, git编程语言c类型库许可协议expat许可证x1. Xlib是一種X Window System協定的用戶端 以C語言撰寫 其功能是與X server溝通 這樣的功能可以讓程式人員撰寫程式時 毋須了解其協定的細節 但甚少應用程式會直接使用Xlib 通常是透過其他的函式庫來呼叫Xlib用以提供部件工具箱 widget toolkits Xlib開發者X Org基金会首次发布大约1985年当前版本1 8 8 2024年3月24日 穩定版本 1 源代码库gitlab wbr freedesktop wbr org wbr xorg wbr lib wbr libx11 wbr git编程语言C类型库许可协议Expat许可证X11許可證历史许可通知和免责声明网站www wbr x wbr org 文档 www wbr x wbr org wbr releases wbr current wbr doc wbr libX11 wbr libX11 wbr libX11 wbr html Xlib及其應用Intrinsics Xt Xaw Xaw Motif GTK Qt X11 version TkXlib發表於1985年 目前使用在許多的Unix like作業系統上 目前XCB有可能取代Xlib 目录 1 資料型別 2 範例 3 注釋 4 外部連結資料型別 编辑Xlib主要的資料型別是Display 2 結構 範例 编辑下面是一個XLib的範列 產生一個視窗 Simple Xlib application drawing a box in a window gcc input c o output lX11 include lt X11 Xlib h gt include lt stdio h gt include lt stdlib h gt include lt string h gt include lt stdbool h gt int main void Display d Window w XEvent e 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 640 480 0 BlackPixel d s WhitePixel d s register interest in the delete window message Atom wmDeleteMessage XInternAtom d WM DELETE WINDOW False XSetWMProtocols d w amp 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 amp 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 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 注釋 编辑 ANNOUNCE libX11 1 8 8 作者姓名字符串 Alan Coopersmith 检索日期 2024年3月25日 Display Structure on freedesktop CVS Tip search for typedef struct XDisplay Display 2009 07 09 原始内容存档于2008 01 31 外部連結 编辑Xlib Programming Manual Manual pages for all Xlib functions 页面存档备份 存于互联网档案馆 Kenton Lee s pages on X Window and Motif 页面存档备份 存于互联网档案馆 A short tutorial on Xlib 页面存档备份 存于互联网档案馆 A longer tutorial on Xlib Using Xlib for creating a screensaver module 页面存档备份 存于互联网档案馆 Simple X11 toolkit for learning Xlib 取自 https zh wikipedia org w index php title Xlib amp oldid 71705748, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。