XCB window context and manipulation

How the client windows are interacting with their environment, such as the full screen and the other windows?

Interacting with the window manage

The client program needs to interact with the window manager. The window manager is responsible to

  1. decorating drawn widnows, i.e. adding a frame, an iconify button, a system menu, a title bar, etc.
  2. handling icons shown when windows are being iconified.
  3. ordering of windows on the screen.
  4. other administrative tasks.

The client window programs need to tell the window manager about various hints, so the window manager know how to treat the client windows.

1. Window properties

Note: the difference between "Attributes" and "Properties". Many of the parameters in the properties are passed to the window manager. The property and its type are Id with the structure "xcb_atom_t". The function "xcb_change_property" changes the property of a window.

2. Setting the window name and icon name

The window name may be used by the window manager as the title of the window (in the title bar), in a task list, etc. The function "xcb_change_property" can change the window name. The parameter "property"  is XCB_ATOM_WM_NAME, and the parameter "type" XCB_ATOM_STRING.

Note that the client program needs to be compiled and linked against xcb_atom.

Simple window operations

In order to manipulate window on the screen, some window operations functions are supplied by XCB.

1. Mapping and un-mapping a window

This gives the effect of making a window hidden(unmapped) and shown again(mapped).

  • xcb_map_window mapping a window causes the window to appear on the screen, and an Expose event to be sent to the client program unless the window is completely covered by other windows.
  • xcb_unmap_window causes a window to be removed from the screen although the window as a logical entity still exists.

2. Configuring a window

If a window is already created and some attributes (that is, the position, the size, the events, etc) for the window need to be modified, the function "xcb_configure_window" can change them by parameters of valuemask and  valuelist.

3. Moving a window around the screen

The function "xcb_configure_window" can move a window to a different location with valuemask of XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y.

After being moved, the window might get partially exposed or partially hidden by other windows, and thus the client might get Expose events.

4. Resizing a window

The function "xcb_configure_window" can change the size of a window with valuemask of XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT.

The move and resize operations are combined with valuemask of XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT.

5. Changing windows stacking order: raise and lower

Stacking order is one of properties that relate to the window and other windows. The front-most window is said to be on the top of the stack, while the back-most window is at the bottom of the stack.

The function "xcb_configure_window" can change stacking order of a window with valuemask of XCB_CONFIG_WINDOW_STACK_MODE.

6. Getting information about a window

Just like we can set various attributes of a window, we can also ask the X server supply the current values of these attributes by the structure "xcb_get_geometry_reply_t".

The function "xcb_get_geometry" sends a request for the structure "xcb_get_geometry_reply_t" to the X server. 

The function "xcb_get_geometry_reply" gets a reply from the X server, that is, finally gets the structure "xcb_get_geometry_reply_t".

To get the Id of the parent window, the structure "xcb_query_tree_reply_t". The function "xcb_query_tree" sends a request for the structure and the function "xcb_query_tree_reply" finally get it.

To get relative coordinates between a window and its parent, the structure "xcb_translate_coordinates_reply_t " and the two functions "xcb_translate_coordinates"/"xcb_translate_coordinates_reply" need to be used.

Another information about a window can be fetched by the structure "xcb_get_window_attributes_reply_t", and the two funcitons "xcb_get_window_attributes"/"xcb_get_window_attributes_reply"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值