gui_sdl.c (1195B)
1 /* gui_sdl.c - interfaz grafica con SDL3 (ventana de comun/linux/guikit). */ 2 #include <string.h> 3 #include "frontend.h" 4 #include "guikit.h" 5 6 static Surface *surf; 7 8 static void gui_draw_game(Frontend *f, const View *v) 9 { 10 chess_screen(surf, v, &f->hits); 11 gk_present(); 12 } 13 14 static void gui_draw_form(Frontend *f, const Form *form) 15 { 16 gfx_form(surf, form, &f->hits); 17 gk_present(); 18 } 19 20 static int gui_wait(Frontend *f, int timeout_ms, const int *fds, int nfds, InEvent *ev) 21 { 22 (void)f; 23 (void)fds; 24 return gk_wait(timeout_ms, nfds, ev); 25 } 26 27 static void gui_close(Frontend *f) 28 { 29 (void)f; 30 gk_close(); 31 } 32 33 static char *gui_paste(Frontend *f) 34 { 35 (void)f; 36 return gk_clipboard(); 37 } 38 39 Frontend *gui_open(int layout, int scale) 40 { 41 static Frontend fe; 42 surf = gk_open(g_lang ? "Chess" : "Ajedrez", layout == LAYOUT_COMPACT ? 320 : 640, layout == LAYOUT_COMPACT ? 320 : 480, scale); 43 if (!surf) return NULL; 44 gfx_form_backdrop = chess_form_backdrop; 45 memset(&fe, 0, sizeof fe); 46 fe.draw_game = gui_draw_game; 47 fe.draw_form = gui_draw_form; 48 fe.wait = gui_wait; 49 fe.close = gui_close; 50 fe.paste = gui_paste; 51 fe.is_gui = true; 52 return &fe; 53 }