GNOME窗口管理器
来源:互联网 发布:知乎dota2与lol 编辑:程序博客网 时间:2024/06/05 13:49
1.窗口管理器常用数据结构:
Glib库里面的双向链表,用来管理窗口和控件等数据,定义如下:
struct GList{gpointer data; GList *next; GList *prev;};转载网上的一段示例代码(http://keyewan.blog.163.com/blog/static/189827233201110844628516/):
/* * file: g_list.c * desc: 这个文件用于演示glib库里双向链表GList的用法 * compile: gcc -o g_list g_list.c `pkg-config --cflags --libs glib-2.0` */#include <glib.h>void display_list(GList *list){ GList *it = NULL; /* 遍历链表 */ for (it = list; it; it = it->next) { printf("%s", it->data); } printf("/n");}int main(int argc, char *argv[]){ GList *list = NULL; /* * 向链表尾部追加节点 */ list = g_list_append(list, "one "); list = g_list_append(list, "two "); list = g_list_append(list, "three "); list = g_list_append(list, "four "); list = g_list_append(list, "five "); display_list(list); /* 在链表头部插入*/ list = g_list_prepend(list, "zero "); display_list(list); GList *it = NULL; /* 查找链表中的节点 */ it = g_list_find(list, "two "); printf("Find data "two ": %s/n", it->data); int index = 0; /* 确定链表指针指向链表中的第几个节点 */ index = g_list_position(list, it); printf("index of "two " is: %d/n", index); it = g_list_nth(list, 1); printf("%s/n", it->data); /* 从链表里删除一个节点 */ printf("After remove data "three ", the list:/n"); list = g_list_remove(list, "three "); display_list(list); /* 向链表里插入一个节点 */ printf("After insert string "INSERT " at index 3, the list:/n"); list = g_list_insert(list, "INSERT ", 3); display_list(list); /* 采用内循环遍历链表节点 */ g_list_foreach(list, (GFunc)printf, NULL); printf("/n"); GList *last = NULL; /* 取链表的最后一个节点 */ last = g_list_last(list); /* 从最后一个节点开始遍历链表 */ for (it = last; it; it = it->prev) { printf("%s", it->data); } printf("/n"); /* 销毁链表 */ g_list_free(list); return 0;}在linux下使用下面的命令编译:
gcc -o g_list g_list.c `pkg-config --cflags --libs glib-2.0`
编译后程序运行的结果如下:
$ ./g_list
one two three four five
zero one two three four five
Find data "two ": two
index of "two " is: 2
one
After remove data "three ", the list:
zero one two four five
After insert string "INSERT " at index 3, the list:
zero one two INSERT four five
zero one two INSERT four five
five four INSERT two one zero
现在你应该知道我为什么在每个字符串后面加一个空格了吧。
总结:在glib库中,双向链表的用法跟单向链表基本上是一致的,只是多了一个访问上一个节点的指针prev。对于你的应用如果单向链表够用,就没有必要使用双向链表,因为这里要增加维护一个指针的开销。
---------------------------------------------------------------------------------------------------------------------------------
2.窗口管理器对“窗口”的数据结构定义:
struct _MetaWindow{ MetaDisplay *display; /*关于窗口的显示,隐藏,选中操作,有点复杂,待续*/ MetaScreen *screen; MetaWorkspace *workspace; Window xwindow;
- GNOME窗口管理器
- linux Gnome .KDE.xfce4窗口管理器切换
- Metacity -- Gnome的默认窗口管理器
- X11 、XFree86 、KDE、GNOME、窗口管理器等相关概念
- 第三篇:什么是窗口管理器、GNOME、KDE、XDM、KDM、GDM
- linux lightdm gdm gnome kde等的区别于联系(桌面环境 窗口管理器 显示管理器)
- 窗口管理器
- 窗口管理器
- vncviewer 启动gnome窗口
- GNOME显示管理器 (GNOME Display Manager,GDM)简介
- 改变Gnome默认的文件管理器
- 关闭Gnome窗口缩放动画
- X窗口管理器大全
- 初识FVWM-窗口管理器
- 安装FLUXBOX窗口管理器
- 窗口管理器的要求
- Ubuntu设置窗口管理器
- directfb 窗口管理器调试
- 虚指针
- Mono for Android (1) 之布局
- DirectX 3D_实践之DirectX3D中粒子系统的使用
- uva 10056 - What is the Probability ?
- 计算机科学中最重要的32个算法
- GNOME窗口管理器
- uva 10375 - Choose and divide
- 如何解决终端服务器超出了最大允许连接数
- 正则表达式
- python中参数的传递的list形式和dict的区分
- Blink, 通向哈里·波特的魔法世界
- 数据结构_图_prim最小生成树算法
- [C++STDlib基础]关于字符串的操作——C++标准库头文件<cstring>
- hdu 2108 Shape of HDU(判断多边形是否为凸多边形)