Fix mouse in full-screen scrolling on edge of monitor

This commit is contained in:
Krzosa Karol
2024-08-03 08:21:25 +02:00
parent a42a4e435d
commit d382735b80
3 changed files with 25 additions and 10 deletions

View File

@@ -585,10 +585,22 @@ void WindowCommand(Event event, Window *window, View *view) {
{
Vec2 mouse_vec2 = MouseVec2();
Vec2I mouse = MouseVec2I();
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
bool mouse_in_scrollbar = CheckCollisionPointRec(mouse, window->scrollbar_rect);
Vec2 mouse_vec2 = MouseVec2();
Vec2I mouse = MouseVec2I();
// Special case for full-screen where we can have document
// aligned with monitor screen in which case mouse cursor cannot
// be smaller then 0 which means we cannot scroll
if (mouse.y == 0 && window->document_rect.min.y == 0) {
float x, y;
SDL_GetGlobalMouseState(&x, &y);
if (y == 0) {
mouse.y = -10;
}
}
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
bool mouse_in_scrollbar = CheckCollisionPointRec(mouse, window->scrollbar_rect);
bool scrollbar_action = mouse_in_scrollbar || window->mouse_selecting_scrollbar;
bool document_action = false;

View File

@@ -39,12 +39,16 @@ void ReplaceDebugData() {
String16 string = ToString16(scratch, s);
ReplaceText(buffer, GetRange(*buffer), string);
String view_list = DebugViewList(scratch);
Append(buffer, ToString16(scratch, view_list));
Append(buffer, L"\n");
float xmouse, ymouse;
SDL_GetMouseState(&xmouse, &ymouse);
Appendf(buffer, "mouse: [%f, %f]", xmouse, ymouse);
String window_list = DebugWindowList(scratch);
Append(buffer, ToString16(scratch, window_list));
// String view_list = DebugViewList(scratch);
// Append(buffer, ToString16(scratch, view_list));
// Append(buffer, L"\n");
// String window_list = DebugWindowList(scratch);
// Append(buffer, ToString16(scratch, window_list));
}
void ApplyTitleBarChangesToWindow(Window *window, View *view, Buffer *buffer) {

View File

@@ -2,7 +2,6 @@
- scrolling in fullscreen is busted because no space outside of window
- scrolling when clicking on scroller is busted
- page up and down should also scroll and leave you in exactly same scroll
- something about mouse stuff is busted and it randomly does big selections and stuff like that
- I think the way sublime text and we display line highlights is confusing with multiple cursors (line highlight can be confused with selection)
- don't trim lines with cursor or selection on it