2 #include "x-event-manager.h"
7 #include <dali/integration-api/debug.h>
8 #include <dali/public-api/signals/callback.h>
22 #if defined(DEBUG_ENABLED)
23 //Dali::Integration::Log::Filter* gInputDeviceLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_X_EVENT");
28 XEventManager::XEventManager( XID window, Display* display, WindowEventInterface* eventInterface )
29 : mXInput2( window, display, eventInterface ),
30 mFileDescriptorMonitor( NULL ),
37 XEventManager::~XEventManager()
39 delete mFileDescriptorMonitor;
42 void XEventManager::Initialize()
49 XSelectInput( mDisplay, mWindow, StructureNotifyMask | ExposureMask | KeyPressMask | KeyReleaseMask );
51 mXInput2.Initialize();
53 // Start monitoring for X events on a file descriptor return via ConnectionNumber.
54 int fileDescriptor = ConnectionNumber( mDisplay );
56 CallbackBase* callback = MakeCallback( this, &XEventManager::XEventReceived);
58 mFileDescriptorMonitor = new FileDescriptorMonitor( fileDescriptor, callback, FileDescriptorMonitor::FD_READABLE );
64 void XEventManager::XEventReceived( FileDescriptorMonitor::EventType eventMask )
66 if( ! ( eventMask & FileDescriptorMonitor::FD_READABLE ) )
68 DALI_ASSERT_ALWAYS( 0 && "X File descriptor error");
72 while( XPending( mDisplay) )
75 XNextEvent( mDisplay, &xEvent );
77 // cookie data pointer is undefined until XGetEventData is called.
78 XGenericEventCookie* cookie = &xEvent.xcookie;
80 // Tizen 2.4 TV current uses client messages for key presses instead of KeyPress type
81 if( xEvent.type == ClientMessage)
83 // Process Client Message
84 mXInput2.ProcessClientMessage( &xEvent );
86 else if( xEvent.type == KeyPress )
88 mXInput2.ProcessKeyEvent( (XKeyEvent*)&xEvent );
90 else if( xEvent.type == GenericEvent )
92 if( XGetEventData( mDisplay, cookie ) )
94 if( cookie->extension == mXInput2.GetExtensionId() )
96 mXInput2.ProcessGenericEvent( cookie );
98 XFreeEventData( mDisplay, cookie );
105 } // namespace internal
106 } // namespace adaptor