跳至主要内容

关于X服务器的C/S模型的一点理解

一般,在C/S模型中,客户端是发送命令和请求服务器处理,服务器响应这些请求并给客户访问服务器的权限。X的C/S模型看上去有些让人混淆。X服务器被动地显示客户机要求的显示任务(图形和窗口),X服务器永远也不会自发决定去移动一个窗口或是触发一个按钮,它的工作只是管理显示并将鼠标和键盘的输入传给客户端。客户端的程序处于控制之中,且是资源的实际消耗者。客户端请求使用被X服务器控制的窗口和图形。键盘和鼠标也属于X服务器,服务器不会将这些事件传递给客户端,除非客户端专门请求这些事件,即请求将这些事件流作为一种资料。客户端应用程序处理进来的事件并请求X服务器据此改变显示内容。
但是上述描述与Win32下编程模型是很相似的,可以作以下类比:X中的客户对应Win32下的进程,X中的服务器对应Win32下的GDI库。X服务器(GDI)不负责移动窗口等任务实际是将这些消息传给客户(进程),由客户(进程)中的消息响应代码来调用(向GDI发送命令)显示相关的操作。窗口和图形当然是由X服务器管理的(GDI),键盘和鼠标也属于X服务器(这里有些差异,Win32下好像是属于user32或是kernel32库的),服务器不会将事件传递给客户端(类似于Win32系统中默认处理函数),除非客户端专门请求这些事件(进程实现了相应消息的处理代码)。
X Window系统的一个最强有力的特征是其通过网络透明地运行应用程序的能力。服务器在自己这边管理这些资源,使客户端能轻易地生成一个远方图形环境。这应该是X系统与GDI系统的显著不同之处。还没见过GDI接受远程进程的显示操作的。

评论

此博客中的热门博文

反转剧

这两天明显感到天气转冷,呱呱的家里也已经下起了大雪,南京则是阴冷潮湿,让人没有了出行的欲望。没想到躲在被子里看反转剧也成了度过寒冬的一剂良药。在PPLive越来越让人失望的时候,PPStream横空出世,虽然广告仍是少不了的主题,但从视频质量和播放连续性上来说都超过PPLive,实为居家必备之良品(由此可见,新事物一定会战胜旧事物......)。韩国的反转剧最近似乎比较流行,称之为反转剧就在于其结果总是让人出乎意料,不合常理,其间又不乏各种搞怪搞笑的镜头,各种当红帅哥美女也一定让DDMM们爱不释手,20~30分钟一集的剧情一改韩剧拖沓的风貌,想看就看,容易切入。 反转剧,今天你看了吗?

from cpp to java

when i start to study java with a cpp background, i find it is very difficult to convert my mind. i always think how some features in cpp was implemented in java, this give me a little reject to java language. though java is born from c, i think they still have different applicable domains, so try to study both is good for me, and java is a pure OO language, i believe it will give me a better understanding on OOD.

Personalized Google Home

Using your google account, you can create a personalized homepage. You can customize several modules, including various news, gmail, bookmarks. This service is similar to what http://www.netvibes.com/ provides. The drawback is the inconvenience of bookmark module. It doesn't provide grouping while netvibes provide tags to implement this. Wishing google will improve this defect in the near future. Meanwhile, the Live plan of Microsoft is also going on. MS presents several several servicies to counterattack google's counterparts. Virtual Earth (see http://preview.local.live.com ) is a recent service. It provides map service just like google earth, provides a virtual tour better than google. Imaging driving a car in the map and seeing everything real, maybe you can do a virtual europe tour now. Seems interesting. MS also provides a customized home, you can log into www.live.com via your msn accounts. I haven't tried that yet.