diff --git a/Makefile b/Makefile index 8a304d511..b45266197 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ endif endif # change to sdl-console to build a console version on Windows -SDL_PCNAME:=sdl +SDL_PCNAME:=sdl2 WINDRES:=windres PKG_CONFIG:=pkg-config @@ -180,15 +180,15 @@ CURSOR_SHAPES:=LARGE # CURSOR_SHAPES:=SMALL # Libraries, paths, and flags: -SDL_LIBS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL_image -lSDL_ttf -lz $(PNG) +SDL_LIBS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf -lz $(PNG) # Sound support -SDL_MIXER_LIB:=$(call linktest,-lSDL_mixer,$(SDL_LIBS)) -NOSOUNDFLAG:=$(if $(SDL_MIXER_LIB),,-DNOSOUND$(warning -lSDL_Mixer failed, no sound for you!)) +SDL_MIXER_LIB:=$(call linktest,-lSDL2_mixer,$(SDL_LIBS)) +NOSOUNDFLAG:=$(if $(SDL_MIXER_LIB),,-DNOSOUND$(warning -lSDL2_Mixer failed, no sound for you!)) # SDL Pango is needed to render complex scripts like Thai and Arabic -SDL_PANGO_LIB:=$(call linktest,-lSDL_Pango,$(SDL_LIBS)) -NOPANGOFLAG:=$(if $(SDL_PANGO_LIB),,-DNO_SDLPANGO$(warning -lSDL_Pango failed, no scripts for you!)) +SDL_PANGO_LIB:=$(call linktest,-lSDL2_Pango,$(SDL_LIBS)) +NOPANGOFLAG:=$(if $(SDL_PANGO_LIB),,-DNO_SDLPANGO$(warning -lSDL2_Pango failed, no scripts for you!)) SDL_LIBS+=$(SDL_MIXER_LIB) $(SDL_PANGO_LIB) @@ -981,7 +981,7 @@ install-man: tuxpaint: obj/tuxpaint.o obj/i18n.o obj/im.o obj/cursor.o obj/pixels.o \ obj/rgblinear.o obj/playsound.o obj/fonts.o obj/parse.o \ - obj/progressbar.o obj/dirwalk.o obj/get_fname.o obj/onscreen_keyboard.o \ + obj/progressbar.o obj/dirwalk.o obj/get_fname.o obj/onscreen_keyboard.o\ $(ARCH_LIBS) @echo @echo "...Linking Tux Paint..." diff --git a/src/im.c b/src/im.c index ba942660c..5ff1232fb 100644 --- a/src/im.c +++ b/src/im.c @@ -136,7 +136,7 @@ enum { /** * All im_event_*() functions have this type. */ -typedef int (*IM_EVENT_FN)(IM_DATA*, SDL_keysym); /* IM_EVENT_FN type */ +typedef int (*IM_EVENT_FN)(IM_DATA*, SDL_Event); /* IM_EVENT_FN type */ /** @@ -663,8 +663,10 @@ static const wchar_t* charmap_search(CHARMAP* cm, wchar_t* s) * * @see im_read */ -static int im_event_c(IM_DATA* im, SDL_keysym ks) +static int im_event_c(IM_DATA* im, SDL_Event event) { + SDL_Keysym ks = event.key.keysym; + /* Handle event requests */ im->s[0] = L'\0'; if(im->request != IM_REQ_TRANSLATE) return 0; @@ -674,7 +676,7 @@ static int im_event_c(IM_DATA* im, SDL_keysym ks) case SDLK_BACKSPACE: im->s[0] = L'\b'; break; case SDLK_TAB: im->s[0] = L'\t'; break; case SDLK_RETURN: im->s[0] = L'\r'; break; - default: im->s[0] = ks.unicode; + default: im->s[0] = event.text.text[0]; } im->s[1] = L'\0'; im->buf[0] = L'\0'; @@ -702,8 +704,10 @@ static int im_event_c(IM_DATA* im, SDL_keysym ks) * @see im_event_c() * @see im_event_fns */ -int im_read(IM_DATA* im, SDL_keysym ks) +int im_read(IM_DATA* im, SDL_Event event) { + SDL_Keysym ks = event.key.keysym; + IM_EVENT_FN im_event_fp = NULL; int redraw = 0; @@ -717,8 +721,8 @@ int im_read(IM_DATA* im, SDL_keysym ks) im_event_fp = im_event_fns[im->lang]; /* Run the language-specific IM or run the default C IM */ - if(im_event_fp) redraw = (*im_event_fp)(im, ks); - else redraw = im_event_c(im, ks); + if(im_event_fp) redraw = (*im_event_fp)(im, event); + else redraw = im_event_c(im, event); #ifdef IM_DEBUG wprintf(L"* [%8ls] [%8ls] %2d %2d (%2d)\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf), im->redraw); @@ -737,12 +741,12 @@ int im_read(IM_DATA* im, SDL_keysym ks) */ static void im_event(IM_DATA* im) { - SDL_keysym ks; + SDL_Event event; - ks.sym = 0; - ks.unicode = 0; + // event.key.keysym = 0; + event.text.text[0] = '\0'; - im_read(im, ks); + im_read(im, event); } @@ -787,6 +791,11 @@ static void im_fullreset(IM_DATA* im) } + + + + + /* *************************************************************************** * LANGUAGE-SPECIFIC IM FUNCTIONS * @@ -828,8 +837,9 @@ static void im_fullreset(IM_DATA* im) * * @see im_read */ -static int im_event_zh_tw(IM_DATA* im, SDL_keysym ks) +static int im_event_zh_tw(IM_DATA* im, SDL_Event event) { + SDL_Keysym ks = event.key.keysym; static const char* lang_file = IMDIR "zh_tw.im"; enum { SEC_ENGLISH, SEC_ZH_TW, SEC_TOTAL }; @@ -865,7 +875,7 @@ static int im_event_zh_tw(IM_DATA* im, SDL_keysym ks) if(charmap_load(&cm, lang_file)) { fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; - return im_event_c(im, ks); + return im_event_c(im, event); } im_fullreset(im); @@ -886,12 +896,12 @@ static int im_event_zh_tw(IM_DATA* im, SDL_keysym ks) /* Handle keys */ switch(ks.sym) { /* Keys to ignore */ - case SDLK_NUMLOCK: case SDLK_CAPSLOCK: case SDLK_SCROLLOCK: + case SDLK_NUMLOCKCLEAR: case SDLK_CAPSLOCK: case SDLK_SCROLLLOCK: case SDLK_LSHIFT: case SDLK_RSHIFT: case SDLK_LCTRL: case SDLK_RCTRL: - case SDLK_LMETA: case SDLK_RMETA: - case SDLK_LSUPER: case SDLK_RSUPER: - case SDLK_MODE: case SDLK_COMPOSE: + case SDLK_LGUI: case SDLK_RGUI: + case SDLK_MENU: + case SDLK_MODE: case SDLK_APPLICATION: break; /* Left-Alt & Right-Alt mapped to mode-switch */ @@ -920,13 +930,13 @@ static int im_event_zh_tw(IM_DATA* im, SDL_keysym ks) default: /* English mode */ if(cm.section == SEC_ENGLISH) { - im->s[0] = ks.unicode; + im->s[0] = event.text.text[0]; im->s[1] = L'\0'; im->buf[0] = L'\0'; } /* Thai mode */ else { - wchar_t u = ks.unicode; + wchar_t u = event.text.text[0]; im->s[0] = L'\0'; /* Zero-out output string */ wcsncat(im->buf, &u, 1); /* Copy new character */ @@ -1013,8 +1023,9 @@ static int im_event_zh_tw(IM_DATA* im, SDL_keysym ks) * * @see im_read */ -static int im_event_th(IM_DATA* im, SDL_keysym ks) +static int im_event_th(IM_DATA* im, SDL_Event event) { + SDL_Keysym ks = event.key.keysym; static const char* lang_file = IMDIR "th.im"; enum { SEC_ENGLISH, SEC_THAI, SEC_TOTAL }; @@ -1050,7 +1061,7 @@ static int im_event_th(IM_DATA* im, SDL_keysym ks) if(charmap_load(&cm, lang_file)) { fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; - return im_event_c(im, ks); + return im_event_c(im, event); } im_fullreset(im); @@ -1071,13 +1082,13 @@ static int im_event_th(IM_DATA* im, SDL_keysym ks) /* Handle keys */ switch(ks.sym) { /* Keys to ignore */ - case SDLK_NUMLOCK: case SDLK_CAPSLOCK: case SDLK_SCROLLOCK: + case SDLK_NUMLOCKCLEAR: case SDLK_CAPSLOCK: case SDLK_SCROLLLOCK: case SDLK_LSHIFT: case SDLK_RSHIFT: case SDLK_LCTRL: case SDLK_RCTRL: case SDLK_LALT: - case SDLK_LMETA: case SDLK_RMETA: - case SDLK_LSUPER: case SDLK_RSUPER: - case SDLK_MODE: case SDLK_COMPOSE: + case SDLK_LGUI: case SDLK_RGUI: + case SDLK_MENU: + case SDLK_MODE: case SDLK_APPLICATION: break; /* Right-Alt mapped to mode-switch */ @@ -1106,13 +1117,13 @@ static int im_event_th(IM_DATA* im, SDL_keysym ks) default: /* English mode */ if(cm.section == SEC_ENGLISH) { - im->s[0] = ks.unicode; + im->s[0] = event.text.text[0]; im->s[1] = L'\0'; im->buf[0] = L'\0'; } /* Thai mode */ else { - wchar_t u = ks.unicode; + wchar_t u = event.text.text[0]; im->s[0] = L'\0'; /* Zero-out output string */ wcsncat(im->buf, &u, 1); /* Copy new character */ @@ -1199,8 +1210,9 @@ static int im_event_th(IM_DATA* im, SDL_keysym ks) * * @see im_read */ -static int im_event_ja(IM_DATA* im, SDL_keysym ks) +static int im_event_ja(IM_DATA* im, SDL_Event event) { + SDL_Keysym ks = event.key.keysym; static const char* lang_file = IMDIR "ja.im"; enum { SEC_ENGLISH, SEC_HIRAGANA, SEC_KATAKANA, SEC_TOTAL }; @@ -1236,7 +1248,7 @@ static int im_event_ja(IM_DATA* im, SDL_keysym ks) if(charmap_load(&cm, lang_file)) { fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; - return im_event_c(im, ks); + return im_event_c(im, event); } im_fullreset(im); @@ -1257,13 +1269,13 @@ static int im_event_ja(IM_DATA* im, SDL_keysym ks) /* Handle keys */ switch(ks.sym) { /* Keys to ignore */ - case SDLK_NUMLOCK: case SDLK_CAPSLOCK: case SDLK_SCROLLOCK: + case SDLK_NUMLOCKCLEAR: case SDLK_CAPSLOCK: case SDLK_SCROLLLOCK: case SDLK_LSHIFT: case SDLK_RSHIFT: case SDLK_LCTRL: case SDLK_RCTRL: case SDLK_LALT: - case SDLK_LMETA: case SDLK_RMETA: - case SDLK_LSUPER: case SDLK_RSUPER: - case SDLK_MODE: case SDLK_COMPOSE: + case SDLK_LGUI: case SDLK_RGUI: + case SDLK_MENU: + case SDLK_MODE: case SDLK_APPLICATION: break; /* Right-Alt mapped to mode-switch */ @@ -1293,13 +1305,13 @@ static int im_event_ja(IM_DATA* im, SDL_keysym ks) default: /* English mode */ if(cm.section == SEC_ENGLISH) { - im->s[0] = ks.unicode; + im->s[0] = event.text.text[0]; im->s[1] = L'\0'; im->buf[0] = L'\0'; } /* Hiragana and Katakana modes */ else { - wchar_t u = ks.unicode; + wchar_t u = event.text.text[0]; im->s[0] = L'\0'; /* Zero-out output string */ wcsncat(im->buf, &u, 1); /* Copy new character */ @@ -1410,8 +1422,9 @@ static int im_event_ko_isvowel(CHARMAP* cm, wchar_t c) * * @see im_read */ -static int im_event_ko(IM_DATA* im, SDL_keysym ks) +static int im_event_ko(IM_DATA* im, SDL_Event event) { + SDL_Keysym ks = event.key.keysym; static const char* lang_file = IMDIR "ko.im"; enum { SEC_ENGLISH, SEC_HANGUL, SEC_TOTAL }; @@ -1447,7 +1460,7 @@ static int im_event_ko(IM_DATA* im, SDL_keysym ks) if(charmap_load(&cm, lang_file)) { fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; - return im_event_c(im, ks); + return im_event_c(im, event); } im_fullreset(im); @@ -1468,12 +1481,12 @@ static int im_event_ko(IM_DATA* im, SDL_keysym ks) /* Handle keys */ switch(ks.sym) { /* Keys to ignore */ - case SDLK_NUMLOCK: case SDLK_CAPSLOCK: case SDLK_SCROLLOCK: + case SDLK_NUMLOCKCLEAR: case SDLK_CAPSLOCK: case SDLK_SCROLLLOCK: case SDLK_LSHIFT: case SDLK_RSHIFT: case SDLK_LCTRL: case SDLK_RCTRL: - case SDLK_LMETA: case SDLK_RMETA: - case SDLK_LSUPER: case SDLK_RSUPER: - case SDLK_MODE: case SDLK_COMPOSE: + case SDLK_LGUI: case SDLK_RGUI: + case SDLK_MENU: + case SDLK_MODE: case SDLK_APPLICATION: break; /* Right-Alt mapped to mode-switch */ @@ -1494,7 +1507,7 @@ static int im_event_ko(IM_DATA* im, SDL_keysym ks) if(wcslen(im->buf) > 0) { wcs_pull(im->buf, 1); if(im->redraw > 0) im->redraw--; - ks.unicode = L'\0'; + event.text.text[0] = L'\0'; } /* continue processing: */ @@ -1502,13 +1515,13 @@ static int im_event_ko(IM_DATA* im, SDL_keysym ks) default: /* English mode */ if(cm.section == SEC_ENGLISH) { - im->s[0] = ks.unicode; + im->s[0] = event.text.text[0]; im->s[1] = L'\0'; im->buf[0] = L'\0'; } /* Hangul mode */ else { - wchar_t u = ks.unicode; + wchar_t u = event.text.text[0]; wchar_t* bp = im->buf; im->s[0] = L'\0'; /* Zero-out output string */ diff --git a/src/im.h b/src/im.h index a2f349cd3..0a12dcaf9 100644 --- a/src/im.h +++ b/src/im.h @@ -51,7 +51,7 @@ typedef struct IM_DATA { void im_init(IM_DATA* im, int lang); /* Initialize IM */ void im_softreset(IM_DATA* im); /* Soft Reset IM */ -int im_read(IM_DATA* im, SDL_keysym ks); +int im_read(IM_DATA* im, SDL_Event event); #endif /* TUXPAINT_IM_H */ diff --git a/src/onscreen_keyboard.c b/src/onscreen_keyboard.c index 0810421f1..33f67246f 100644 --- a/src/onscreen_keyboard.c +++ b/src/onscreen_keyboard.c @@ -1389,7 +1389,7 @@ static char * find_keysym(osk_key key, on_screen_keyboard *keyboard) int keycode; char *keysym; osk_keymap keysyms; - SDLMod modstate; + SDL_Keymod modstate; keycode = key.keycode; keysyms = keyboard->layout->keymap[keycode]; @@ -1458,7 +1458,7 @@ static char * find_keysym(osk_key key, on_screen_keyboard *keyboard) /* We lose the SDL ModState by leaving and entering the tuxpaint window, so using a custom state */ static int handle_keymods(char * keysym, osk_key * key, on_screen_keyboard *keyboard) { - SDLMod mod; + SDL_Keymod mod; SDL_Event ev; mod = keyboard->modifiers; @@ -1482,7 +1482,7 @@ static int handle_keymods(char * keysym, osk_key * key, on_screen_keyboard *keyb else if (strncmp("Alt_L", keysym, 5) == 0) { ev.key.keysym.sym = SDLK_LALT; - ev.key.keysym.unicode = 0; // FIXME is 0 the right value here? + ev.text.text[0] = '0'; // FIXME is 0 the right value here? ev.type = SDL_KEYDOWN; SDL_PushEvent(&ev); ev.type = SDL_KEYUP; @@ -1600,7 +1600,7 @@ struct osk_keyboard * osk_clicked(on_screen_keyboard *keyboard, int x, int y) event.key.keysym.mod = KMOD_NONE; event.key.keysym.sym = 0; - event.key.keysym.unicode = 0; + event.text.text[0] = 0; key = find_key(keyboard, x, y); @@ -1729,27 +1729,27 @@ struct osk_keyboard * osk_clicked(on_screen_keyboard *keyboard, int x, int y) if (wcsncmp(L"Return", ks, 6) == 0) { event.key.keysym.sym = SDLK_RETURN; - event.key.keysym.unicode = '\r'; + event.text.text[0] = '\r'; } else if (wcsncmp(L"Tab", ks, 3) == 0 || wcsncmp(L"ISO_Left_Tab", ks, 12) == 0) { event.key.keysym.sym = SDLK_TAB; - event.key.keysym.unicode = '\t'; + event.text.text[0] = '\t'; } else if (wcsncmp(L"BackSpace", ks, 9) == 0) { event.key.keysym.sym = SDLK_BACKSPACE; - event.key.keysym.unicode = '\b'; + event.text.text[0] = '\b'; } else if (wcsncmp(L"NoSymbol", ks, 8) == 0) return(keyboard); else if (keyboard->composed_type == 1) - event.key.keysym.unicode = *keyboard->composed; + event.text.text[0] = *keyboard->composed; else - event.key.keysym.unicode = keysym2unicode(mnemo2keysym(mnemo, keyboard), keyboard); + event.text.text[0] = keysym2unicode(mnemo2keysym(mnemo, keyboard), keyboard); clear_dead_sticks(keyboard); event.type = SDL_KEYDOWN; diff --git a/src/postscript_print.h b/src/postscript_print.h index 107517b67..58f0f3bd2 100644 --- a/src/postscript_print.h +++ b/src/postscript_print.h @@ -35,7 +35,7 @@ #include #include -#include "SDL.h" +#include "SDL2/SDL.h" #include "compiler.h" diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 27cbc5323..57130a1eb 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -360,8 +360,8 @@ static void mtw(wchar_t * wtok, char * tok) #include #include -#include "SDL.h" -#include "SDL_thread.h" +#include "SDL2/SDL.h" +#include "SDL2/SDL_thread.h" #if !defined(_SDL_H) #error "---------------------------------------------------" #error "If you installed SDL from a package, be sure to get" @@ -370,7 +370,7 @@ static void mtw(wchar_t * wtok, char * tok) #error "---------------------------------------------------" #endif -#include "SDL_image.h" +#include "SDL2/SDL_image.h" #if !defined(_SDL_IMAGE_H) && !defined(_IMG_h) #error "---------------------------------------------------" #error "If you installed SDL_image from a package, be sure" @@ -379,7 +379,7 @@ static void mtw(wchar_t * wtok, char * tok) #error "---------------------------------------------------" #endif -#include "SDL_ttf.h" +#include "SDL2/SDL_ttf.h" #if !defined(_SDL_TTF_H) && !defined(_SDLttf_h) #error "---------------------------------------------------" #error "If you installed SDL_ttf from a package, be sure" @@ -423,7 +423,7 @@ static void mtw(wchar_t * wtok, char * tok) #ifndef NOSOUND -#include "SDL_mixer.h" +#include "SDL2/SDL_mixer.h" #if !defined(_SDL_MIXER_H) && !defined(_MIXER_H_) #error "---------------------------------------------------" #error "If you installed SDL_mixer from a package, be sure" @@ -477,7 +477,7 @@ static void mtw(wchar_t * wtok, char * tok) #error "---------------------------------------------------" #endif -#include "SDL_getenv.h" +//#include "SDL_getenv.h" #include "i18n.h" #include "cursor.h" @@ -852,6 +852,8 @@ static void setup_screen_layout(void) #endif } +static SDL_Window *window_screen; +static SDL_Renderer *renderer; static SDL_Surface *screen = NULL; static SDL_Surface *canvas = NULL; static SDL_Surface *label = NULL; @@ -859,6 +861,26 @@ static SDL_Surface *save_canvas = NULL; static SDL_Surface *canvas_back = NULL; static SDL_Surface *img_starter = NULL, *img_starter_bkgd = NULL; + +static void SDL_Flip(SDL_Surface *screen) +{ + SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, screen); + SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderPresent(renderer); +} + +static void SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h) +{ + SDL_Rect r; + r.x = x; + r.y = y; + r.w = w; + r.h = h; + SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, screen); + SDL_RenderCopy(renderer, texture, &r, &r); +} + + /* Update a rect. based on two x/y coords (not necessarly in order): */ static void update_screen(int x1, int y1, int x2, int y2) { @@ -1888,8 +1910,8 @@ static Uint32 drawtext_callback(Uint32 interval, void *param); static void control_drawtext_timer(Uint32 interval, const char *const text, Uint8 locale_text); static const char *great_str(void); static void draw_image_title(int t, SDL_Rect dest); -static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1, SDL_Rect *area2); -static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Rect real_r_tools); +static void handle_keymouse(SDL_Keycode key, Uint8 updown, int steps, SDL_Rect *area1, SDL_Rect *area2); +static void handle_keymouse_buttons(SDL_Keycode key, int *whicht, int *whichc, SDL_Rect real_r_tools); static void handle_active(SDL_Event * event); static char *remove_slash(char *path); /*static char *replace_tilde(const char* const path);*/ @@ -1978,7 +2000,7 @@ static void do_wait(int counter) /* FIXME: Handle SDL_Quit better */ } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -2019,13 +2041,13 @@ static void eat_sdl_events(void) SDL_Quit(); exit(0); /* can't safely use do_quit during start-up */ } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) handle_active(&event); else if (event.type == SDL_KEYDOWN) { - SDLKey key = event.key.keysym.sym; - SDLMod ctrl = event.key.keysym.mod & KMOD_CTRL; - SDLMod alt = event.key.keysym.mod & KMOD_ALT; + SDL_Keycode key = event.key.keysym.sym; + SDL_Keymod ctrl = event.key.keysym.mod & KMOD_CTRL; + SDL_Keymod alt = event.key.keysym.mod & KMOD_ALT; if ((key == SDLK_c && ctrl) || (key == SDLK_F4 && alt)) { SDL_Quit(); @@ -2143,15 +2165,15 @@ static void mainloop(void) unsigned int i = 0; SDL_TimerID scrolltimer = NULL; SDL_Event event; - SDLKey key; - SDLMod mod; + SDL_Keycode key; + SDL_Keymod mod; Uint32 last_cursor_blink, cur_cursor_blink, pre_event_time, current_event_time; SDL_Rect update_rect; SDL_Rect real_r_tools = r_tools; #ifdef DEBUG Uint16 key_unicode; - SDLKey key_down; + SDL_Keycode key_down; #endif on_screen_keyboard *new_kbd; SDL_Rect kbd_rect; @@ -2222,13 +2244,14 @@ static void mainloop(void) } } } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { /* Reset Shapes tool and clean the canvas if we lose focus*/ if (mouseaccessibility && emulate_button_pressed && ((cur_tool == TOOL_SHAPES && shape_tool_mode != SHAPE_TOOL_MODE_DONE) || cur_tool == TOOL_LINES) && - event.active.state & (SDL_APPINPUTFOCUS|SDL_APPACTIVE) && - event.active.gain == 0) + event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) + /* event.active.state & (SDL_APPINPUTFOCUS|SDL_APPACTIVE) && + event.active.gain == 0)*/ { do_undo(); tool_avail[TOOL_REDO] = 0; /* Don't let them 'redo' to get preview back */ @@ -2604,7 +2627,7 @@ static void mainloop(void) texttool_str[texttool_len] = L'\0'; /* Read IM, remember how many to redraw next iteration */ - redraw = im_read(&im_data, event.key.keysym); + redraw = im_read(&im_data, event); /* Korean Hangul needs this to refresh when buffered chars gets emptied */ if (! *im_cp) @@ -4823,7 +4846,7 @@ static void mainloop(void) shape_radius = sqrt((shape_ctr_x - shape_outer_x) * (shape_ctr_x - shape_outer_x) + (shape_ctr_y - shape_outer_y) * (shape_ctr_y - shape_outer_y)); - SDL_WarpMouse(shape_outer_x + 96, shape_ctr_y); + SDL_WarpMouseInWindow(window_screen, shape_outer_x + 96, shape_ctr_y); do_setcursor(cursor_rotate); @@ -7689,8 +7712,8 @@ static void seticon(void) memset(mask, 0xFF, masklen); /* Set icon: */ - SDL_WM_SetIcon(icon, mask); - + // SDL_WM_SetIcon(icon, mask); + SDL_SetWindowIcon(window_screen, icon); /* Free icon surface & mask: */ free(mask); #else @@ -7705,7 +7728,7 @@ static void seticon(void) if (grab_input) { debug("Grabbing input!"); - SDL_WM_GrabInput(SDL_GRAB_ON); + SDL_SetWindowGrab(window_screen, SDL_TRUE); } } @@ -11345,9 +11368,13 @@ static void load_starter(char *img_id) tmp_surf->format->Amask); /* 3rd arg ignored for RGBA surfaces */ - SDL_SetAlpha(tmp_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); + // SDL_SetAlpha(tmp_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); + SDL_SetSurfaceBlendMode(tmp_surf, SDL_BLENDMODE_NONE); + autoscale_copy_smear_free(tmp_surf, img_starter, NondefectiveBlit); - SDL_SetAlpha(img_starter, SDL_RLEACCEL | SDL_SRCALPHA, SDL_ALPHA_OPAQUE); + // SDL_SetAlpha(img_starter, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); + SDL_SetSurfaceBlendMode(img_starter, SDL_BLENDMODE_NONE); + } @@ -11666,8 +11693,8 @@ static int do_prompt_image_flash_snd(const char *const text, SDL_Rect dest; int done, ans, w, counter; SDL_Color black = { 0, 0, 0, 0 }; - SDLKey key; - SDLKey key_y, key_n; + SDL_Keycode key; + SDL_Keycode key_y, key_n; char *keystr; SDL_Surface * backup; #ifndef NO_PROMPT_SHADOWS @@ -11743,7 +11770,7 @@ static int do_prompt_image_flash_snd(const char *const text, playsound(screen, 1, snd, 1, SNDPOS_LEFT, SNDDIST_NEAR); #ifndef NO_PROMPT_SHADOWS - alpha_surf = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, + alpha_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, (PROMPT_W - 96 * 2) + (w - 4) * 2, (w - 4) * 2, screen->format->BitsPerPixel, @@ -11755,7 +11782,8 @@ static int do_prompt_image_flash_snd(const char *const text, if (alpha_surf != NULL) { SDL_FillRect(alpha_surf, NULL, SDL_MapRGB(alpha_surf->format, 0, 0, 0)); - SDL_SetAlpha(alpha_surf, SDL_SRCALPHA, 64); + SDL_SetSurfaceAlphaMod(alpha_surf, 64); + for (i = 8; i > 0; i = i - 2) { @@ -11929,7 +11957,7 @@ static int do_prompt_image_flash_snd(const char *const text, ans = 0; done = 1; } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -12346,7 +12374,8 @@ static void cleanup(void) /* (Just in case...) */ - SDL_WM_GrabInput(SDL_GRAB_OFF); + // SDL_WM_GrabInput(SDL_GRAB_OFF); + SDL_SetWindowGrab(window_screen, SDL_FALSE); /* If we're using a lockfile, we can 'clear' it when we quit @@ -13701,7 +13730,7 @@ static int do_open(void) num_files_in_dirs, j, any_saved_files; SDL_Rect dest; SDL_Event event; - SDLKey key; + SDL_Keycode key; Uint32 last_click_time; int last_click_which, last_click_button; int places_to_look; @@ -14202,7 +14231,7 @@ static int do_open(void) /* FIXME: Handle SDL_Quit better */ } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -14812,7 +14841,7 @@ static int do_slideshow(void) go_back, found, speed; SDL_Rect dest; SDL_Event event; - SDLKey key; + SDL_Keycode key; char *freeme; int speeds; float x_per, y_per; @@ -15247,7 +15276,7 @@ static int do_slideshow(void) /* FIXME: Handle SDL_Quit better */ } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -15590,7 +15619,7 @@ static void play_slideshow(int * selected, int num_selected, char * dirname, int tmp_starter_mirrored, tmp_starter_flipped, tmp_starter_personal; char fname[1024]; SDL_Event event; - SDLKey key; + SDL_Keycode key; SDL_Rect dest; Uint32 last_ticks; @@ -15693,7 +15722,7 @@ static void play_slideshow(int * selected, int num_selected, char * dirname, next = 1; done = 1; } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -16726,7 +16755,7 @@ static void draw_image_title(int t, SDL_Rect dest) /* Handle keyboard events to control the mouse: */ /* Move as many pixels as bigsteps outside the areas, in the areas and 5 pixels around, move 1 pixel at a time */ -static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1, SDL_Rect *area2) +static void handle_keymouse(SDL_Keycode key, Uint8 updown, int steps, SDL_Rect *area1, SDL_Rect *area2) { int left, right, up, bottom; SDL_Event event; @@ -16816,7 +16845,7 @@ static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1 { if (key == SDLK_INSERT || key == SDLK_F5 || ((cur_tool != TOOL_TEXT && cur_tool != TOOL_LABEL) && - (key == SDLK_SPACE || key == SDLK_5 || key == SDLK_KP5))) + (key == SDLK_SPACE || key == SDLK_5 || key == SDLK_KP_5))) { event.type = SDL_MOUSEBUTTONUP; @@ -16830,16 +16859,16 @@ static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1 else { if (key == SDLK_LEFT) - SDL_WarpMouse(left, oldpos_y); + SDL_WarpMouseInWindow(window_screen, left, oldpos_y); else if (key == SDLK_RIGHT) - SDL_WarpMouse(right, oldpos_y); + SDL_WarpMouseInWindow(window_screen, right, oldpos_y); else if (key == SDLK_UP) - SDL_WarpMouse(oldpos_x, up); + SDL_WarpMouseInWindow(window_screen, oldpos_x, up); else if (key == SDLK_DOWN) - SDL_WarpMouse(oldpos_x, bottom); + SDL_WarpMouseInWindow(window_screen, oldpos_x, bottom); else if ((key == SDLK_INSERT || key == SDLK_F5) && !button_down) { @@ -16853,7 +16882,7 @@ static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1 else if(cur_tool != TOOL_TEXT && cur_tool != TOOL_LABEL ) { if (!button_down && - (key == SDLK_SPACE || key == SDLK_5 || key == SDLK_KP5)) + (key == SDLK_SPACE || key == SDLK_5 || key == SDLK_KP_5)) { event.type = SDL_MOUSEBUTTONDOWN; event.button.x = oldpos_x; @@ -16862,44 +16891,44 @@ static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1 SDL_PushEvent(&event); } - else if (key == SDLK_1 || key == SDLK_KP1) - SDL_WarpMouse(left, bottom); + else if (key == SDLK_1 || key == SDLK_KP_1) + SDL_WarpMouseInWindow(window_screen, left, bottom); - else if (key == SDLK_3 || key == SDLK_KP3) - SDL_WarpMouse(right, bottom); + else if (key == SDLK_3 || key == SDLK_KP_3) + SDL_WarpMouseInWindow(window_screen, right, bottom); - else if (key == SDLK_7 || key == SDLK_KP7) - SDL_WarpMouse(left, up); + else if (key == SDLK_7 || key == SDLK_KP_7) + SDL_WarpMouseInWindow(window_screen, left, up); - else if (key == SDLK_9 || key == SDLK_KP9) - SDL_WarpMouse(right, up); + else if (key == SDLK_9 || key == SDLK_KP_9) + SDL_WarpMouseInWindow(window_screen, right, up); - else if (key == SDLK_2 || key == SDLK_KP2) - SDL_WarpMouse(oldpos_x, bottom); + else if (key == SDLK_2 || key == SDLK_KP_2) + SDL_WarpMouseInWindow(window_screen, oldpos_x, bottom); - else if (key == SDLK_8 || key == SDLK_KP8) - SDL_WarpMouse(oldpos_x, up); + else if (key == SDLK_8 || key == SDLK_KP_8) + SDL_WarpMouseInWindow(window_screen, oldpos_x, up); - else if (key == SDLK_6 || key == SDLK_KP6) - SDL_WarpMouse(right, oldpos_y); + else if (key == SDLK_6 || key == SDLK_KP_6) + SDL_WarpMouseInWindow(window_screen, right, oldpos_y); - else if (key == SDLK_4 || key == SDLK_KP4) - SDL_WarpMouse(left, oldpos_y); + else if (key == SDLK_4 || key == SDLK_KP_4) + SDL_WarpMouseInWindow(window_screen, left, oldpos_y); /* FIXME: This is qwerty centric and interferes with gettexted reponses for yes/no, so disabling until either is removed or is configurable. */ #if 0 else if (key == SDLK_s) - SDL_WarpMouse(oldpos_x, bottom); + SDL_WarpMouseInWindow(window_screen, oldpos_x, bottom); else if (key == SDLK_w) - SDL_WarpMouse(oldpos_x, up); + SDL_WarpMouseInWindow(window_screen, oldpos_x, up); else if (key == SDLK_d) - SDL_WarpMouse(right, oldpos_y); + SDL_WarpMouseInWindow(window_screen, right, oldpos_y); else if (key == SDLK_a) - SDL_WarpMouse(left, oldpos_y); + SDL_WarpMouseInWindow(window_screen, left, oldpos_y); #endif } @@ -16908,7 +16937,7 @@ static void handle_keymouse(SDLKey key, Uint8 updown, int steps, SDL_Rect *area1 } /* A subset of keys that will move one button at a time and jump between r_canvas<->r_tools<->r_colors */ -static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Rect real_r_tools ) +static void handle_keymouse_buttons(SDL_Keycode key, int *whicht, int *whichc, SDL_Rect real_r_tools ) { if (hit_test(&real_r_tools, oldpos_x, oldpos_y) && (key == SDLK_F7 || key == SDLK_F8 || key == SDLK_F11 || key == SDLK_F12)) @@ -16977,7 +17006,7 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Re update_screen_rect(&r_tools); } - SDL_WarpMouse(button_w / 2 + *whicht % 2 * button_w, real_r_tools.y - *whicht % 2 * button_w / 2 + *whicht * button_h / 2 + 10 - tool_scroll * button_h / 2 ); + SDL_WarpMouseInWindow(window_screen, button_w / 2 + *whicht % 2 * button_w, real_r_tools.y - *whicht % 2 * button_w / 2 + *whicht * button_h / 2 + 10 - tool_scroll * button_h / 2 ); } else if (key == SDLK_F11 && hit_test(&r_colors,oldpos_x, oldpos_y)) @@ -16986,7 +17015,7 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Re *whichc = *whichc - 1; if (*whichc < 0) *whichc += NUM_COLORS; - SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); + SDL_WarpMouseInWindow(window_screen, button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); } else if (key == SDLK_F12 && hit_test(&r_colors,oldpos_x, oldpos_y)) @@ -16994,17 +17023,17 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Re *whichc = grid_hit_gd(&r_colors, oldpos_x, oldpos_y, &gd_colors); *whichc = *whichc + 1; *whichc = *whichc % NUM_COLORS; - SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); + SDL_WarpMouseInWindow(window_screen, button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); } else if (key == SDLK_F4) { if (hit_test(&r_tools, oldpos_x, oldpos_y)) - SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h/2)); + SDL_WarpMouseInWindow(window_screen, button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h/2)); else if (hit_test(&r_colors,oldpos_x, oldpos_y)) - SDL_WarpMouse(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); + SDL_WarpMouseInWindow(window_screen, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); else - SDL_WarpMouse(button_w / 2 + *whicht % 2 * button_w, real_r_tools.y - *whicht % 2 * button_w / 2 + *whicht * button_h / 2 + 10 - tool_scroll * button_h / 2 ); + SDL_WarpMouseInWindow(window_screen, button_w / 2 + *whicht % 2 * button_w, real_r_tools.y - *whicht % 2 * button_w / 2 + *whicht * button_h / 2 + 10 - tool_scroll * button_h / 2 ); /* Play a sound here as there is a big jump */ playsound(screen, 1, SND_CLICK, 0, SNDPOS_LEFT, SNDDIST_NEAR); @@ -17015,21 +17044,15 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Re static void handle_active(SDL_Event * event) { - if (event->active.state & SDL_APPACTIVE) + if (event->window.event == SDL_WINDOWEVENT_EXPOSED) { - if (event->active.gain == 1) - { if (fullscreen) SDL_Flip(screen); - } } - if (event->active.state & SDL_APPINPUTFOCUS|SDL_APPACTIVE) + if (event->window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { - if (event->active.gain == 1) - { if (mouseaccessibility) { magic_switchin(canvas); - } } else if (mouseaccessibility && emulate_button_pressed) { magic_switchout(canvas); @@ -18441,7 +18464,7 @@ static int do_new_dialog(void) num_files_in_dirs, j; SDL_Rect dest; SDL_Event event; - SDLKey key; + SDL_Keycode key; Uint32 last_click_time; int last_click_which, last_click_button; int places_to_look; @@ -19069,7 +19092,7 @@ static int do_new_dialog(void) /* FIXME: Handle SDL_Quit better */ } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -19831,7 +19854,7 @@ static int do_color_sel(void) chose = 0; done = 1; } - else if (event.type == SDL_ACTIVEEVENT) + else if (event.type == SDL_WINDOWEVENT) { handle_active(&event); } @@ -20077,7 +20100,7 @@ static int do_color_picker(void) double rh, gh, bh; int done, chose; SDL_Event event; - SDLKey key; + SDL_Keycode key; int color_picker_left, color_picker_top; int back_left, back_top; SDL_Rect color_example_dest; @@ -20131,7 +20154,7 @@ static int do_color_picker(void) SDL_BlitSurface(backup, NULL, screen, NULL); #ifndef NO_PROMPT_SHADOWS - alpha_surf = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, + alpha_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, (PROMPT_W - 96 * 2) + (w - 4) * 2, (w - 4) * 2, screen->format->BitsPerPixel, @@ -20143,7 +20166,8 @@ static int do_color_picker(void) if (alpha_surf != NULL) { SDL_FillRect(alpha_surf, NULL, SDL_MapRGB(alpha_surf->format, 0, 0, 0)); - SDL_SetAlpha(alpha_surf, SDL_SRCALPHA, 64); + SDL_SetSurfaceAlphaMod(alpha_surf, 64); + for (i = 8; i > 0; i = i - 2) { @@ -20276,7 +20300,7 @@ static int do_color_picker(void) done = 0; chose = 0; x = y = 0; - SDL_WarpMouse(back_left + button_w / 2, back_top - button_w / 2); + SDL_WarpMouseInWindow(window_screen, back_left + button_w / 2, back_top - button_w / 2); do { @@ -21988,9 +22012,11 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) TPAINT_AMASK); /* 3rd arg ignored for RGBA surfaces */ - SDL_SetAlpha(aux_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); + // SDL_SetAlpha(aux_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); + SDL_SetSurfaceBlendMode(aux_surf, SDL_BLENDMODE_NONE); autoscale_copy_smear_free(aux_surf, img_starter, NondefectiveBlit); - SDL_SetAlpha(img_starter, SDL_RLEACCEL | SDL_SRCALPHA, SDL_ALPHA_OPAQUE); + // SDL_SetAlpha(img_starter, SDL_ALPHA_OPAQUE); + SDL_SetSurfaceBlendMode(img_starter, SDL_BLENDMODE_NONE); free(unc_buff); } @@ -22976,10 +23002,10 @@ static void do_lock_file(void) free(lock_fname); } -int TP_EventFilter(const SDL_Event * event) +int TP_EventFilter(const SDL_Event * event, void *data) { if (event->type == SDL_QUIT || - event->type == SDL_ACTIVEEVENT || + event->type == SDL_WINDOWEVENT || event->type == SDL_JOYAXISMOTION || event->type == SDL_JOYBALLMOTION || event->type == SDL_JOYHATMOTION || @@ -23094,7 +23120,7 @@ static void setup(void) /* Set up event filter */ - SDL_SetEventFilter(TP_EventFilter); + SDL_SetEventFilter(TP_EventFilter, NULL); /* Set up joystick */ @@ -23158,7 +23184,7 @@ static void setup(void) /* Set-up Key-Repeat: */ - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + // SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); /* Init TTF stuff: */ if (TTF_Init() < 0) @@ -23180,8 +23206,6 @@ static void setup(void) #ifndef __APPLE__ seticon(); #endif - SDL_WM_SetCaption("Tux Paint", "Tux Paint"); - if (hide_cursor) SDL_ShowCursor (SDL_DISABLE); @@ -23224,13 +23248,27 @@ static void setup(void) if (fullscreen) { #ifdef USE_HWSURFACE - screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, - VIDEO_BPP, SDL_FULLSCREEN | SDL_HWSURFACE); + /* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, + VIDEO_BPP, SDL_FULLSCREEN | SDL_HWSURFACE);*/ + SDL_Window *window_screen = SDL_CreateWindow("Tux Paint", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + WINDOW_WIDTH, WINDOW_HEIGHT, + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_HWSURFACE); + #else - screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, - VIDEO_BPP, SDL_FULLSCREEN | SDL_SWSURFACE); +/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, + VIDEO_BPP, SDL_FULLSCREEN | SDL_SWSURFACE);*/ + SDL_Window *window_screen = SDL_CreateWindow("Tux Paint", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + WINDOW_WIDTH, WINDOW_HEIGHT, + SDL_WINDOW_FULLSCREEN ); #endif + screen = SDL_GetWindowSurface(window_screen); + renderer = SDL_CreateRenderer(window_screen, -1, 0); + if (screen == NULL) { fprintf(stderr, @@ -23263,17 +23301,30 @@ static void setup(void) } #ifdef USE_HWSURFACE - screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, - VIDEO_BPP, SDL_HWSURFACE); + /* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, + VIDEO_BPP, SDL_HWSURFACE);*/ +SDL_Window *window_screen = SDL_CreateWindow("Tux Paint", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + WINDOW_WIDTH, WINDOW_HEIGHT, + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_HWSURFACE); #else - screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, - VIDEO_BPP, SDL_SWSURFACE); +SDL_Window *window_screen = SDL_CreateWindow("Tux Paint", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + WINDOW_WIDTH, WINDOW_HEIGHT, + SDL_WINDOW_FULLSCREEN); +/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, +s + VIDEO_BPP, SDL_SWSURFACE);*/ #endif if (set_window_pos) putenv((char *) "SDL_VIDEO_WINDOW_POS=nopref"); } + screen = SDL_GetWindowSurface(window_screen); + if (screen == NULL) { fprintf(stderr, @@ -23612,7 +23663,7 @@ static void setup(void) img_sfx = loadimage(DATA_PREFIX "images/tools/sfx.png"); img_speak = loadimage(DATA_PREFIX "images/tools/speak.png"); - img_black = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_SWSURFACE, + img_black = SDL_CreateRGBSurface(SDL_SWSURFACE, img_btn_off->w, img_btn_off->h, img_btn_off->format->BitsPerPixel, img_btn_off->format->Rmask, @@ -23621,7 +23672,7 @@ static void setup(void) img_btn_off->format->Amask); SDL_FillRect(img_black, NULL, SDL_MapRGBA(screen->format, 0, 0, 0, 255)); - img_grey = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_SWSURFACE, + img_grey = SDL_CreateRGBSurface(SDL_SWSURFACE, img_btn_off->w, img_btn_off->h, img_btn_off->format->BitsPerPixel, img_btn_off->format->Rmask, @@ -23986,7 +24037,7 @@ static void setup(void) /* Enable Unicode support in SDL: */ - SDL_EnableUNICODE(1); +// SDL_EnableUNICODE(1); #ifndef _WIN32 /* Set up signal handler for SIGPIPE (in case printer command dies; @@ -24073,7 +24124,7 @@ static void claim_to_be_ready(void) oldpos_x = WINDOW_WIDTH / 2; oldpos_y = WINDOW_HEIGHT / 2; - SDL_WarpMouse(oldpos_x, oldpos_y); + SDL_WarpMouseInWindow(window_screen, oldpos_x, oldpos_y); eraser_sound = 0; @@ -24446,7 +24497,7 @@ static void handle_joyhatmotion(SDL_Event event, int oldpos_x, int oldpos_y, int break; } if(*valhat_x || *valhat_y) - SDL_WarpMouse(oldpos_x + *valhat_x, oldpos_y + *valhat_y); + SDL_WarpMouseInWindow(window_screen, oldpos_x + *valhat_x, oldpos_y + *valhat_y); *old_hat_ticks = SDL_GetTicks(); } @@ -24458,7 +24509,7 @@ static void handle_joyballmotion(SDL_Event event, int oldpos_x, int oldpos_y) { /* printf("\n ball movement \n"); */ val_x = event.jball.xrel; val_y = event.jball.yrel; - SDL_WarpMouse(oldpos_x + val_x, oldpos_y + val_y); + SDL_WarpMouseInWindow(window_screen, oldpos_x + val_x, oldpos_y + val_y); } @@ -24478,7 +24529,7 @@ if (ticks - old_hat_ticks > joystick_hat_timeout) vx += valhat_x; vy += valhat_y; } -SDL_WarpMouse(vx, vy); +SDL_WarpMouseInWindow(window_screen, vx, vy); if (motioner && joystick_slowness) SDL_Delay(joystick_slowness);