diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index d3a9dc36..d206b712 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -6,18 +6,19 @@ namespace rack { void RackScrollWidget::step() { - Vec pos = gRackWidget->lastMousePos; + Vec pos = gMousePos; + Rect viewport = getViewport(box.zeroPos()); // Scroll rack if dragging cable near the edge of the screen if (gRackWidget->wireContainer->activeWire) { float margin = 20.0; float speed = 15.0; - if (pos.x <= margin) + if (pos.x <= viewport.pos.x + margin) offset.x -= speed; - if (pos.x >= box.size.x - margin) + if (pos.x >= viewport.pos.x + viewport.size.x - margin) offset.x += speed; - if (pos.y <= margin) + if (pos.y <= viewport.pos.y + margin) offset.y -= speed; - if (pos.y >= box.size.y - margin) + if (pos.y >= viewport.pos.y + viewport.size.y - margin) offset.y += speed; } ScrollWidget::step(); diff --git a/src/gui.cpp b/src/gui.cpp index bb859f2a..01de9ab1 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -36,6 +36,8 @@ bool gAllowCursorLock = true; int gGuiFrame; Vec gMousePos; +std::string lastWindowTitle; + void windowSizeCallback(GLFWwindow* window, int width, int height) { gScene->box.size = Vec(width, height); @@ -252,7 +254,8 @@ void guiInit() { // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); - gWindow = glfwCreateWindow(640, 480, "", NULL, NULL); + lastWindowTitle = ""; + gWindow = glfwCreateWindow(640, 480, lastWindowTitle.c_str(), NULL, NULL); if (!gWindow) { osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Cannot open window with OpenGL 2.0 renderer. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); exit(1); @@ -328,15 +331,18 @@ void guiRun() { mouseButtonStickyPop(); // Set window title - std::string title = gApplicationName; + std::string windowTitle = gApplicationName; if (!gApplicationVersion.empty()) { - title += " v" + gApplicationVersion; + windowTitle += " v" + gApplicationVersion; } if (!gRackWidget->lastPath.empty()) { - title += " - "; - title += extractFilename(gRackWidget->lastPath); + windowTitle += " - "; + windowTitle += extractFilename(gRackWidget->lastPath); + } + if (windowTitle != lastWindowTitle) { + glfwSetWindowTitle(gWindow, windowTitle.c_str()); + lastWindowTitle = windowTitle; } - glfwSetWindowTitle(gWindow, title.c_str()); // Get framebuffer size int width, height;