什么是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。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用Go语言编写GUI应用程序时,有很多可用的GUI框架可以选择,每个都有其独特的优势和应用场景。下面是几个流行的GUI工具及库: ### 1. **GTK+ 和 GTK/GTK3** GTK+ 是一套跨平台的图形用户界面(GUI)工具包,支持多种操作系统包括Linux、Windows和macOS。GTK+ 提供了丰富的组件集,如按钮、标签、文本框等,并且支持创建复杂的应用程序布局。对于希望在多平台上构建一致性的GUI应用的开发者来说,GTK+ 是一个很好的选择。 #### 使用方式: - 在 Linux 系统上,通常会安装 GTK+ 开发环境作为依赖。 - 在 macOS 上,你可以通过 Homebrew 安装 gtk+。 - Windows 用户则可以从官方网站下载预编译的库和工具链。 ### 2. **Fenix GUI Framework** Fenix 是一个基于 GTK+ 的Go语言GUI框架。它提供了一套简洁的API,使得开发者可以快速构建现代化的UI。相比GTK+原生API,Fenix简化了一些复杂度,使得入门更为容易。 #### 使用方式: - Fenix 需要在项目中作为一个外部依赖引入。 - 使用类似于Python的面向对象的方式构建窗口、控件等。 ### 3. **GfxGo** GfxGo 是另一个基于GTK+的Go语言GUI库,旨在提供一种易于使用的界面构建体验。它强调的是效率和性能,适合那些追求高交互性和响应速度的开发者。 #### 使用方式: - 类似于Fenix,GfxGo 也需要添加到项目依赖中。 - 构建界面和逻辑时,GfxGo 提供了一系列便捷的API。 ### 4. **Electron Go** 如果想要开发跨平台的桌面应用并且利用已有的Web前端技能,Electron Go 可能是一个不错的选择。Electron 是由Node.js团队维护的一个开源项目,允许开发者使用HTML、CSS和JavaScript来构建桌面应用。 #### 使用方式: - 需要额外学习Electron框架和Webpack等构建工具。 - 对于不熟悉前端技术的开发者来说,可能需要花费更多的时间和精力来适应。 ### 相关问题: 1. **GTK+ 和 Fenix 的主要区别是什么?** - GTK+ 更基础,提供更多自定义选项和低级API,适用于需要高度定制化界面的应用。 - Fenix 则封装了许多GTK+的基本功能,提供更高的抽象级别,使其更易上手,适合快速原型开发。 2. **在选择GUI库时应该考虑哪些因素?** - 应用需求(性能、安全性、用户界面复杂性) - 学习曲线(库的文档质量、社区活跃程度) - 社区支持和生态系统 - 与其他库和框架的兼容性 3. **如何集成Electron Go与现有的Web应用?** - 通过将Web应用打包成渲染进程,利用Node.js API与本地Go应用交互。 - 使用Electron框架的特性,如加载本地文件、访问系统API等。 - 需要注意跨域问题,确保安全设置允许Web应用与本地Go应用之间的通信。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值