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

Events

Events are sent to your application to indicate changes in a GdkWindow or user actions you might be interested in. All events are associated with a GdkWindow. They also come to be associated with a GtkWidget; the GTK+ main loop passes events from GDK to the GTK+ widget tree.

Types of Event

There are many kinds of events; the GdkEvent union can represent any of them. A special event type, GdkEventAny, contains the three fields common to all events; any event can be cast to GdkEventAny. The first field in GdkEventAny is a type marker, GdkEventType; GdkEventType is also included in the GdkEvent union. Confused yet? Seeing the code should help. Here is GdkEventAny:


struct _GdkEventAny
{
  GdkEventType type;
  GdkWindow *window;
  gint8 send_event;
};

and GdkEvent:


union _GdkEvent
{
  GdkEventType              type;
  GdkEventAny               any;
  GdkEventExpose            expose;
  GdkEventNoExpose          no_expose;
  GdkEventVisibility        visibility;
  GdkEventMotion            motion;
  GdkEventButton            button;
  GdkEventKey               key;
  GdkEventCrossing          crossing;
  GdkEventFocus             focus_change;
  GdkEventConfigure         configure;
  GdkEventProperty          property;
  GdkEventSelection         selection;
  GdkEventProximity         proximity;
  GdkEventClient            client;
  GdkEventDND               dnd;
};

Every event type has the three members of GdkEventAny as its first three members. Thus, the type of an event can be referred to in many ways (assume a GdkEvent* called event):

  • event->type

  • event->any.type

  • event->button.type

  • ((GdkEventAny*)event)->type

  • ((GdkEventButton*)event)->type

You'll probably see all these in GTK+ source code. Of course, each event subtype has its own unique members; the type field tells you which subtype is valid.

The window field of GdkEventAny is the GdkWindow the event was sent to. If the send_event flag is TRUE, then the event was synthesized by another (or your own) application; if FALSE, it originated with the X server. GDK does not export the X interface for sending events (XSendEvent()). However, GTK+ often "makes up" an event by declaring a static event struct, filling it in, then emitting the event's corresponding widget signal. These synthesized events will have send_event set to TRUE. the section called Receiving GDK Events in GTK+ explains how GTK+ associates events with widget signals.

There are more possible values for GdkEventType than there are members in the GdkEvent union. Many event types share the same data; for example, GDK_BUTTON_PRESS and GDK_BUTTON_RELEASE both use the button member of GdkEvent, since the same information is conveyed when mouse buttons are pressed and released. Table 2 shows all possible values of the GdkEventType enumeration, and the corresponding GdkEvent member. The meaning of each event type is described later in this section.

Table 2. GdkEventType Values

Value GdkEvent Member
GDK_NOTHING none [PD] footnote!
GDK_DELETE GdkEventAny
GDK_DESTROY GdkEventAny
GDK_EXPOSE GdkEventExpose
GDK_MOTION_NOTIFY GdkEventMotion
GDK_BUTTON_PRESS GdkEventButton
GDK_2BUTTON_PRESS GdkEventButton
GDK_3BUTTON_PRESS GdkEventButton
GDK_BUTTON_RELEASE GdkEventButton
GDK_KEY_PRESS GdkEventKey
GDK_KEY_RELEASE GdkEventKey
GDK_ENTER_NOTIFY GdkEventCrossing
GDK_LEAVE_NOTIFY GdkEventCrossing
GDK_FOCUS_CHANGE GdkEventFocus
GDK_CONFIGURE GdkEventConfigure
GDK_MAP GdkEventAny
GDK_UNMAP GdkEventAny
GDK_PROPERTY_NOTIFY GdkEventProperty
GDK_SELECTION_CLEAR GdkEventSelection
GDK_SELECTION_REQUEST GdkEventSelection
GDK_SELECTION_NOTIFY GdkEventSelection
GDK_PROXIMITY_IN GdkEventProximity
GDK_PROXIMITY_OUT GdkEventProximity
GDK_DRAG_ENTER GdkEventDND
GDK_DRAG_LEAVE GdkEventDND
GDK_DRAG_MOTION GdkEventDND
GDK_DRAG_STATUS GdkEventDND
GDK_DROP_START GdkEventDND
GDK_DROP_FINISHED GdkEventDND
GDK_CLIENT_EVENT GdkEventClient
GDK_VISIBILITY_NOTIFY GdkEventVisibility
GDK_NO_EXPOSE GdkEventNoExpose
Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire