| 679 | |
| 680 | |
| 681 | int Window::getMods() { |
| 682 | int mods = 0; |
| 683 | #if defined ARCH_LIN |
| 684 | // On Linux X11, get mods directly from X11 display, to support X11 key remapping |
| 685 | Display* display = glfwGetX11Display(); |
| 686 | XkbStateRec state; |
| 687 | XkbGetState(display, XkbUseCoreKbd, &state); |
| 688 | |
| 689 | // Derived from GLFW's translateState() from x11_window.c |
| 690 | if (state.mods & ShiftMask) |
| 691 | mods |= GLFW_MOD_SHIFT; |
| 692 | if (state.mods & ControlMask) |
| 693 | mods |= GLFW_MOD_CONTROL; |
| 694 | if (state.mods & Mod1Mask) |
| 695 | mods |= GLFW_MOD_ALT; |
| 696 | if (state.mods & Mod4Mask) |
| 697 | mods |= GLFW_MOD_SUPER; |
| 698 | if (state.mods & LockMask) |
| 699 | mods |= GLFW_MOD_CAPS_LOCK; |
| 700 | if (state.mods & Mod2Mask) |
| 701 | mods |= GLFW_MOD_NUM_LOCK; |
| 702 | #else |
| 703 | // Use GLFW key codes on other OS's |
| 704 | if (glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS) |
| 705 | mods |= GLFW_MOD_SHIFT; |
| 706 | if (glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) |
| 707 | mods |= GLFW_MOD_CONTROL; |
| 708 | if (glfwGetKey(win, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS) |
| 709 | mods |= GLFW_MOD_ALT; |
| 710 | if (glfwGetKey(win, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS) |
| 711 | mods |= GLFW_MOD_SUPER; |
| 712 | #endif |
| 713 | return mods; |
| 714 | } |
| 715 | |
| 716 | |
| 717 | void Window::setFullScreen(bool fullScreen) { |
no outgoing calls
no test coverage detected