mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Change Cursor_SetScreenPos to Cursor_SetPosition which takes window coords, and remove Cursor_GetScreenPos
This commit is contained in:
parent
6646b10059
commit
8f36382eb6
@ -542,10 +542,9 @@ static void TableWidget_MoveCursorToSelected(struct TableWidget* w) {
|
|||||||
|
|
||||||
idx = w->selectedIndex;
|
idx = w->selectedIndex;
|
||||||
TableWidget_GetCoords(w, idx, &x, &y);
|
TableWidget_GetCoords(w, idx, &x, &y);
|
||||||
x += w->cellSize / 2; y += w->cellSize / 2;
|
|
||||||
|
|
||||||
x += Window_X; y += Window_Y;
|
x += w->cellSize / 2; y += w->cellSize / 2;
|
||||||
Cursor_SetScreenPos(x, y);
|
Cursor_SetPosition(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TableWidget_MakeBlockDesc(String* desc, BlockID block) {
|
static void TableWidget_MakeBlockDesc(String* desc, BlockID block) {
|
||||||
|
35
src/Window.c
35
src/Window.c
@ -32,11 +32,11 @@ void Clipboard_RequestText(RequestClipboardCallback callback, void* obj) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Point2D cursorPrev;
|
static Point2D cursorPrev;
|
||||||
static void Window_CentreMousePosition(void) {
|
/* Gets the position of the cursor in screen coordinates. */
|
||||||
int cenX = Window_X + Window_Width / 2;
|
static Point2D Cursor_GetScreenPos(void);
|
||||||
int cenY = Window_Y + Window_Height / 2;
|
|
||||||
|
|
||||||
Cursor_SetScreenPos(cenX, cenY);
|
static void Window_CentreMousePosition(void) {
|
||||||
|
Cursor_SetPosition(Window_Width / 2, Window_Height / 2);
|
||||||
/* Fixes issues with large DPI displays on Windows >= 8.0. */
|
/* Fixes issues with large DPI displays on Windows >= 8.0. */
|
||||||
cursorPrev = Cursor_GetScreenPos();
|
cursorPrev = Cursor_GetScreenPos();
|
||||||
}
|
}
|
||||||
@ -546,8 +546,10 @@ Point2D Cursor_GetScreenPos(void) {
|
|||||||
POINT point; GetCursorPos(&point);
|
POINT point; GetCursorPos(&point);
|
||||||
Point2D p = { point.x, point.y }; return p;
|
Point2D p = { point.x, point.y }; return p;
|
||||||
}
|
}
|
||||||
void Cursor_SetScreenPos(int x, int y) { SetCursorPos(x, y); }
|
void Cursor_SetPosition(int x, int y) {
|
||||||
void Cursor_SetVisible(bool visible) { ShowCursor(visible ? 1 : 0); }
|
SetCursorPos(x + Window_X, y + Window_Y);
|
||||||
|
}
|
||||||
|
void Cursor_SetVisible(bool visible) { ShowCursor(visible); }
|
||||||
|
|
||||||
void Window_ShowDialog(const char* title, const char* msg) {
|
void Window_ShowDialog(const char* title, const char* msg) {
|
||||||
MessageBoxA(win_handle, msg, title, 0);
|
MessageBoxA(win_handle, msg, title, 0);
|
||||||
@ -819,7 +821,7 @@ void Window_Create(int width, int height) {
|
|||||||
KeyReleaseMask | KeyPressMask | KeymapStateMask | PointerMotionMask |
|
KeyReleaseMask | KeyPressMask | KeymapStateMask | PointerMotionMask |
|
||||||
FocusChangeMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
FocusChangeMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
||||||
LeaveWindowMask | PropertyChangeMask;
|
LeaveWindowMask | PropertyChangeMask;
|
||||||
win_visual = GLContext_SelectVisual(mode);
|
win_visual = GLContext_SelectVisual(&mode);
|
||||||
|
|
||||||
Platform_LogConst("Opening render window... ");
|
Platform_LogConst("Opening render window... ");
|
||||||
attributes.colormap = XCreateColormap(win_display, win_rootWin, win_visual.visual, AllocNone);
|
attributes.colormap = XCreateColormap(win_display, win_rootWin, win_visual.visual, AllocNone);
|
||||||
@ -1168,8 +1170,8 @@ Point2D Cursor_GetScreenPos(void) {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetScreenPos(int x, int y) {
|
void Cursor_SetPosition(int x, int y) {
|
||||||
XWarpPointer(win_display, None, win_rootWin, 0, 0, 0, 0, x, y);
|
XWarpPointer(win_display, None, win_rootWin, 0,0, 0,0, x + Window_X, y + Window_Y);
|
||||||
XFlush(win_display); /* TODO: not sure if XFlush call is necessary */
|
XFlush(win_display); /* TODO: not sure if XFlush call is necessary */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1921,9 +1923,10 @@ Point2D Cursor_GetScreenPos(void) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetScreenPos(int x, int y) {
|
void Cursor_SetPosition(int x, int y) {
|
||||||
CGPoint point;
|
CGPoint point;
|
||||||
point.x = x; point.y = y;
|
point.x = x + Window_X;
|
||||||
|
point.y = y + Window_Y;
|
||||||
|
|
||||||
CGAssociateMouseAndMouseCursorPosition(0);
|
CGAssociateMouseAndMouseCursorPosition(0);
|
||||||
CGDisplayMoveCursorToPoint(CGMainDisplayID(), point);
|
CGDisplayMoveCursorToPoint(CGMainDisplayID(), point);
|
||||||
@ -2278,10 +2281,8 @@ Point2D Cursor_GetScreenPos(void) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetScreenPos(int x, int y) {
|
void Cursor_SetPosition(int x, int y) {
|
||||||
SDL_WarpMouseGlobal(x, y);
|
SDL_WarpMouseInWindow(win_handle, x, y);
|
||||||
//x -= Window_X; y -= Window_Y;
|
|
||||||
//SDL_WarpMouseInWindow(win_handle, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetVisible(bool visible) {
|
void Cursor_SetVisible(bool visible) {
|
||||||
@ -2739,7 +2740,7 @@ void Window_ProcessEvents(void) { }
|
|||||||
/* Not supported (or even used internally) */
|
/* Not supported (or even used internally) */
|
||||||
Point2D Cursor_GetScreenPos(void) { Point2D p = { 0,0 }; return p; }
|
Point2D Cursor_GetScreenPos(void) { Point2D p = { 0,0 }; return p; }
|
||||||
/* Not allowed to move cursor from javascript */
|
/* Not allowed to move cursor from javascript */
|
||||||
void Cursor_SetScreenPos(int x, int y) { }
|
void Cursor_SetPosition(int x, int y) { Mouse_X = x; Mouse_Y = y; }
|
||||||
|
|
||||||
void Cursor_SetVisible(bool visible) {
|
void Cursor_SetVisible(bool visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
@ -3048,7 +3049,7 @@ void Window_ProcessEvents(void) {
|
|||||||
Point2D Cursor_GetScreenPos(void) {
|
Point2D Cursor_GetScreenPos(void) {
|
||||||
Point2D p; p.X = Mouse_X; p.Y = Mouse_Y; return p;
|
Point2D p; p.X = Mouse_X; p.Y = Mouse_Y; return p;
|
||||||
}
|
}
|
||||||
void Cursor_SetScreenPos(int x, int y) { Mouse_X = x; Mouse_Y = y; }
|
void Cursor_SetPosition(int x, int y) { Mouse_X = x; Mouse_Y = y; }
|
||||||
void Cursor_SetVisible(bool visible) { }
|
void Cursor_SetVisible(bool visible) { }
|
||||||
|
|
||||||
void Window_ShowDialog(const char* title, const char* msg) {
|
void Window_ShowDialog(const char* title, const char* msg) {
|
||||||
|
@ -103,10 +103,8 @@ void Window_Close(void);
|
|||||||
/* Processes all pending window messages/events. */
|
/* Processes all pending window messages/events. */
|
||||||
void Window_ProcessEvents(void);
|
void Window_ProcessEvents(void);
|
||||||
|
|
||||||
/* Gets the position of the cursor in screen coordinates. */
|
/* Sets the position of the cursor. */
|
||||||
Point2D Cursor_GetScreenPos(void);
|
void Cursor_SetPosition(int x, int y);
|
||||||
/* Sets the position of the cursor in screen coordinates. */
|
|
||||||
void Cursor_SetScreenPos(int x, int y);
|
|
||||||
/* Sets whether the cursor is visible when over this window. */
|
/* Sets whether the cursor is visible when over this window. */
|
||||||
/* NOTE: You MUST BE VERY CAREFUL with this! OS typically uses a counter for visibility,
|
/* NOTE: You MUST BE VERY CAREFUL with this! OS typically uses a counter for visibility,
|
||||||
so setting invisible multiple times means you must then set visible multiple times. */
|
so setting invisible multiple times means you must then set visible multiple times. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user