| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33030e9 commit fe2ca0b
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,7 @@ | |||
| 49 | 49 | // Setup a perspective projection | |
| 50 | 50 | glMatrixMode(GL_PROJECTION); | |
| 51 | 51 | glLoadIdentity(); | |
| 52 | - float extent = std::tan(sf::degrees(45).asRadians()); | ||
| 52 | + const float extent = std::tan(sf::degrees(45).asRadians()); | ||
| 53 | 53 | ||
| 54 | 54 | #ifdef SFML_OPENGL_ES | |
| 55 | 55 | glFrustumf(-extent, extent, -extent, extent, 1.0f, 500.0f); | |
@@ -166,55 +166,55 @@ int main() | |||
| 166 | 166 | return EXIT_FAILURE; | |
| 167 | 167 | ||
| 168 | 168 | // Get the default screen | |
| 169 | - int screen = DefaultScreen(display); | ||
| 169 | + const int screen = DefaultScreen(display); | ||
| 170 | 170 | ||
| 171 | 171 | // Let's create the main window | |
| 172 | 172 | XSetWindowAttributes attributes; | |
| 173 | 173 | attributes.background_pixel = BlackPixel(display, screen); | |
| 174 | 174 | attributes.event_mask = KeyPressMask; | |
| 175 | - Window window = XCreateWindow(display, | ||
| 176 | - RootWindow(display, screen), | ||
| 177 | - 0, | ||
| 178 | - 0, | ||
| 179 | - 650, | ||
| 180 | - 330, | ||
| 181 | - 0, | ||
| 182 | - DefaultDepth(display, screen), | ||
| 183 | - InputOutput, | ||
| 184 | - DefaultVisual(display, screen), | ||
| 185 | - CWBackPixel | CWEventMask, | ||
| 186 | - &attributes); | ||
| 175 | + const Window window = XCreateWindow(display, | ||
| 176 | + RootWindow(display, screen), | ||
| 177 | + 0, | ||
| 178 | + 0, | ||
| 179 | + 650, | ||
| 180 | + 330, | ||
| 181 | + 0, | ||
| 182 | + DefaultDepth(display, screen), | ||
| 183 | + InputOutput, | ||
| 184 | + DefaultVisual(display, screen), | ||
| 185 | + CWBackPixel | CWEventMask, | ||
| 186 | + &attributes); | ||
| 187 | 187 | if (!window) | |
| 188 | 188 | return EXIT_FAILURE; | |
| 189 | 189 | ||
| 190 | 190 | // Set the window's name | |
| 191 | 191 | XStoreName(display, window, "SFML Window"); | |
| 192 | 192 | ||
| 193 | 193 | // Let's create the windows which will serve as containers for our SFML views | |
| 194 | - Window view1 = XCreateWindow(display, | ||
| 195 | - window, | ||
| 196 | - 10, | ||
| 197 | - 10, | ||
| 198 | - 310, | ||
| 199 | - 310, | ||
| 200 | - 0, | ||
| 201 | - DefaultDepth(display, screen), | ||
| 202 | - InputOutput, | ||
| 203 | - DefaultVisual(display, screen), | ||
| 204 | - 0, | ||
| 205 | - nullptr); | ||
| 206 | - Window view2 = XCreateWindow(display, | ||
| 207 | - window, | ||
| 208 | - 330, | ||
| 209 | - 10, | ||
| 210 | - 310, | ||
| 211 | - 310, | ||
| 212 | - 0, | ||
| 213 | - DefaultDepth(display, screen), | ||
| 214 | - InputOutput, | ||
| 215 | - DefaultVisual(display, screen), | ||
| 216 | - 0, | ||
| 217 | - nullptr); | ||
| 194 | + const Window view1 = XCreateWindow(display, | ||
| 195 | + window, | ||
| 196 | + 10, | ||
| 197 | + 10, | ||
| 198 | + 310, | ||
| 199 | + 310, | ||
| 200 | + 0, | ||
| 201 | + DefaultDepth(display, screen), | ||
| 202 | + InputOutput, | ||
| 203 | + DefaultVisual(display, screen), | ||
| 204 | + 0, | ||
| 205 | + nullptr); | ||
| 206 | + const Window view2 = XCreateWindow(display, | ||
| 207 | + window, | ||
| 208 | + 330, | ||
| 209 | + 10, | ||
| 210 | + 310, | ||
| 211 | + 310, | ||
| 212 | + 0, | ||
| 213 | + DefaultDepth(display, screen), | ||
| 214 | + InputOutput, | ||
| 215 | + DefaultVisual(display, screen), | ||
| 216 | + 0, | ||
| 217 | + nullptr); | ||
| 218 | 218 | ||
| 219 | 219 | // Show our windows | |
| 220 | 220 | XMapWindow(display, window); | |
@@ -225,7 +225,7 @@ int main() | |||
| 225 | 225 | sf::Window sfmlView2(view2); | |
| 226 | 226 | ||
| 227 | 227 | // Create a clock for measuring elapsed time | |
| 228 | - sf::Clock clock; | ||
| 228 | + const sf::Clock clock; | ||
| 229 | 229 | ||
| 230 | 230 | // Load OpenGL or OpenGL ES entry points using glad | |
| 231 | 231 | if (!sfmlView1.setActive()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,8 +136,8 @@ void cleanup() | |||
| 136 | 136 | ||
| 137 | 137 | void drmFbDestroyCallback(gbm_bo* bo, void* data) | |
| 138 | 138 | { | |
| 139 | - int drmFd = gbm_device_get_fd(gbm_bo_get_device(bo)); | ||
| 140 | - auto* fb = static_cast<DrmFb*>(data); | ||
| 139 | + const int drmFd = gbm_device_get_fd(gbm_bo_get_device(bo)); | ||
| 140 | + auto* fb = static_cast<DrmFb*>(data); | ||
| 141 | 141 | ||
| 142 | 142 | if (fb->fbId) | |
| 143 | 143 | drmModeRmFB(drmFd, fb->fbId); | |
@@ -147,8 +147,8 @@ void drmFbDestroyCallback(gbm_bo* bo, void* data) | |||
| 147 | 147 | ||
| 148 | 148 | DrmFb* drmFbGetFromBo(gbm_bo& bo) | |
| 149 | 149 | { | |
| 150 | - int drmFd = gbm_device_get_fd(gbm_bo_get_device(&bo)); | ||
| 151 | - auto* fb = static_cast<DrmFb*>(gbm_bo_get_user_data(&bo)); | ||
| 150 | + const int drmFd = gbm_device_get_fd(gbm_bo_get_device(&bo)); | ||
| 151 | + auto* fb = static_cast<DrmFb*>(gbm_bo_get_user_data(&bo)); | ||
| 152 | 152 | if (fb) | |
| 153 | 153 | return fb; | |
| 154 | 154 | ||
@@ -549,7 +549,7 @@ DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, cons | |||
| 549 | 549 | // Create EGL context | |
| 550 | 550 | createContext(shared); | |
| 551 | 551 | ||
| 552 | - Vector2u size = owner.getSize(); | ||
| 552 | + const Vector2u size = owner.getSize(); | ||
| 553 | 553 | createSurface(size, bitsPerPixel, true); | |
| 554 | 554 | } | |
| 555 | 555 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,15 +117,15 @@ bool keepFileDescriptor(int fileDesc) | |||
| 117 | 117 | // This is the keyboard test used by SDL. | |
| 118 | 118 | // The first 32 bits are ESC, numbers and Q to D; If we have any of those, | |
| 119 | 119 | // consider it a keyboard device; do not test for KEY_RESERVED, though | |
| 120 | - bool isKeyboard = (bitmaskKey[0] & 0xFFFFFFFE); | ||
| 120 | + const bool isKeyboard = (bitmaskKey[0] & 0xFFFFFFFE); | ||
| 121 | 121 | ||
| 122 | - bool isAbs = TEST_BIT(EV_ABS, bitmaskEv) && TEST_BIT(ABS_X, bitmaskAbs) && TEST_BIT(ABS_Y, bitmaskAbs); | ||
| 122 | + const bool isAbs = TEST_BIT(EV_ABS, bitmaskEv) && TEST_BIT(ABS_X, bitmaskAbs) && TEST_BIT(ABS_Y, bitmaskAbs); | ||
| 123 | 123 | ||
| 124 | - bool isRel = TEST_BIT(EV_REL, bitmaskEv) && TEST_BIT(REL_X, bitmaskRel) && TEST_BIT(REL_Y, bitmaskRel); | ||
| 124 | + const bool isRel = TEST_BIT(EV_REL, bitmaskEv) && TEST_BIT(REL_X, bitmaskRel) && TEST_BIT(REL_Y, bitmaskRel); | ||
| 125 | 125 | ||
| 126 | - bool isMouse = (isAbs || isRel) && TEST_BIT(BTN_MOUSE, bitmaskKey); | ||
| 126 | + const bool isMouse = (isAbs || isRel) && TEST_BIT(BTN_MOUSE, bitmaskKey); | ||
| 127 | 127 | ||
| 128 | - bool isTouch = isAbs && (TEST_BIT(BTN_TOOL_FINGER, bitmaskKey) || TEST_BIT(BTN_TOUCH, bitmaskKey)); | ||
| 128 | + const bool isTouch = isAbs && (TEST_BIT(BTN_TOOL_FINGER, bitmaskKey) || TEST_BIT(BTN_TOUCH, bitmaskKey)); | ||
| 129 | 129 | ||
| 130 | 130 | return isKeyboard || isMouse || isTouch; | |
| 131 | 131 | } | |
@@ -145,7 +145,7 @@ void initFileDescriptors() | |||
| 145 | 145 | stream << i; | |
| 146 | 146 | name += stream.str(); | |
| 147 | 147 | ||
| 148 | - int tempFD = open(name.c_str(), O_RDONLY | O_NONBLOCK); | ||
| 148 | + const int tempFD = open(name.c_str(), O_RDONLY | O_NONBLOCK); | ||
| 149 | 149 | ||
| 150 | 150 | if (tempFD < 0) | |
| 151 | 151 | { | |
@@ -355,7 +355,7 @@ void processSlots() | |||
| 355 | 355 | ||
| 356 | 356 | bool eventProcess(sf::Event& event) | |
| 357 | 357 | { | |
| 358 | - std::lock_guard lock(inputMutex); | ||
| 358 | + const std::lock_guard lock(inputMutex); | ||
| 359 | 359 | ||
| 360 | 360 | // Ensure that we are initialized | |
| 361 | 361 | initFileDescriptors(); | |
@@ -383,7 +383,7 @@ bool eventProcess(sf::Event& event) | |||
| 383 | 383 | { | |
| 384 | 384 | if (inputEvent.type == EV_KEY) | |
| 385 | 385 | { | |
| 386 | - sf::Mouse::Button mb = toMouseButton(inputEvent.code); | ||
| 386 | + const sf::Mouse::Button mb = toMouseButton(inputEvent.code); | ||
| 387 | 387 | if (mb != sf::Mouse::ButtonCount) | |
| 388 | 388 | { | |
| 389 | 389 | event.type = inputEvent.value ? sf::Event::MouseButtonPressed : sf::Event::MouseButtonReleased; | |
@@ -396,7 +396,7 @@ bool eventProcess(sf::Event& event) | |||
| 396 | 396 | } | |
| 397 | 397 | else | |
| 398 | 398 | { | |
| 399 | - sf::Keyboard::Key kb = toKey(inputEvent.code); | ||
| 399 | + const sf::Keyboard::Key kb = toKey(inputEvent.code); | ||
| 400 | 400 | ||
| 401 | 401 | unsigned int special = 0; | |
| 402 | 402 | if ((kb == sf::Keyboard::Delete) || (kb == sf::Keyboard::Backspace)) | |
@@ -571,7 +571,7 @@ namespace sf::priv | |||
| 571 | 571 | //////////////////////////////////////////////////////////// | |
| 572 | 572 | bool InputImpl::isKeyPressed(Keyboard::Key key) | |
| 573 | 573 | { | |
| 574 | - std::lock_guard lock(inputMutex); | ||
| 574 | + const std::lock_guard lock(inputMutex); | ||
| 575 | 575 | if ((key < 0) || (key >= static_cast<int>(keyMap.size()))) | |
| 576 | 576 | return false; | |
| 577 | 577 | ||
@@ -625,7 +625,7 @@ void InputImpl::setVirtualKeyboardVisible(bool /*visible*/) | |||
| 625 | 625 | //////////////////////////////////////////////////////////// | |
| 626 | 626 | bool InputImpl::isMouseButtonPressed(Mouse::Button button) | |
| 627 | 627 | { | |
| 628 | - std::lock_guard lock(inputMutex); | ||
| 628 | + const std::lock_guard lock(inputMutex); | ||
| 629 | 629 | if ((button < 0) || (button >= static_cast<int>(mouseMap.size()))) | |
| 630 | 630 | return false; | |
| 631 | 631 | ||
@@ -637,7 +637,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button) | |||
| 637 | 637 | //////////////////////////////////////////////////////////// | |
| 638 | 638 | Vector2i InputImpl::getMousePosition() | |
| 639 | 639 | { | |
| 640 | - std::lock_guard lock(inputMutex); | ||
| 640 | + const std::lock_guard lock(inputMutex); | ||
| 641 | 641 | return mousePos; | |
| 642 | 642 | } | |
| 643 | 643 | ||
@@ -652,7 +652,7 @@ Vector2i InputImpl::getMousePosition(const WindowBase& /*relativeTo*/) | |||
| 652 | 652 | //////////////////////////////////////////////////////////// | |
| 653 | 653 | void InputImpl::setMousePosition(const Vector2i& position) | |
| 654 | 654 | { | |
| 655 | - std::lock_guard lock(inputMutex); | ||
| 655 | + const std::lock_guard lock(inputMutex); | ||
| 656 | 656 | mousePos = position; | |
| 657 | 657 | } | |
| 658 | 658 | ||
@@ -696,7 +696,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int finger, const WindowBase& /*re | |||
| 696 | 696 | //////////////////////////////////////////////////////////// | |
| 697 | 697 | bool InputImpl::checkEvent(sf::Event& event) | |
| 698 | 698 | { | |
| 699 | - std::lock_guard lock(inputMutex); | ||
| 699 | + const std::lock_guard lock(inputMutex); | ||
| 700 | 700 | if (!eventQueue.empty()) | |
| 701 | 701 | { | |
| 702 | 702 | event = eventQueue.front(); | |
@@ -730,7 +730,7 @@ bool InputImpl::checkEvent(sf::Event& event) | |||
| 730 | 730 | //////////////////////////////////////////////////////////// | |
| 731 | 731 | void InputImpl::setTerminalConfig() | |
| 732 | 732 | { | |
| 733 | - std::lock_guard lock(inputMutex); | ||
| 733 | + const std::lock_guard lock(inputMutex); | ||
| 734 | 734 | initFileDescriptors(); | |
| 735 | 735 | ||
| 736 | 736 | tcgetattr(STDIN_FILENO, &newTerminalConfig); // get current terminal config | |
@@ -747,7 +747,7 @@ void InputImpl::setTerminalConfig() | |||
| 747 | 747 | //////////////////////////////////////////////////////////// | |
| 748 | 748 | void InputImpl::restoreTerminalConfig() | |
| 749 | 749 | { | |
| 750 | - std::lock_guard lock(inputMutex); | ||
| 750 | + const std::lock_guard lock(inputMutex); | ||
| 751 | 751 | initFileDescriptors(); | |
| 752 | 752 | ||
| 753 | 753 | tcsetattr(STDIN_FILENO, TCSANOW, &oldTerminalConfig); // restore terminal config | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes() | |||
| 38 | 38 | { | |
| 39 | 39 | std::vector<VideoMode> modes; | |
| 40 | 40 | ||
| 41 | - Drm& drm = sf::priv::DRMContext::getDRM(); | ||
| 41 | + const Drm& drm = sf::priv::DRMContext::getDRM(); | ||
| 42 | 42 | drmModeConnectorPtr conn = drm.savedConnector; | |
| 43 | 43 | ||
| 44 | 44 | if (conn) | |
@@ -56,7 +56,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes() | |||
| 56 | 56 | //////////////////////////////////////////////////////////// | |
| 57 | 57 | VideoMode VideoModeImpl::getDesktopMode() | |
| 58 | 58 | { | |
| 59 | - Drm& drm = sf::priv::DRMContext::getDRM(); | ||
| 59 | + const Drm& drm = sf::priv::DRMContext::getDRM(); | ||
| 60 | 60 | drmModeModeInfoPtr ptr = drm.mode; | |
| 61 | 61 | if (ptr) | |
| 62 | 62 | return VideoMode({ptr->hdisplay, ptr->vdisplay}); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,7 @@ WindowImplDRM::~WindowImplDRM() | |||
| 61 | 61 | //////////////////////////////////////////////////////////// | |
| 62 | 62 | WindowHandle WindowImplDRM::getSystemHandle() const | |
| 63 | 63 | { | |
| 64 | - Drm& drm = sf::priv::DRMContext::getDRM(); | ||
| 64 | + const Drm& drm = sf::priv::DRMContext::getDRM(); | ||
| 65 | 65 | return static_cast<WindowHandle>(drm.fileDescriptor); | |
| 66 | 66 | } | |
| 67 | 67 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,7 @@ void eglCheckError(const std::filesystem::path& file, unsigned int line, std::st | |||
| 43 | 43 | { | |
| 44 | 44 | // Obtain information about the success or failure of the most recent EGL | |
| 45 | 45 | // function called in the current thread | |
| 46 | - EGLint errorCode = eglGetError(); | ||
| 46 | + const EGLint errorCode = eglGetError(); | ||
| 47 | 47 | ||
| 48 | 48 | if (errorCode != EGL_SUCCESS) | |
| 49 | 49 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -138,7 +138,7 @@ String ClipboardImpl::getStringImpl() | |||
| 138 | 138 | // if UTF-8 is not available) and written to our window property | |
| 139 | 139 | XConvertSelection(m_display, m_clipboard, (m_utf8String != None) ? m_utf8String : XA_STRING, m_targetProperty, m_window, CurrentTime); | |
| 140 | 140 | ||
| 141 | - Clock clock; | ||
| 141 | + const Clock clock; | ||
| 142 | 142 | ||
| 143 | 143 | // Wait for a response for up to 1000ms | |
| 144 | 144 | while (!m_requestResponded && (clock.getElapsedTime().asMilliseconds() < 1000)) | |
@@ -204,7 +204,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent) | |||
| 204 | 204 | // Notification that the current selection owner | |
| 205 | 205 | // has responded to our request | |
| 206 | 206 | ||
| 207 | - XSelectionEvent& selectionEvent = windowEvent.xselection; | ||
| 207 | + const XSelectionEvent& selectionEvent = windowEvent.xselection; | ||
| 208 | 208 | ||
| 209 | 209 | m_clipboardContents.clear(); | |
| 210 | 210 | ||
@@ -222,18 +222,18 @@ void ClipboardImpl::processEvent(XEvent& windowEvent) | |||
| 222 | 222 | ||
| 223 | 223 | // The selection owner should have wrote the selection | |
| 224 | 224 | // data to the specified window property | |
| 225 | - int result = XGetWindowProperty(m_display, | ||
| 226 | - m_window, | ||
| 227 | - m_targetProperty, | ||
| 228 | - 0, | ||
| 229 | - 0x7fffffff, | ||
| 230 | - False, | ||
| 231 | - AnyPropertyType, | ||
| 232 | - &type, | ||
| 233 | - &format, | ||
| 234 | - &items, | ||
| 235 | - &remainingBytes, | ||
| 236 | - &data); | ||
| 225 | + const int result = XGetWindowProperty(m_display, | ||
| 226 | + m_window, | ||
| 227 | + m_targetProperty, | ||
| 228 | + 0, | ||
| 229 | + 0x7fffffff, | ||
| 230 | + False, | ||
| 231 | + AnyPropertyType, | ||
| 232 | + &type, | ||
| 233 | + &format, | ||
| 234 | + &items, | ||
| 235 | + &remainingBytes, | ||
| 236 | + &data); | ||
| 237 | 237 | ||
| 238 | 238 | if (result == Success) | |
| 239 | 239 | { | |
@@ -267,7 +267,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent) | |||
| 267 | 267 | case SelectionRequest: | |
| 268 | 268 | { | |
| 269 | 269 | // Respond to a request for our clipboard contents | |
| 270 | - XSelectionRequestEvent& selectionRequestEvent = windowEvent.xselectionrequest; | ||
| 270 | + const XSelectionRequestEvent& selectionRequestEvent = windowEvent.xselectionrequest; | ||
| 271 | 271 | ||
| 272 | 272 | // Our reply | |
| 273 | 273 | XSelectionEvent selectionEvent; | |
@@ -316,7 +316,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent) | |||
| 316 | 316 | ((m_utf8String == None) && (selectionRequestEvent.target == m_text))) | |
| 317 | 317 | { | |
| 318 | 318 | // Respond to a request for conversion to a Latin-1 string | |
| 319 | - std::string data = m_clipboardContents.toAnsiString(); | ||
| 319 | + const std::string data = m_clipboardContents.toAnsiString(); | ||
| 320 | 320 | ||
| 321 | 321 | XChangeProperty(m_display, | |
| 322 | 322 | selectionRequestEvent.requestor, | |
@@ -343,7 +343,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent) | |||
| 343 | 343 | { | |
| 344 | 344 | // Respond to a request for conversion to a UTF-8 string | |
| 345 | 345 | // or an encoding of our choosing (we always choose UTF-8) | |
| 346 | - std::basic_string<std::uint8_t> data = m_clipboardContents.toUtf8(); | ||
| 346 | + const std::basic_string<std::uint8_t> data = m_clipboardContents.toUtf8(); | ||
| 347 | 347 | ||
| 348 | 348 | XChangeProperty(m_display, | |
| 349 | 349 | selectionRequestEvent.requestor, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments