什么是Linux的原生GUI API?

Linux并非提供单一的原生GUI API,而是有X11作为传统选择,Wayland作为新兴的窗口系统。X11是Linux发行版常用的窗口系统,而GTK+、Qt等工具包库建立在Xlib之上,提供更易用的编程接口。Wayland基于OpenGL/ES API,有望成为未来的“原生GUI API”。Ubuntu则在开发Mir系统,同样基于OpenGL/ES API。
摘要由CSDN通过智能技术生成

本文翻译自:What is Linux’s native GUI API?

I hope this doesn't come across as a stupid question but it's always something I have wondered. 我希望这不是一个愚蠢的问题,但它总是我想知道的。 Both Windows (Win32 API) and OS X (Cocoa) have their own APIs to handle windows, events and other OS stuff. Windows(Win32 API)和OS X(Cocoa)都有自己的API来处理窗口,事件和其他操作系统。 I have never really got a clear answer as to what Linux's equivalent is. 对于Linux的等价物,我从来没有真正得到明确的答案。

I have heard some people say GTK+, but GTK+ being cross platform, how can it be native? 我听说有人说GTK +,但是GTK +是跨平台的,它怎么可能是原生的呢?


#1楼

参考:https://stackoom.com/question/rMJ8/什么是Linux的原生GUI-API


#2楼

Linux is a kernel, not a full operating system. Linux是内核,而不是完整的操作系统。 There are different windowing systems and gui's that run on top of Linux to provide windowing. 有不同的窗口系统和gui在Linux上运行以提供窗口。 Typically X11 is the windowing system used by Linux distros. 通常, X11是Linux发行版使用的窗口系统。


#3楼

XWindows可能是最接近可称为“原生”的:)


#4楼

I suppose the question is more like "What is linux's native GUI API". 我想这个问题更像是“什么是linux的原生GUI API”。

In most cases X (aka X11) will be used for that: http://en.wikipedia.org/wiki/X_Window_System . 在大多数情况下,X(也称为X11)将用于此: http//en.wikipedia.org/wiki/X_Window_System

You can find the API documentation here 您可以在此处找到API文档


#5楼

Strictly speaking, the API of Linux consists of its system calls . 严格来说,Linux的API包含其系统调用 These are all of the kernel functions that can be called by a user-mode (non-kernel) program. 这些是可以由用户模式(非内核)程序调用的所有内核函数。 This is a very low-level interface that allows programs to do things like open and read files. 这是一个非常低级的接口,允许程序执行打开和读取文件等操作。 See http://en.wikipedia.org/wiki/System_call for a general introduction. 有关一般介绍,请参见http://en.wikipedia.org/wiki/System_call

A real Linux system will also have an entire "stack" of other software running on it, in order to provide a graphical user interface and other features. 真正的Linux系统还将在其上运行其他软件的整个“堆栈”,以便提供图形用户界面和其他功能。 Each element of this stack will offer its own API. 该堆栈的每个元素都将提供自己的API。


#6楼

In Linux the graphical user interface is not a part of the operating system. 在Linux中,图形用户界面不是操作系统的一部分。 The graphical user interface found on most Linux desktops is provided by software called the X Window System , which defines a device independent way of dealing with screens, keyboards and pointer devices. 大多数Linux桌面上的图形用户界面由称为X Window System的软件提供,该软件定义了一种独立于设备的方式来处理屏幕,键盘和指针设备。

X Window defines a network protocol for communication, and any program that knows how to "speak" this protocol can use it. X Window定义了用于通信的网络协议,任何知道如何“说”该协议的程序都可以使用它。 There is a C library called Xlib that makes it easier to use this protocol, so Xlib is kind of the native GUI API. 有一个叫C库的Xlib ,使得它更容易使用这个协议,所以×程序库是一种生GUI API的。 Xlib is not the only way to access an X Window server; Xlib不是访问X Window服务器的唯一方法; there is also XCB . 还有XCB

Toolkit libraries such as GTK+ (used by GNOME ) and Qt (used by KDE ), built on top of Xlib, are used because they are easier to program with. 使用基于Xlib构建的GTK + (由GNOME使用 )和Qt (由KDE使用)等工具包库,因为它们更易于编程。 For example they give you a consistent look and feel across applications, make it easier to use drag-and-drop, provide components standard to a modern desktop environment, and so on. 例如,它们为您提供跨应用程序的一致外观,使其更易于使用拖放,为现代桌面环境提供标准组件,等等。

How X draws on the screen internally depends on the implementation. X在内部如何在屏幕上绘制取决于实现。 X.org has a device independent part and a device dependent part. X.org具有设备无关部分和设备相关部分。 The former manages screen resources such as windows, while the latter communicates with the graphics card driver, usually a kernel module. 前者管理屏幕资源,例如windows,而后者则与显卡驱动程序通信,通常是内核模块。 The communication may happen over direct memory access or through system calls to the kernel. 通信可以通过直接内存访问或通过对内核的系统调用来进行。 The driver translates the commands into a form that the hardware on the card understands. 驱动程序将命令转换为卡上的硬件可以理解的形式。

As of 2013, a new window system called Wayland is starting to become usable, and many distributions have said they will at some point migrate to it, though there is still no clear schedule. 截至2013年,一个名为Wayland的新窗口系统开始变得可用,并且许多发行版表示他们将在某些时候迁移到它,尽管仍然没有明确的时间表。 This system is based on OpenGL/ES API, which means that in the future OpenGL will be the "native GUI API" in Linux. 该系统基于OpenGL / ES API,这意味着未来OpenGL将成为Linux中的“本机GUI API”。 Work is being done to port GTK+ and QT to Wayland, so that current popular applications and desktop systems would need minimal changes. 正在努力将GTK +和QT移植到Wayland,因此当前流行的应用程序和桌面系统只需要很少的更改。 The applications that cannot be ported will be supported through an X11 server, much like OS X supports X11 apps through Xquartz. 无法移植的应用程序将通过X11服务器得到支持,就像OS X通过Xquartz支持X11应用程序一样。 The GTK+ port is expected to be finished within a year , while Qt 5 already has complete Wayland support. GTK +端口预计将在一年内完成 ,而Qt 5已经完成了Wayland的支持。

To further complicate matters, Ubuntu has announced they are developing a new system called Mir because of problems they perceive with Wayland. 为了使问题更加复杂,Ubuntu宣布他们正在开发一个名为Mir的新系统,因为他们认为Wayland存在问题。 This window system is also based on the OpenGL/ES API. 该窗口系统也基于OpenGL / ES API。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值