|
|
@@ -103,86 +103,86 @@ static KeyboardButton::Enum x11_translate_key(KeySym x11_key)
|
|
|
{
|
|
|
switch (x11_key)
|
|
|
{
|
|
|
- case XK_BackSpace: return KeyboardButton::BACKSPACE;
|
|
|
- case XK_Tab: return KeyboardButton::TAB;
|
|
|
- case XK_space: return KeyboardButton::SPACE;
|
|
|
- case XK_Escape: return KeyboardButton::ESCAPE;
|
|
|
- case XK_Return: return KeyboardButton::ENTER;
|
|
|
- case XK_F1: return KeyboardButton::F1;
|
|
|
- case XK_F2: return KeyboardButton::F2;
|
|
|
- case XK_F3: return KeyboardButton::F3;
|
|
|
- case XK_F4: return KeyboardButton::F4;
|
|
|
- case XK_F5: return KeyboardButton::F5;
|
|
|
- case XK_F6: return KeyboardButton::F6;
|
|
|
- case XK_F7: return KeyboardButton::F7;
|
|
|
- case XK_F8: return KeyboardButton::F8;
|
|
|
- case XK_F9: return KeyboardButton::F9;
|
|
|
- case XK_F10: return KeyboardButton::F10;
|
|
|
- case XK_F11: return KeyboardButton::F11;
|
|
|
- case XK_F12: return KeyboardButton::F12;
|
|
|
- case XK_Home: return KeyboardButton::HOME;
|
|
|
- case XK_Left: return KeyboardButton::LEFT;
|
|
|
- case XK_Up: return KeyboardButton::UP;
|
|
|
- case XK_Right: return KeyboardButton::RIGHT;
|
|
|
- case XK_Down: return KeyboardButton::DOWN;
|
|
|
- case XK_Page_Up: return KeyboardButton::PAGE_UP;
|
|
|
- case XK_Page_Down: return KeyboardButton::PAGE_DOWN;
|
|
|
- case XK_Shift_L: return KeyboardButton::LSHIFT;
|
|
|
- case XK_Shift_R: return KeyboardButton::RSHIFT;
|
|
|
- case XK_Control_L: return KeyboardButton::LCONTROL;
|
|
|
- case XK_Control_R: return KeyboardButton::RCONTROL;
|
|
|
- case XK_Caps_Lock: return KeyboardButton::CAPS_LOCK;
|
|
|
- case XK_Alt_L: return KeyboardButton::LALT;
|
|
|
- case XK_Alt_R: return KeyboardButton::RALT;
|
|
|
- case XK_Super_L: return KeyboardButton::LSUPER;
|
|
|
- case XK_Super_R: return KeyboardButton::RSUPER;
|
|
|
- case XK_KP_0: return KeyboardButton::KP_0;
|
|
|
- case XK_KP_1: return KeyboardButton::KP_1;
|
|
|
- case XK_KP_2: return KeyboardButton::KP_2;
|
|
|
- case XK_KP_3: return KeyboardButton::KP_3;
|
|
|
- case XK_KP_4: return KeyboardButton::KP_4;
|
|
|
- case XK_KP_5: return KeyboardButton::KP_5;
|
|
|
- case XK_KP_6: return KeyboardButton::KP_6;
|
|
|
- case XK_KP_7: return KeyboardButton::KP_7;
|
|
|
- case XK_KP_8: return KeyboardButton::KP_8;
|
|
|
- case XK_KP_9: return KeyboardButton::KP_9;
|
|
|
- case '0': return KeyboardButton::NUM_0;
|
|
|
- case '1': return KeyboardButton::NUM_1;
|
|
|
- case '2': return KeyboardButton::NUM_2;
|
|
|
- case '3': return KeyboardButton::NUM_3;
|
|
|
- case '4': return KeyboardButton::NUM_4;
|
|
|
- case '5': return KeyboardButton::NUM_5;
|
|
|
- case '6': return KeyboardButton::NUM_6;
|
|
|
- case '7': return KeyboardButton::NUM_7;
|
|
|
- case '8': return KeyboardButton::NUM_8;
|
|
|
- case '9': return KeyboardButton::NUM_9;
|
|
|
- case 'a': return KeyboardButton::A;
|
|
|
- case 'b': return KeyboardButton::B;
|
|
|
- case 'c': return KeyboardButton::C;
|
|
|
- case 'd': return KeyboardButton::D;
|
|
|
- case 'e': return KeyboardButton::E;
|
|
|
- case 'f': return KeyboardButton::F;
|
|
|
- case 'g': return KeyboardButton::G;
|
|
|
- case 'h': return KeyboardButton::H;
|
|
|
- case 'i': return KeyboardButton::I;
|
|
|
- case 'j': return KeyboardButton::J;
|
|
|
- case 'k': return KeyboardButton::K;
|
|
|
- case 'l': return KeyboardButton::L;
|
|
|
- case 'm': return KeyboardButton::M;
|
|
|
- case 'n': return KeyboardButton::N;
|
|
|
- case 'o': return KeyboardButton::O;
|
|
|
- case 'p': return KeyboardButton::P;
|
|
|
- case 'q': return KeyboardButton::Q;
|
|
|
- case 'r': return KeyboardButton::R;
|
|
|
- case 's': return KeyboardButton::S;
|
|
|
- case 't': return KeyboardButton::T;
|
|
|
- case 'u': return KeyboardButton::U;
|
|
|
- case 'v': return KeyboardButton::V;
|
|
|
- case 'w': return KeyboardButton::W;
|
|
|
- case 'x': return KeyboardButton::X;
|
|
|
- case 'y': return KeyboardButton::Y;
|
|
|
- case 'z': return KeyboardButton::Z;
|
|
|
- default: return KeyboardButton::NONE;
|
|
|
+ case XK_BackSpace: return KeyboardButton::BACKSPACE;
|
|
|
+ case XK_Tab: return KeyboardButton::TAB;
|
|
|
+ case XK_space: return KeyboardButton::SPACE;
|
|
|
+ case XK_Escape: return KeyboardButton::ESCAPE;
|
|
|
+ case XK_Return: return KeyboardButton::ENTER;
|
|
|
+ case XK_F1: return KeyboardButton::F1;
|
|
|
+ case XK_F2: return KeyboardButton::F2;
|
|
|
+ case XK_F3: return KeyboardButton::F3;
|
|
|
+ case XK_F4: return KeyboardButton::F4;
|
|
|
+ case XK_F5: return KeyboardButton::F5;
|
|
|
+ case XK_F6: return KeyboardButton::F6;
|
|
|
+ case XK_F7: return KeyboardButton::F7;
|
|
|
+ case XK_F8: return KeyboardButton::F8;
|
|
|
+ case XK_F9: return KeyboardButton::F9;
|
|
|
+ case XK_F10: return KeyboardButton::F10;
|
|
|
+ case XK_F11: return KeyboardButton::F11;
|
|
|
+ case XK_F12: return KeyboardButton::F12;
|
|
|
+ case XK_Home: return KeyboardButton::HOME;
|
|
|
+ case XK_Left: return KeyboardButton::LEFT;
|
|
|
+ case XK_Up: return KeyboardButton::UP;
|
|
|
+ case XK_Right: return KeyboardButton::RIGHT;
|
|
|
+ case XK_Down: return KeyboardButton::DOWN;
|
|
|
+ case XK_Page_Up: return KeyboardButton::PAGE_UP;
|
|
|
+ case XK_Page_Down: return KeyboardButton::PAGE_DOWN;
|
|
|
+ case XK_Shift_L: return KeyboardButton::LSHIFT;
|
|
|
+ case XK_Shift_R: return KeyboardButton::RSHIFT;
|
|
|
+ case XK_Control_L: return KeyboardButton::LCONTROL;
|
|
|
+ case XK_Control_R: return KeyboardButton::RCONTROL;
|
|
|
+ case XK_Caps_Lock: return KeyboardButton::CAPS_LOCK;
|
|
|
+ case XK_Alt_L: return KeyboardButton::LALT;
|
|
|
+ case XK_Alt_R: return KeyboardButton::RALT;
|
|
|
+ case XK_Super_L: return KeyboardButton::LSUPER;
|
|
|
+ case XK_Super_R: return KeyboardButton::RSUPER;
|
|
|
+ case XK_KP_0: return KeyboardButton::KP_0;
|
|
|
+ case XK_KP_1: return KeyboardButton::KP_1;
|
|
|
+ case XK_KP_2: return KeyboardButton::KP_2;
|
|
|
+ case XK_KP_3: return KeyboardButton::KP_3;
|
|
|
+ case XK_KP_4: return KeyboardButton::KP_4;
|
|
|
+ case XK_KP_5: return KeyboardButton::KP_5;
|
|
|
+ case XK_KP_6: return KeyboardButton::KP_6;
|
|
|
+ case XK_KP_7: return KeyboardButton::KP_7;
|
|
|
+ case XK_KP_8: return KeyboardButton::KP_8;
|
|
|
+ case XK_KP_9: return KeyboardButton::KP_9;
|
|
|
+ case '0': return KeyboardButton::NUM_0;
|
|
|
+ case '1': return KeyboardButton::NUM_1;
|
|
|
+ case '2': return KeyboardButton::NUM_2;
|
|
|
+ case '3': return KeyboardButton::NUM_3;
|
|
|
+ case '4': return KeyboardButton::NUM_4;
|
|
|
+ case '5': return KeyboardButton::NUM_5;
|
|
|
+ case '6': return KeyboardButton::NUM_6;
|
|
|
+ case '7': return KeyboardButton::NUM_7;
|
|
|
+ case '8': return KeyboardButton::NUM_8;
|
|
|
+ case '9': return KeyboardButton::NUM_9;
|
|
|
+ case 'a': return KeyboardButton::A;
|
|
|
+ case 'b': return KeyboardButton::B;
|
|
|
+ case 'c': return KeyboardButton::C;
|
|
|
+ case 'd': return KeyboardButton::D;
|
|
|
+ case 'e': return KeyboardButton::E;
|
|
|
+ case 'f': return KeyboardButton::F;
|
|
|
+ case 'g': return KeyboardButton::G;
|
|
|
+ case 'h': return KeyboardButton::H;
|
|
|
+ case 'i': return KeyboardButton::I;
|
|
|
+ case 'j': return KeyboardButton::J;
|
|
|
+ case 'k': return KeyboardButton::K;
|
|
|
+ case 'l': return KeyboardButton::L;
|
|
|
+ case 'm': return KeyboardButton::M;
|
|
|
+ case 'n': return KeyboardButton::N;
|
|
|
+ case 'o': return KeyboardButton::O;
|
|
|
+ case 'p': return KeyboardButton::P;
|
|
|
+ case 'q': return KeyboardButton::Q;
|
|
|
+ case 'r': return KeyboardButton::R;
|
|
|
+ case 's': return KeyboardButton::S;
|
|
|
+ case 't': return KeyboardButton::T;
|
|
|
+ case 'u': return KeyboardButton::U;
|
|
|
+ case 'v': return KeyboardButton::V;
|
|
|
+ case 'w': return KeyboardButton::W;
|
|
|
+ case 'x': return KeyboardButton::X;
|
|
|
+ case 'y': return KeyboardButton::Y;
|
|
|
+ case 'z': return KeyboardButton::Z;
|
|
|
+ default: return KeyboardButton::NONE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -212,11 +212,11 @@ int32_t func(void* data)
|
|
|
struct LinuxDevice
|
|
|
{
|
|
|
LinuxDevice()
|
|
|
- : m_x11_display(NULL)
|
|
|
- , m_x11_window(None)
|
|
|
- , m_x11_parent_window(None)
|
|
|
- , m_x11_hidden_cursor(None)
|
|
|
- , m_screen_config(NULL)
|
|
|
+ : _x11_display(NULL)
|
|
|
+ , _x11_window(None)
|
|
|
+ , _x11_parent_window(None)
|
|
|
+ , _x11_hidden_cursor(None)
|
|
|
+ , _screen_config(NULL)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -225,15 +225,15 @@ struct LinuxDevice
|
|
|
// Create main window
|
|
|
XInitThreads();
|
|
|
XSetErrorHandler(x11_error_handler);
|
|
|
- m_x11_display = XOpenDisplay(NULL);
|
|
|
+ _x11_display = XOpenDisplay(NULL);
|
|
|
|
|
|
- CE_ASSERT(m_x11_display != NULL, "Unable to open X11 display");
|
|
|
+ CE_ASSERT(_x11_display != NULL, "Unable to open X11 display");
|
|
|
|
|
|
- int screen = DefaultScreen(m_x11_display);
|
|
|
- int depth = DefaultDepth(m_x11_display, screen);
|
|
|
- Visual* visual = DefaultVisual(m_x11_display, screen);
|
|
|
+ int screen = DefaultScreen(_x11_display);
|
|
|
+ int depth = DefaultDepth(_x11_display, screen);
|
|
|
+ Visual* visual = DefaultVisual(_x11_display, screen);
|
|
|
|
|
|
- m_x11_parent_window = (cls->parent_window == 0) ? RootWindow(m_x11_display, screen) :
|
|
|
+ _x11_parent_window = (cls->parent_window == 0) ? RootWindow(_x11_display, screen) :
|
|
|
(Window) cls->parent_window;
|
|
|
|
|
|
// Create main window
|
|
|
@@ -248,8 +248,8 @@ struct LinuxDevice
|
|
|
| ButtonReleaseMask
|
|
|
| PointerMotionMask;
|
|
|
|
|
|
- m_x11_window = XCreateWindow(m_x11_display,
|
|
|
- m_x11_parent_window,
|
|
|
+ _x11_window = XCreateWindow(_x11_display,
|
|
|
+ _x11_parent_window,
|
|
|
0, 0,
|
|
|
cs->window_width,
|
|
|
cs->window_height,
|
|
|
@@ -260,11 +260,11 @@ struct LinuxDevice
|
|
|
CWBorderPixel | CWEventMask,
|
|
|
&win_attribs
|
|
|
);
|
|
|
- CE_ASSERT(m_x11_window != None, "Unable to create X window");
|
|
|
+ CE_ASSERT(_x11_window != None, "Unable to create X window");
|
|
|
|
|
|
// Do we have detectable autorepeat?
|
|
|
Bool detectable;
|
|
|
- m_x11_detectable_autorepeat = (bool) XkbSetDetectableAutoRepeat(m_x11_display, true, &detectable);
|
|
|
+ _x11_detectable_autorepeat = (bool) XkbSetDetectableAutoRepeat(_x11_display, true, &detectable);
|
|
|
|
|
|
// Build hidden cursor
|
|
|
Pixmap bm_no;
|
|
|
@@ -272,23 +272,23 @@ struct LinuxDevice
|
|
|
Colormap colormap;
|
|
|
static char no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
|
- colormap = XDefaultColormap(m_x11_display, screen);
|
|
|
- XAllocNamedColor(m_x11_display, colormap, "black", &black, &dummy);
|
|
|
- bm_no = XCreateBitmapFromData(m_x11_display, m_x11_window, no_data, 8, 8);
|
|
|
- m_x11_hidden_cursor = XCreatePixmapCursor(m_x11_display, bm_no, bm_no, &black, &black, 0, 0);
|
|
|
+ colormap = XDefaultColormap(_x11_display, screen);
|
|
|
+ XAllocNamedColor(_x11_display, colormap, "black", &black, &dummy);
|
|
|
+ bm_no = XCreateBitmapFromData(_x11_display, _x11_window, no_data, 8, 8);
|
|
|
+ _x11_hidden_cursor = XCreatePixmapCursor(_x11_display, bm_no, bm_no, &black, &black, 0, 0);
|
|
|
|
|
|
- m_wm_delete_message = XInternAtom(m_x11_display, "WM_DELETE_WINDOW", False);
|
|
|
- XSetWMProtocols(m_x11_display, m_x11_window, &m_wm_delete_message, 1);
|
|
|
+ _wm_delete_message = XInternAtom(_x11_display, "WM_DELETE_WINDOW", False);
|
|
|
+ XSetWMProtocols(_x11_display, _x11_window, &_wm_delete_message, 1);
|
|
|
|
|
|
- oswindow_set_window(m_x11_display, m_x11_window);
|
|
|
- bgfx::x11SetDisplayWindow(m_x11_display, m_x11_window);
|
|
|
- XMapRaised(m_x11_display, m_x11_window);
|
|
|
+ oswindow_set_window(_x11_display, _x11_window);
|
|
|
+ bgfx::x11SetDisplayWindow(_x11_display, _x11_window);
|
|
|
+ XMapRaised(_x11_display, _x11_window);
|
|
|
|
|
|
// Get screen configuration
|
|
|
- m_screen_config = XRRGetScreenInfo(m_x11_display, RootWindow(m_x11_display, screen));
|
|
|
+ _screen_config = XRRGetScreenInfo(_x11_display, RootWindow(_x11_display, screen));
|
|
|
|
|
|
Rotation rr_old_rot;
|
|
|
- const SizeID rr_old_sizeid = XRRConfigCurrentConfiguration(m_screen_config, &rr_old_rot);
|
|
|
+ const SizeID rr_old_sizeid = XRRConfigCurrentConfiguration(_screen_config, &rr_old_rot);
|
|
|
|
|
|
// Start main thread
|
|
|
MainThreadArgs mta;
|
|
|
@@ -307,44 +307,44 @@ struct LinuxDevice
|
|
|
|
|
|
// Restore previous screen configuration if changed
|
|
|
Rotation rr_cur_rot;
|
|
|
- const SizeID rr_cur_sizeid = XRRConfigCurrentConfiguration(m_screen_config, &rr_cur_rot);
|
|
|
+ const SizeID rr_cur_sizeid = XRRConfigCurrentConfiguration(_screen_config, &rr_cur_rot);
|
|
|
|
|
|
if (rr_cur_rot != rr_old_rot || rr_cur_sizeid != rr_old_sizeid)
|
|
|
{
|
|
|
- XRRSetScreenConfig(m_x11_display,
|
|
|
- m_screen_config,
|
|
|
- RootWindow(m_x11_display, screen),
|
|
|
+ XRRSetScreenConfig(_x11_display,
|
|
|
+ _screen_config,
|
|
|
+ RootWindow(_x11_display, screen),
|
|
|
rr_old_sizeid,
|
|
|
rr_old_rot,
|
|
|
CurrentTime);
|
|
|
}
|
|
|
- XRRFreeScreenConfigInfo(m_screen_config);
|
|
|
+ XRRFreeScreenConfigInfo(_screen_config);
|
|
|
|
|
|
- XDestroyWindow(m_x11_display, m_x11_window);
|
|
|
- XCloseDisplay(m_x11_display);
|
|
|
+ XDestroyWindow(_x11_display, _x11_window);
|
|
|
+ XCloseDisplay(_x11_display);
|
|
|
return EXIT_SUCCESS;
|
|
|
}
|
|
|
|
|
|
void pump_events()
|
|
|
{
|
|
|
- while (XPending(m_x11_display))
|
|
|
+ while (XPending(_x11_display))
|
|
|
{
|
|
|
XEvent event;
|
|
|
- XNextEvent(m_x11_display, &event);
|
|
|
+ XNextEvent(_x11_display, &event);
|
|
|
|
|
|
switch (event.type)
|
|
|
{
|
|
|
case ClientMessage:
|
|
|
{
|
|
|
- if ((Atom)event.xclient.data.l[0] == m_wm_delete_message)
|
|
|
+ if ((Atom)event.xclient.data.l[0] == _wm_delete_message)
|
|
|
{
|
|
|
- m_queue.push_exit_event(0);
|
|
|
+ _queue.push_exit_event(0);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case ConfigureNotify:
|
|
|
{
|
|
|
- m_queue.push_metrics_event(event.xconfigure.x, event.xconfigure.y,
|
|
|
+ _queue.push_metrics_event(event.xconfigure.x, event.xconfigure.y,
|
|
|
event.xconfigure.width, event.xconfigure.height);
|
|
|
break;
|
|
|
}
|
|
|
@@ -362,14 +362,14 @@ struct LinuxDevice
|
|
|
|
|
|
if (mb != MouseButton::NONE)
|
|
|
{
|
|
|
- m_queue.push_mouse_event(event.xbutton.x, event.xbutton.y, mb, event.type == ButtonPress);
|
|
|
+ _queue.push_mouse_event(event.xbutton.x, event.xbutton.y, mb, event.type == ButtonPress);
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
case MotionNotify:
|
|
|
{
|
|
|
- m_queue.push_mouse_event(event.xmotion.x, event.xmotion.y);
|
|
|
+ _queue.push_mouse_event(event.xmotion.x, event.xmotion.y);
|
|
|
break;
|
|
|
}
|
|
|
case KeyPress:
|
|
|
@@ -394,7 +394,7 @@ struct LinuxDevice
|
|
|
(event.type == KeyPress) ? modifier_mask |= ModifierButton::ALT : modifier_mask &= ~ModifierButton::ALT;
|
|
|
}
|
|
|
|
|
|
- m_queue.push_keyboard_event(modifier_mask, kb, event.type == KeyPress);
|
|
|
+ _queue.push_keyboard_event(modifier_mask, kb, event.type == KeyPress);
|
|
|
break;
|
|
|
}
|
|
|
case KeymapNotify:
|
|
|
@@ -412,21 +412,21 @@ struct LinuxDevice
|
|
|
|
|
|
public:
|
|
|
|
|
|
- Display* m_x11_display;
|
|
|
- Window m_x11_window;
|
|
|
- Window m_x11_parent_window;
|
|
|
- Cursor m_x11_hidden_cursor;
|
|
|
- Atom m_wm_delete_message;
|
|
|
- XRRScreenConfiguration* m_screen_config;
|
|
|
- bool m_x11_detectable_autorepeat;
|
|
|
- OsEventQueue m_queue;
|
|
|
+ Display* _x11_display;
|
|
|
+ Window _x11_window;
|
|
|
+ Window _x11_parent_window;
|
|
|
+ Cursor _x11_hidden_cursor;
|
|
|
+ Atom _wm_delete_message;
|
|
|
+ XRRScreenConfiguration* _screen_config;
|
|
|
+ bool _x11_detectable_autorepeat;
|
|
|
+ OsEventQueue _queue;
|
|
|
};
|
|
|
|
|
|
static LinuxDevice s_ldvc;
|
|
|
|
|
|
bool next_event(OsEvent& ev)
|
|
|
{
|
|
|
- return s_ldvc.m_queue.pop_event(ev);
|
|
|
+ return s_ldvc._queue.pop_event(ev);
|
|
|
}
|
|
|
|
|
|
} // namespace crown
|