Add X11 events logging for debug purpose
Compiled out by default, just to be used for debugging local builds.
This commit is contained in:
parent
828898867f
commit
2a638a9cdf
1 changed files with 60 additions and 12 deletions
|
@ -88,6 +88,13 @@
|
||||||
#define VALUATOR_TILTX 3
|
#define VALUATOR_TILTX 3
|
||||||
#define VALUATOR_TILTY 4
|
#define VALUATOR_TILTY 4
|
||||||
|
|
||||||
|
//#define DISPLAY_SERVER_X11_DEBUG_LOGS_ENABLED
|
||||||
|
#ifdef DISPLAY_SERVER_X11_DEBUG_LOGS_ENABLED
|
||||||
|
#define DEBUG_LOG_X11(...) printf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEBUG_LOG_X11(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
static const double abs_resolution_mult = 10000.0;
|
static const double abs_resolution_mult = 10000.0;
|
||||||
static const double abs_resolution_range_mult = 10.0;
|
static const double abs_resolution_range_mult = 10.0;
|
||||||
|
|
||||||
|
@ -2346,6 +2353,11 @@ void OS_X11::_poll_events() {
|
||||||
void OS_X11::process_xevents() {
|
void OS_X11::process_xevents() {
|
||||||
//printf("checking events %i\n", XPending(x11_display));
|
//printf("checking events %i\n", XPending(x11_display));
|
||||||
|
|
||||||
|
#ifdef DISPLAY_SERVER_X11_DEBUG_LOGS_ENABLED
|
||||||
|
static int frame = 0;
|
||||||
|
++frame;
|
||||||
|
#endif
|
||||||
|
|
||||||
do_mouse_warp = false;
|
do_mouse_warp = false;
|
||||||
|
|
||||||
// Is the current mouse mode one where it needs to be grabbed.
|
// Is the current mouse mode one where it needs to be grabbed.
|
||||||
|
@ -2526,30 +2538,45 @@ void OS_X11::process_xevents() {
|
||||||
XFreeEventData(x11_display, &event.xcookie);
|
XFreeEventData(x11_display, &event.xcookie);
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case Expose:
|
case Expose: {
|
||||||
Main::force_redraw();
|
DEBUG_LOG_X11("[%u] Expose window=%lu, count='%u' \n", frame, event.xexpose.window, event.xexpose.count);
|
||||||
break;
|
|
||||||
|
Main::force_redraw();
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case NoExpose: {
|
||||||
|
DEBUG_LOG_X11("[%u] NoExpose drawable=%lu \n", frame, event.xnoexpose.drawable);
|
||||||
|
|
||||||
case NoExpose:
|
|
||||||
minimized = true;
|
minimized = true;
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case VisibilityNotify: {
|
case VisibilityNotify: {
|
||||||
|
DEBUG_LOG_X11("[%u] VisibilityNotify window=%lu, state=%u \n", frame, event.xvisibility.window, event.xvisibility.state);
|
||||||
|
|
||||||
XVisibilityEvent *visibility = (XVisibilityEvent *)&event;
|
XVisibilityEvent *visibility = (XVisibilityEvent *)&event;
|
||||||
minimized = (visibility->state == VisibilityFullyObscured);
|
minimized = (visibility->state == VisibilityFullyObscured);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case LeaveNotify: {
|
case LeaveNotify: {
|
||||||
|
DEBUG_LOG_X11("[%u] LeaveNotify window=%lu, mode='%u' \n", frame, event.xcrossing.window, event.xcrossing.mode);
|
||||||
|
|
||||||
if (main_loop && !mouse_mode_grab) {
|
if (main_loop && !mouse_mode_grab) {
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case EnterNotify: {
|
case EnterNotify: {
|
||||||
|
DEBUG_LOG_X11("[%u] EnterNotify window=%lu, mode='%u' \n", frame, event.xcrossing.window, event.xcrossing.mode);
|
||||||
|
|
||||||
if (main_loop && !mouse_mode_grab) {
|
if (main_loop && !mouse_mode_grab) {
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case FocusIn:
|
|
||||||
|
case FocusIn: {
|
||||||
|
DEBUG_LOG_X11("[%u] FocusIn window=%lu, mode='%u' \n", frame, event.xfocus.window, event.xfocus.mode);
|
||||||
|
|
||||||
minimized = false;
|
minimized = false;
|
||||||
window_has_focus = true;
|
window_has_focus = true;
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
|
@ -2580,9 +2607,11 @@ void OS_X11::process_xevents() {
|
||||||
MutexLock mutex_lock(events_mutex);
|
MutexLock mutex_lock(events_mutex);
|
||||||
XSetICFocus(xic);
|
XSetICFocus(xic);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
|
case FocusOut: {
|
||||||
|
DEBUG_LOG_X11("[%u] FocusOut window=%lu, mode='%u' \n", frame, event.xfocus.window, event.xfocus.mode);
|
||||||
|
|
||||||
case FocusOut:
|
|
||||||
window_has_focus = false;
|
window_has_focus = false;
|
||||||
input->release_pressed_events();
|
input->release_pressed_events();
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
|
@ -2618,11 +2647,14 @@ void OS_X11::process_xevents() {
|
||||||
MutexLock mutex_lock(events_mutex);
|
MutexLock mutex_lock(events_mutex);
|
||||||
XUnsetICFocus(xic);
|
XUnsetICFocus(xic);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
|
case ConfigureNotify: {
|
||||||
|
DEBUG_LOG_X11("[%u] ConfigureNotify window=%lu, event=%lu, above=%lu, override_redirect=%u \n", frame, event.xconfigure.window, event.xconfigure.event, event.xconfigure.above, event.xconfigure.override_redirect);
|
||||||
|
|
||||||
case ConfigureNotify:
|
|
||||||
_window_changed(&event);
|
_window_changed(&event);
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
case ButtonRelease: {
|
case ButtonRelease: {
|
||||||
/* exit in case of a mouse button press */
|
/* exit in case of a mouse button press */
|
||||||
|
@ -2649,6 +2681,8 @@ void OS_X11::process_xevents() {
|
||||||
mb->set_pressed((event.type == ButtonPress));
|
mb->set_pressed((event.type == ButtonPress));
|
||||||
|
|
||||||
if (event.type == ButtonPress) {
|
if (event.type == ButtonPress) {
|
||||||
|
DEBUG_LOG_X11("[%u] ButtonPress window=%lu, button_index=%u \n", frame, event.xbutton.window, mb->get_button_index());
|
||||||
|
|
||||||
uint64_t diff = get_ticks_usec() / 1000 - last_click_ms;
|
uint64_t diff = get_ticks_usec() / 1000 - last_click_ms;
|
||||||
|
|
||||||
if (mb->get_button_index() == last_click_button_index) {
|
if (mb->get_button_index() == last_click_button_index) {
|
||||||
|
@ -2667,6 +2701,8 @@ void OS_X11::process_xevents() {
|
||||||
last_click_ms += diff;
|
last_click_ms += diff;
|
||||||
last_click_pos = Point2(event.xbutton.x, event.xbutton.y);
|
last_click_pos = Point2(event.xbutton.x, event.xbutton.y);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG_LOG_X11("[%u] ButtonRelease window=%lu, button_index=%u \n", frame, event.xbutton.window, mb->get_button_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
input->parse_input_event(mb);
|
input->parse_input_event(mb);
|
||||||
|
@ -2788,13 +2824,21 @@ void OS_X11::process_xevents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease: {
|
case KeyRelease: {
|
||||||
|
#ifdef DISPLAY_SERVER_X11_DEBUG_LOGS_ENABLED
|
||||||
|
if (event.type == KeyPress) {
|
||||||
|
DEBUG_LOG_X11("[%u] KeyPress window=%lu, keycode=%u, time=%lu \n", frame, event.xkey.window, event.xkey.keycode, event.xkey.time);
|
||||||
|
} else {
|
||||||
|
DEBUG_LOG_X11("[%u] KeyRelease window=%lu, keycode=%u, time=%lu \n", frame, event.xkey.window, event.xkey.keycode, event.xkey.time);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
last_timestamp = event.xkey.time;
|
last_timestamp = event.xkey.time;
|
||||||
|
|
||||||
// key event is a little complex, so
|
// key event is a little complex, so
|
||||||
// it will be handled in its own function.
|
// it will be handled in its own function.
|
||||||
_handle_key_event((XKeyEvent *)&event, events, event_index);
|
_handle_key_event(&event.xkey, events, event_index);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
|
@ -3003,6 +3047,8 @@ String OS_X11::_get_clipboard_impl(Atom p_source, Window x11_window, Atom target
|
||||||
|
|
||||||
if (type == XInternAtom(x11_display, "INCR", 0)) {
|
if (type == XInternAtom(x11_display, "INCR", 0)) {
|
||||||
// Data is going to be received incrementally.
|
// Data is going to be received incrementally.
|
||||||
|
DEBUG_LOG_X11("INCR selection started.\n");
|
||||||
|
|
||||||
LocalVector<uint8_t> incr_data;
|
LocalVector<uint8_t> incr_data;
|
||||||
uint32_t data_size = 0;
|
uint32_t data_size = 0;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
@ -3031,6 +3077,8 @@ String OS_X11::_get_clipboard_impl(Atom p_source, Window x11_window, Atom target
|
||||||
&len, &bytes_left, // data length
|
&len, &bytes_left, // data length
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
|
DEBUG_LOG_X11("PropertyNotify: len=%lu, format=%i\n", len, format);
|
||||||
|
|
||||||
if (result == Success) {
|
if (result == Success) {
|
||||||
if (data && (len > 0)) {
|
if (data && (len > 0)) {
|
||||||
uint32_t prev_size = incr_data.size();
|
uint32_t prev_size = incr_data.size();
|
||||||
|
|
Loading…
Reference in a new issue