gtk中Gource注册过程和将xevent加入本地队列后处理
来源:互联网 发布:小米手机抹除数据 编辑:程序博客网 时间:2024/05/14 10:33
1、注册eventhandler
gtk_init (int *argc, char ***argv)
gtk_init_check
gtk_parse_args
gtk_get_option_group
g_option_group_set_parse_hooks(group,pre_parse_hook,post_parse_hook)
pre_parse_hook
do_pre_parse_initialization
gdk_event_handler_set((GdkEventFunc)gtk_main_do_event,NULL,NULL);
- **/
- void
- gdk_event_handler_set (GdkEventFunc func,
- gpointer data,
- GDestroyNotify notify)
- {
- if (_gdk_event_notify)
- (*_gdk_event_notify) (_gdk_event_data);
- _gdk_event_func = func;
- _gdk_event_data = data;
- _gdk_event_notify = notify;
- }
2、注册gdk_event对应的GSource
gdk_init_check() and post_parse_hook(),and gtk_init_check(),
gdk_display_open_default_libgtk_only
gdk_display_open
gdk_events_init (display);
g_source_attach(source, NULL);
- _gdk_events_init (GdkDisplay *display)
- {
- GSource *source;
- GdkDisplaySource *display_source;
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
- int connection_number = ConnectionNumber (display_x11->xdisplay);
- GDK_NOTE (MISC, g_message ("connection number: %d", connection_number));
- source = display_x11->event_source = gdk_display_source_new (display);
- display_source = (GdkDisplaySource*) source;
- g_source_set_priority (source, GDK_PRIORITY_EVENTS);
- display_source->event_poll_fd.fd = connection_number;
- display_source->event_poll_fd.events = G_IO_IN;
- g_source_add_poll (source, &display_source->event_poll_fd);
- g_source_set_can_recurse (source, TRUE);
- g_source_attach (source, NULL);
- display_sources = g_list_prepend (display_sources,display_source);
- gdk_display_add_client_message_filter (display,
- gdk_atom_intern_static_string ("WM_PROTOCOLS"),
- gdk_wm_protocols_filter,
- NULL);
- }
3. dispatch函数
注册了gdk_event需要的GSource后,这个Source的dispatch函数会:
- _gdk_events_queue(display): 将XEvent transplate为GdkEvent, 同时加入本进程的display队列中
- 取得这个队列中的第一个event(if any)
- 调用事先注册好的gdk_event_func, 也就是函数gtk_main_do_event()
- static gboolean
- gdk_event_dispatch (GSource *source,
- GSourceFunc callback,
- gpointer user_data)
- {
- GdkDisplay *display = ((GdkDisplaySource*)source)->display;
- GdkEvent *event;
- GDK_THREADS_ENTER ();
- _gdk_events_queue (display);
- event = _gdk_event_unqueue (display);
- if (event)
- {
- if (_gdk_event_func)
- (*_gdk_event_func) (event, _gdk_event_data);
- gdk_event_free (event);
- }
- GDK_THREADS_LEAVE ();
- return TRUE;
- }
- gtk中Gource注册过程和将xevent加入本地队列后处理
- 关于本地缓存登陆 和 域用户将计算机加入域的问题及登录过程- -
- 添加域后如何将域用户加入本地管理员组
- spring 容器中注册BeanPostProccessor来实现JavaBean的预处理和后处理
- 在ScrollView中加入listview后的处理
- 机房收费系统中——存储过程中加入事务,实现学生注册
- 机房收费系统中——存储过程中加入事务,实现学生注册
- 将登录用户加入本地管理员组!
- Maven 将本地jar加入maven仓库
- 将本地jar包加入maven管理
- 将jar包加入本地Maven库
- DECLARE_WAITQUEUE 将进程加入等待队列
- DECLARE_WAITQUEUE 将进程加入等待队列
- 如何将自已的java jar 包加入到自已本地的maven仓库中
- Swift一句话总结-将变量和常量加入字符串中
- 将php和mysql加入到环境变量中
- FBReader打开txt优化方案,加入本地格式好后得数据写入和读取
- android 系统启动过程中加入tcpdump和logcat
- ComponentOne Studio for WinForms 2008 v2
- 关于《奋斗》,“你偷了我的心”
- ComponentOne Studio for ASP.NET 2008 v2
- Automatic Workload Repository Compare Period report
- ComponentOne Studio for WPF 2008 v2
- gtk中Gource注册过程和将xevent加入本地队列后处理
- ComponentOne Studio for Silverlight 2008 v2
- 堆栈、队列与自动排序集合简单测试事例
- Delphi中资源文件的创建与使用
- ComponentOne Studio for Mobile 2008 v2
- ComponentOne Studio for ActiveX 2008 v2
- 概要设计怎么写
- ComponentOne Studio for IntelliSpell 2008 v2
- ComponentOne Doc-To-Help 2009