Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

The Event Mask

Each GdkWindow has an associated event mask which determines which events on that window the X server will forward to your application. You specify the event mask when a GdkWindow is created, as part of the GdkWindowAttr struct (the section called GdkWindow Attributes). You can access and change the event mask later using gdk_window_set_events() and gdk_window_get_events(). If the GdkWindow in question belongs to a widget, you should not change the event mask directly; rather, call gtk_widget_set_events() or gtk_widget_add_events(). gtk_widget_set_events() should be used after a widget is realized; gtk_widget_add_events() can be used to add events to the existing mask at any time. Figure 5 and Figure 6 show these functions.

#include <gdk/gdk.h>

GdkEventMask gdk_window_get_events(GdkWindow* window);

void gdk_window_set_events(GdkWindow* window, GdkEventMask event_mask);

Figure 5. GdkWindow Event Mask

#include <gtk/gtkwidget.h>

gint gdk_widget_get_events(GtkWidget* widget);

void gtk_widget_add_events(GtkWidget* widget, gint event_mask);

void gtk_widget_set_events(GtkWidget* widget, gint event_mask);

Figure 6. Widget Event Mask

Table 3 shows which event masks request which events. Some events do not have to be selected to be received; in particular:

  • Map, unmap, destroy, and configure events are selected with GDK_STRUCTURE_MASK, but GDK automatically selects them on any new window. (Xlib programmers beware; Xlib does not do this.)

  • Selection, client, drag-and-drop, and delete events have no masks, because they are automatically selected (Xlib selects them for all windows).

Table 3. Event Masks

Mask Event Type
GDK_EXPOSURE_MASK GDK_EXPOSE
GDK_POINTER_MOTION_MASK GDK_MOTION_NOTIFY
GDK_POINTER_MOTION_HINT_MASK N/A (see the section called Mouse Movement Events)
GDK_BUTTON_MOTION_MASK GDK_MOTION_NOTIFY (while a button is pressed)
GDK_BUTTON1_MOTION_MASK GDK_MOTION_NOTIFY (while button 1 is pressed)
GDK_BUTTON2_MOTION_MASK GDK_MOTION_NOTIFY (while button 2 is pressed)
GDK_BUTTON3_MOTION_MASK GDK_MOTION_NOTIFY (while button 3 is pressed)
GDK_BUTTON_PRESS_MASK GDK_BUTTON_PRESS, GDK_2BUTTON_PRESS, GDK_3BUTTON_PRESS
GDK_BUTTON_RELEASE_MASK GDK_BUTTON_RELEASE
GDK_KEY_PRESS_MASK GDK_KEY_PRESS
GDK_KEY_RELEASE_MASK GDK_KEY_RELEASE
GDK_ENTER_NOTIFY_MASK GDK_ENTER_NOTIFY
GDK_LEAVE_NOTIFY_MASK GDK_LEAVE_NOTIFY
GDK_FOCUS_CHANGE_MASK GDK_FOCUS_IN, GDK_FOCUS_OUT
GDK_STRUCTURE_MASK GDK_CONFIGURE, GDK_DESTROY, GDK_MAP, GDK_UNMAP
GDK_PROPERTY_CHANGE_MASK GDK_PROPERTY_NOTIFY
GDK_VISIBILITY_NOTIFY_MASK GDK_VISIBILITY_NOTIFY
GDK_PROXIMITY_IN_MASK GDK_PROXIMITY_IN
GDK_PROXIMITY_OUT_MASK GDK_PROXIMITY_OUT
GDK_SUBSTRUCTURE_MASK Receive GDK_STRUCTURE_MASK events for child windows
GDK_ALL_EVENTS_MASK All events
Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire