| OLD | NEW | 
|    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "base/message_pump_x.h" |    5 #include "base/message_pump_x.h" | 
|    6  |    6  | 
|    7 #include <X11/extensions/XInput2.h> |    7 #include <X11/extensions/XInput2.h> | 
|    8  |    8  | 
|    9 #include "base/basictypes.h" |    9 #include "base/basictypes.h" | 
|   10 #include "base/message_loop.h" |   10 #include "base/message_loop.h" | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   59 #endif  // defined(TOOLKIT_USES_GTK) |   59 #endif  // defined(TOOLKIT_USES_GTK) | 
|   60  |   60  | 
|   61 void InitializeXInput2(void) { |   61 void InitializeXInput2(void) { | 
|   62   Display* display = base::MessagePumpX::GetDefaultXDisplay(); |   62   Display* display = base::MessagePumpX::GetDefaultXDisplay(); | 
|   63   if (!display) |   63   if (!display) | 
|   64     return; |   64     return; | 
|   65  |   65  | 
|   66   int event, err; |   66   int event, err; | 
|   67  |   67  | 
|   68   if (!XQueryExtension(display, "XInputExtension", &xiopcode, &event, &err)) { |   68   if (!XQueryExtension(display, "XInputExtension", &xiopcode, &event, &err)) { | 
|   69     VLOG(1) << "X Input extension not available."; |   69     DVLOG(1) << "X Input extension not available."; | 
|   70     xiopcode = -1; |   70     xiopcode = -1; | 
|   71     return; |   71     return; | 
|   72   } |   72   } | 
|   73  |   73  | 
|   74 #if defined(USE_XI2_MT) |   74 #if defined(USE_XI2_MT) | 
|   75   // USE_XI2_MT also defines the required XI2 minor minimum version. |   75   // USE_XI2_MT also defines the required XI2 minor minimum version. | 
|   76   int major = 2, minor = USE_XI2_MT; |   76   int major = 2, minor = USE_XI2_MT; | 
|   77 #else |   77 #else | 
|   78   int major = 2, minor = 0; |   78   int major = 2, minor = 0; | 
|   79 #endif |   79 #endif | 
|   80   if (XIQueryVersion(display, &major, &minor) == BadRequest) { |   80   if (XIQueryVersion(display, &major, &minor) == BadRequest) { | 
|   81     VLOG(1) << "XInput2 not supported in the server."; |   81     DVLOG(1) << "XInput2 not supported in the server."; | 
|   82     xiopcode = -1; |   82     xiopcode = -1; | 
|   83     return; |   83     return; | 
|   84   } |   84   } | 
|   85 #if defined(USE_XI2_MT) |   85 #if defined(USE_XI2_MT) | 
|   86   if (major < 2 || (major == 2 && minor < USE_XI2_MT)) { |   86   if (major < 2 || (major == 2 && minor < USE_XI2_MT)) { | 
|   87     VLOG(1) << "XI version on server is " << major << "." << minor << ". " |   87     DVLOG(1) << "XI version on server is " << major << "." << minor << ". " | 
|   88             << "But 2." << USE_XI2_MT << " is required."; |   88             << "But 2." << USE_XI2_MT << " is required."; | 
|   89     xiopcode = -1; |   89     xiopcode = -1; | 
|   90     return; |   90     return; | 
|   91   } |   91   } | 
|   92 #endif |   92 #endif | 
|   93 } |   93 } | 
|   94  |   94  | 
|   95 }  // namespace |   95 }  // namespace | 
|   96  |   96  | 
|   97 namespace base { |   97 namespace base { | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  141  |  141  | 
|  142 // static |  142 // static | 
|  143 bool MessagePumpX::HasXInput2() { |  143 bool MessagePumpX::HasXInput2() { | 
|  144   return xiopcode != -1; |  144   return xiopcode != -1; | 
|  145 } |  145 } | 
|  146  |  146  | 
|  147 void MessagePumpX::InitXSource() { |  147 void MessagePumpX::InitXSource() { | 
|  148   DCHECK(!x_source_); |  148   DCHECK(!x_source_); | 
|  149   GPollFD* x_poll = new GPollFD(); |  149   GPollFD* x_poll = new GPollFD(); | 
|  150   Display* display = GetDefaultXDisplay(); |  150   Display* display = GetDefaultXDisplay(); | 
|  151   CHECK(display) << "Unable to get connection to X server"; |  151   DCHECK(display) << "Unable to get connection to X server"; | 
|  152   x_poll->fd = ConnectionNumber(display); |  152   x_poll->fd = ConnectionNumber(display); | 
|  153   x_poll->events = G_IO_IN; |  153   x_poll->events = G_IO_IN; | 
|  154  |  154  | 
|  155   x_source_ = g_source_new(&XSourceFuncs, sizeof(GSource)); |  155   x_source_ = g_source_new(&XSourceFuncs, sizeof(GSource)); | 
|  156   g_source_add_poll(x_source_, x_poll); |  156   g_source_add_poll(x_source_, x_poll); | 
|  157   g_source_set_can_recurse(x_source_, FALSE); |  157   g_source_set_can_recurse(x_source_, FALSE); | 
|  158   g_source_attach(x_source_, g_main_context_default()); |  158   g_source_attach(x_source_, g_main_context_default()); | 
|  159 } |  159 } | 
|  160  |  160  | 
|  161 bool MessagePumpX::ShouldCaptureXEvent(XEvent* xev) { |  161 bool MessagePumpX::ShouldCaptureXEvent(XEvent* xev) { | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  179   } |  179   } | 
|  180  |  180  | 
|  181   if (WillProcessXEvent(xev) == EVENT_CONTINUE) { |  181   if (WillProcessXEvent(xev) == EVENT_CONTINUE) { | 
|  182     MessagePumpDispatcher::DispatchStatus status = |  182     MessagePumpDispatcher::DispatchStatus status = | 
|  183         GetDispatcher()->Dispatch(xev); |  183         GetDispatcher()->Dispatch(xev); | 
|  184  |  184  | 
|  185     if (status == MessagePumpDispatcher::EVENT_QUIT) { |  185     if (status == MessagePumpDispatcher::EVENT_QUIT) { | 
|  186       should_quit = true; |  186       should_quit = true; | 
|  187       Quit(); |  187       Quit(); | 
|  188     } else if (status == MessagePumpDispatcher::EVENT_IGNORED) { |  188     } else if (status == MessagePumpDispatcher::EVENT_IGNORED) { | 
|  189       VLOG(1) << "Event (" << xev->type << ") not handled."; |  189       DVLOG(1) << "Event (" << xev->type << ") not handled."; | 
|  190     } |  190     } | 
|  191     DidProcessXEvent(xev); |  191     DidProcessXEvent(xev); | 
|  192   } |  192   } | 
|  193  |  193  | 
|  194   if (have_cookie) { |  194   if (have_cookie) { | 
|  195     XFreeEventData(xev->xgeneric.display, &xev->xcookie); |  195     XFreeEventData(xev->xgeneric.display, &xev->xcookie); | 
|  196   } |  196   } | 
|  197  |  197  | 
|  198   return should_quit; |  198   return should_quit; | 
|  199 } |  199 } | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  319   capture_gdk_events_[GDK_MOTION_NOTIFY] = true; |  319   capture_gdk_events_[GDK_MOTION_NOTIFY] = true; | 
|  320  |  320  | 
|  321   capture_x_events_[GenericEvent] = true; |  321   capture_x_events_[GenericEvent] = true; | 
|  322 } |  322 } | 
|  323  |  323  | 
|  324 COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small); |  324 COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small); | 
|  325  |  325  | 
|  326 #endif  // defined(TOOLKIT_USES_GTK) |  326 #endif  // defined(TOOLKIT_USES_GTK) | 
|  327  |  327  | 
|  328 }  // namespace base |  328 }  // namespace base | 
| OLD | NEW |