New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL2 color cursors are offset on OS X #1966
Milestone
Comments
Updated test program, draws a green box that is centered on the cursor's hotspot. // Test for color cursor behavior on OS X
#include "SDL.h"
#include <stdio.h>
// 8x8 red sprite for test cursor
unsigned int pixels[] = {
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000,
0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000
};
int main(int argc, char* argv[]) {
SDL_Window *window;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"SDL2 Color Cursor Test",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
150,
100,
SDL_WINDOW_OPENGL
);
if (window == NULL) {
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (renderer == NULL) {
printf("Could not create renderer: %s\n", SDL_GetError());
return 1;
}
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, 8, 8, 32, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
if (surface == NULL) {
printf("Could not create surface: %s\n", SDL_GetError());
return 1;
}
// Hotspot of (3,3) here "fixes" the bug on OS X
SDL_Cursor* cursor = SDL_CreateColorCursor(surface, 0, 0);
if (cursor == NULL) {
printf("Could not create cursor: %s\n", SDL_GetError());
return 1;
}
SDL_SetCursor(cursor);
while (1) {
SDL_Event event;
SDL_Rect r;
if (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT)
break;
else if (event.type == SDL_WINDOWEVENT) {
switch (event.window.event) {
case SDL_WINDOWEVENT_ENTER:
printf("Mouse entered window %d\n",
event.window.windowID);
break;
case SDL_WINDOWEVENT_LEAVE:
printf("Mouse left window %d\n", event.window.windowID);
break;
default:
break;
}
}
}
SDL_GetMouseState(&r.x, &r.y);
r.w = r.h = 6;
r.x -= r.w / 2;
r.y -= r.h / 2;
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
SDL_RenderFillRect(renderer, &r);
SDL_RenderPresent(renderer);
}
SDL_FreeCursor(cursor);
SDL_FreeSurface(surface);
SDL_DestroyWindow(window);
SDL_DestroyRenderer(renderer);
SDL_Quit();
return 0;
} |
Tested with non-zero hotspot coords and it works, too. This clearly got fixed at some point. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: HG 2.0
Reported for operating system, platform: Mac OS X (All), x86_64
Comments on the original bug report:
On 2015-09-06 19:59:07 +0000, historic_bruno wrote:
On 2015-09-06 20:01:58 +0000, historic_bruno wrote:
The text was updated successfully, but these errors were encountered: