summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2008-12-07 21:53:28 +0000
committerSam Lantinga <slouken@libsdl.org>2008-12-07 21:53:28 +0000
commitd7b138d966ed7d3a87f4278f0346c319d631d4c4 (patch)
treece20dcf966e0c797115f2cfa2fe467ac24e48be5 /src
parent327d037f8cef98483da3816e7597fe3903f2b43b (diff)
There's no reason to add extra code to notify the mice of window size changes.
Just query the window size when we care about it. :)
Diffstat (limited to 'src')
-rw-r--r--src/events/SDL_mouse.c27
-rw-r--r--src/events/SDL_mouse_c.h7
-rw-r--r--src/events/SDL_windowevents.c1
-rw-r--r--src/video/SDL_video.c21
4 files changed, 24 insertions, 32 deletions
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 4458034405..0db9a44de8 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -364,21 +364,6 @@ SDL_SetMouseFocus(int id, SDL_WindowID windowID)
if (!focus) {
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
}
- SDL_GetWindowSize(windowID, &mouse->x_max, &mouse->y_max);
- }
-}
-
-void
-SDL_SetMouseFocusSize(SDL_WindowID windowID, int w, int h)
-{
- int i;
-
- for (i = 0; i < SDL_num_mice; ++i) {
- SDL_Mouse *mouse = SDL_GetMouse(i);
- if (mouse && mouse->focus == windowID) {
- mouse->x_max = w;
- mouse->y_max = h;
- }
}
}
@@ -458,15 +443,19 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
} else {
/* while using the relative mode and many windows, we have to be
sure that the pointers find themselves inside the windows */
- if (mouse->x + xrel > mouse->x_max) {
- mouse->x = mouse->x_max;
+ int x_max, y_max;
+
+ SDL_GetWindowSize(mouse->focus, &x_max, &y_max);
+
+ if (mouse->x + xrel > x_max) {
+ mouse->x = x_max;
} else if (mouse->x + xrel < 0) {
mouse->x = 0;
} else {
mouse->x += xrel;
}
- if (mouse->y + yrel > mouse->y_max) {
- mouse->y = mouse->y_max;
+ if (mouse->y + yrel > y_max) {
+ mouse->y = y_max;
} else if (mouse->y + yrel < 0) {
mouse->y = 0;
} else {
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index 640e64a660..efe1349389 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -66,8 +66,8 @@ struct SDL_Mouse
/* Data common to all mice */
SDL_WindowID focus;
int which;
- int x, x_max;
- int y, y_max;
+ int x;
+ int y;
int z; /* for future use */
int xdelta;
int ydelta;
@@ -112,9 +112,6 @@ extern void SDL_ResetMouse(int index);
/* Set the mouse focus window */
extern void SDL_SetMouseFocus(int id, SDL_WindowID windowID);
-/* Set the size of the mouse focus window */
-extern void SDL_SetMouseFocusSize(SDL_WindowID windowID, int w, int h);
-
/* Send a mouse motion event for a mouse */
extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z);
diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c
index 7b131bbee5..a4ffad2942 100644
--- a/src/events/SDL_windowevents.c
+++ b/src/events/SDL_windowevents.c
@@ -74,7 +74,6 @@ SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
window->w = data1;
window->h = data2;
SDL_OnWindowResized(window);
- SDL_SetMouseFocusSize(windowID, window->w, window->h);
break;
case SDL_WINDOWEVENT_MINIMIZED:
if (window->flags & SDL_WINDOW_MINIMIZED) {
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 36431bced7..0d35bb2caa 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1046,6 +1046,7 @@ SDL_SetWindowSize(SDL_WindowID windowID, int w, int h)
if (_this->SetWindowSize) {
_this->SetWindowSize(_this, window);
}
+ SDL_OnWindowResized(window);
}
void
@@ -1054,13 +1055,19 @@ SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h)
SDL_Window *window = SDL_GetWindowFromID(windowID);
if (!window) {
- return;
- }
- if (w) {
- *w = window->w;
- }
- if (h) {
- *h = window->h;
+ if (w) {
+ *w = window->w;
+ }
+ if (h) {
+ *h = window->h;
+ }
+ } else {
+ if (w) {
+ *w = 0;
+ }
+ if (h) {
+ *h = 0;
+ }
}
}