2
0
mirror of https://github.com/arnavbhatt288/sdl-2.30.3-kolibri.git synced 2025-01-04 19:35:58 +01:00

add other window functions + other changes

Signed-off-by: Arnav Bhatt <arnav@ghativega.in>
This commit is contained in:
Arnav Bhatt 2024-07-06 17:58:13 +05:30
parent 6ffbce2cd7
commit c164d8f0a5
No known key found for this signature in database
GPG Key ID: 2F49C4D36103865D
10 changed files with 180 additions and 105 deletions

View File

@ -28,10 +28,10 @@
#ifndef SDL_syswm_h_ #ifndef SDL_syswm_h_
#define SDL_syswm_h_ #define SDL_syswm_h_
#include "SDL_stdinc.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_stdinc.h"
#include "SDL_version.h" #include "SDL_version.h"
#include "SDL_video.h"
/** /**
* \brief SDL_syswm.h * \brief SDL_syswm.h
@ -49,7 +49,7 @@ struct SDL_SysWMinfo;
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
#ifndef NOMINMAX /* don't define min() and max(). */ #ifndef NOMINMAX /* don't define min() and max(). */
#define NOMINMAX #define NOMINMAX
#endif #endif
#include <windows.h> #include <windows.h>
@ -66,8 +66,8 @@ struct SDL_SysWMinfo;
#define Cursor X11Cursor #define Cursor X11Cursor
#endif #endif
#include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xlib.h>
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
/* matches the re-define above */ /* matches the re-define above */
@ -121,7 +121,6 @@ typedef void *EGLSurface;
struct gbm_device; struct gbm_device;
#endif #endif
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
@ -141,14 +140,15 @@ typedef enum
SDL_SYSWM_COCOA, SDL_SYSWM_COCOA,
SDL_SYSWM_UIKIT, SDL_SYSWM_UIKIT,
SDL_SYSWM_WAYLAND, SDL_SYSWM_WAYLAND,
SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
SDL_SYSWM_WINRT, SDL_SYSWM_WINRT,
SDL_SYSWM_ANDROID, SDL_SYSWM_ANDROID,
SDL_SYSWM_VIVANTE, SDL_SYSWM_VIVANTE,
SDL_SYSWM_OS2, SDL_SYSWM_OS2,
SDL_SYSWM_HAIKU, SDL_SYSWM_HAIKU,
SDL_SYSWM_KMSDRM, SDL_SYSWM_KMSDRM,
SDL_SYSWM_RISCOS SDL_SYSWM_RISCOS,
SDL_SYSWM_KOLIBRI
} SDL_SYSWM_TYPE; } SDL_SYSWM_TYPE;
/** /**
@ -161,20 +161,23 @@ struct SDL_SysWMmsg
union union
{ {
#if defined(SDL_VIDEO_DRIVER_WINDOWS) #if defined(SDL_VIDEO_DRIVER_WINDOWS)
struct { struct
HWND hwnd; /**< The window for the message */ {
UINT msg; /**< The type of message */ HWND hwnd; /**< The window for the message */
WPARAM wParam; /**< WORD message parameter */ UINT msg; /**< The type of message */
LPARAM lParam; /**< LONG message parameter */ WPARAM wParam; /**< WORD message parameter */
LPARAM lParam; /**< LONG message parameter */
} win; } win;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_X11) #if defined(SDL_VIDEO_DRIVER_X11)
struct { struct
{
XEvent event; XEvent event;
} x11; } x11;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_DIRECTFB) #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
struct { struct
{
DFBEvent event; DFBEvent event;
} dfb; } dfb;
#endif #endif
@ -205,11 +208,11 @@ struct SDL_SysWMmsg
#if defined(SDL_VIDEO_DRIVER_OS2) #if defined(SDL_VIDEO_DRIVER_OS2)
struct struct
{ {
BOOL fFrame; /**< TRUE if hwnd is a frame window */ BOOL fFrame; /**< TRUE if hwnd is a frame window */
HWND hwnd; /**< The window receiving the message */ HWND hwnd; /**< The window receiving the message */
ULONG msg; /**< The message identifier */ ULONG msg; /**< The message identifier */
MPARAM mp1; /**< The first first message parameter */ MPARAM mp1; /**< The first first message parameter */
MPARAM mp2; /**< The second first message parameter */ MPARAM mp2; /**< The second first message parameter */
} os2; } os2;
#endif #endif
/* Can't have an empty union */ /* Can't have an empty union */
@ -232,43 +235,43 @@ struct SDL_SysWMinfo
#if defined(SDL_VIDEO_DRIVER_WINDOWS) #if defined(SDL_VIDEO_DRIVER_WINDOWS)
struct struct
{ {
HWND window; /**< The window handle */ HWND window; /**< The window handle */
HDC hdc; /**< The window device context */ HDC hdc; /**< The window device context */
HINSTANCE hinstance; /**< The instance handle */ HINSTANCE hinstance; /**< The instance handle */
} win; } win;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_WINRT) #if defined(SDL_VIDEO_DRIVER_WINRT)
struct struct
{ {
IInspectable * window; /**< The WinRT CoreWindow */ IInspectable *window; /**< The WinRT CoreWindow */
} winrt; } winrt;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_X11) #if defined(SDL_VIDEO_DRIVER_X11)
struct struct
{ {
Display *display; /**< The X11 display */ Display *display; /**< The X11 display */
Window window; /**< The X11 window */ Window window; /**< The X11 window */
} x11; } x11;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_DIRECTFB) #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
struct struct
{ {
IDirectFB *dfb; /**< The directfb main interface */ IDirectFB *dfb; /**< The directfb main interface */
IDirectFBWindow *window; /**< The directfb window handle */ IDirectFBWindow *window; /**< The directfb window handle */
IDirectFBSurface *surface; /**< The directfb client surface */ IDirectFBSurface *surface; /**< The directfb client surface */
} dfb; } dfb;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_COCOA) #if defined(SDL_VIDEO_DRIVER_COCOA)
struct struct
{ {
#if defined(__OBJC__) && defined(__has_feature) #if defined(__OBJC__) && defined(__has_feature)
#if __has_feature(objc_arc) #if __has_feature(objc_arc)
NSWindow __unsafe_unretained *window; /**< The Cocoa window */ NSWindow __unsafe_unretained *window; /**< The Cocoa window */
#else
NSWindow *window; /**< The Cocoa window */
#endif
#else #else
NSWindow *window; /**< The Cocoa window */ NSWindow *window; /**< The Cocoa window */
#endif
#else
NSWindow *window; /**< The Cocoa window */
#endif #endif
} cocoa; } cocoa;
#endif #endif
@ -276,37 +279,37 @@ struct SDL_SysWMinfo
struct struct
{ {
#if defined(__OBJC__) && defined(__has_feature) #if defined(__OBJC__) && defined(__has_feature)
#if __has_feature(objc_arc) #if __has_feature(objc_arc)
UIWindow __unsafe_unretained *window; /**< The UIKit window */ UIWindow __unsafe_unretained *window; /**< The UIKit window */
#else
UIWindow *window; /**< The UIKit window */
#endif
#else #else
UIWindow *window; /**< The UIKit window */ UIWindow *window; /**< The UIKit window */
#endif #endif
GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */ #else
GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */ UIWindow *window; /**< The UIKit window */
#endif
GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */ GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
} uikit; } uikit;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_WAYLAND) #if defined(SDL_VIDEO_DRIVER_WAYLAND)
struct struct
{ {
struct wl_display *display; /**< Wayland display */ struct wl_display *display; /**< Wayland display */
struct wl_surface *surface; /**< Wayland surface */ struct wl_surface *surface; /**< Wayland surface */
void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */ void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */
struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */ struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */
struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */ struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */
struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */ struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */
struct xdg_popup *xdg_popup; /**< Wayland xdg popup role */ struct xdg_popup *xdg_popup; /**< Wayland xdg popup role */
struct xdg_positioner *xdg_positioner; /**< Wayland xdg positioner, for popup */ struct xdg_positioner *xdg_positioner; /**< Wayland xdg positioner, for popup */
} wl; } wl;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
struct struct
{ {
void *connection; /**< Mir display server connection */ void *connection; /**< Mir display server connection */
void *surface; /**< Mir surface */ void *surface; /**< Mir surface */
} mir; } mir;
#endif #endif
@ -321,8 +324,8 @@ struct SDL_SysWMinfo
#if defined(SDL_VIDEO_DRIVER_OS2) #if defined(SDL_VIDEO_DRIVER_OS2)
struct struct
{ {
HWND hwnd; /**< The window handle */ HWND hwnd; /**< The window handle */
HWND hwndFrame; /**< The frame window handle */ HWND hwndFrame; /**< The frame window handle */
} os2; } os2;
#endif #endif
@ -337,9 +340,9 @@ struct SDL_SysWMinfo
#if defined(SDL_VIDEO_DRIVER_KMSDRM) #if defined(SDL_VIDEO_DRIVER_KMSDRM)
struct struct
{ {
int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */ int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */
int drm_fd; /**< DRM FD (unavailable on Vulkan windows) */ int drm_fd; /**< DRM FD (unavailable on Vulkan windows) */
struct gbm_device *gbm_dev; /**< GBM device (unavailable on Vulkan windows) */ struct gbm_device *gbm_dev; /**< GBM device (unavailable on Vulkan windows) */
} kmsdrm; } kmsdrm;
#endif #endif
@ -353,7 +356,6 @@ struct SDL_SysWMinfo
typedef struct SDL_SysWMinfo SDL_SysWMinfo; typedef struct SDL_SysWMinfo SDL_SysWMinfo;
/** /**
* Get driver-specific information about a window. * Get driver-specific information about a window.
* *
@ -371,9 +373,8 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window *window,
SDL_SysWMinfo * info); SDL_SysWMinfo *info);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -4,8 +4,8 @@
#ifndef SDL_kolibriclipboard_h_ #ifndef SDL_kolibriclipboard_h_
#define SDL_kolibriclipboard_h_ #define SDL_kolibriclipboard_h_
extern char *KOLIBRI_GetClipboardText(_THIS); char *KOLIBRI_GetClipboardText(_THIS);
extern int KOLIBRI_SetClipboardText(_THIS, const char *text); int KOLIBRI_SetClipboardText(_THIS, const char *text);
extern SDL_bool KOLIBRI_HasClipboardText(_THIS); SDL_bool KOLIBRI_HasClipboardText(_THIS);
#endif /* SDL_kolibriclipboard_h_ */ #endif /* SDL_kolibriclipboard_h_ */

View File

@ -248,6 +248,7 @@ void KOLIBRI_PumpEvents(_THIS)
int top = 0; int top = 0;
int scancode = 0; int scancode = 0;
int pressed = 0; int pressed = 0;
int win_size_w, win_size_h;
SDL_Keycode keycode = SDLK_UNKNOWN; SDL_Keycode keycode = SDLK_UNKNOWN;
SDL_Keymod mod = 0; SDL_Keymod mod = 0;
static int ext_code = 0; static int ext_code = 0;
@ -262,25 +263,20 @@ void KOLIBRI_PumpEvents(_THIS)
return; return;
case KSYS_EVENT_REDRAW: case KSYS_EVENT_REDRAW:
{ {
top = _ksys_thread_info(&thread_info, KSYS_THIS_SLOT); _ksys_thread_info(&thread_info, KSYS_THIS_SLOT);
if (top == thread_info.pos_in_window_stack) {
int win_size_w = thread_info.winx_size;
int win_size_h = thread_info.winy_size;
if (wdata->skin == 0x01) { win_size_w = thread_info.winx_size + 1;
win_size_w++; win_size_h = thread_info.winy_size + 1;
win_size_h++; if (wdata->skin != 0x01) {
} else { win_size_w -= TRUE_WIN_WIDTH;
win_size_w -= (TRUE_WIN_WIDTH + 1); win_size_h -= TRUE_WIN_HEIGHT;
win_size_h -= (TRUE_WIN_HEIGHT + 1);
}
if (thread_info.winx_start != window->x || thread_info.winy_start != window->y)
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, thread_info.winx_start, thread_info.winy_start);
if (win_size_w != window->w || win_size_h != window->h)
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, win_size_w, win_size_h);
} }
if (thread_info.winx_start != window->x || thread_info.winy_start != window->y)
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, thread_info.winx_start, thread_info.winy_start);
if (win_size_w != window->w || win_size_h != window->h)
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, win_size_w, win_size_h);
if (thread_info.window_state & 0x01) { if (thread_info.window_state & 0x01) {
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
restored = SDL_FALSE; restored = SDL_FALSE;
@ -344,6 +340,7 @@ void KOLIBRI_PumpEvents(_THIS)
{ {
mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS); mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS);
if (mouse_pos.x >= 0 && mouse_pos.x < window->w && mouse_pos.y >= 0 && mouse_pos.y < window->h || SDL_GetMouse()->relative_mode) { if (mouse_pos.x >= 0 && mouse_pos.x < window->w && mouse_pos.y >= 0 && mouse_pos.y < window->h || SDL_GetMouse()->relative_mode) {
if (SDL_GetMouse()->relative_mode) { if (SDL_GetMouse()->relative_mode) {
center_pos.x = mouse_pos.x - (window->w / 2); center_pos.x = mouse_pos.x - (window->w / 2);
center_pos.y = mouse_pos.y - (window->h / 2); center_pos.y = mouse_pos.y - (window->h / 2);

View File

@ -4,7 +4,7 @@
#include "../../SDL_internal.h" #include "../../SDL_internal.h"
extern void KOLIBRI_InitOSKeymap(void); void KOLIBRI_InitOSKeymap(void);
extern void KOLIBRI_PumpEvents(_THIS); void KOLIBRI_PumpEvents(_THIS);
#endif /* SDL_kolibrievents_h_ */ #endif /* SDL_kolibrievents_h_ */

View File

@ -23,7 +23,7 @@ int KOLIBRI_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, v
{ {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_Surface *surface; SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB24; const Uint32 surface_format = SDL_PIXELFORMAT_BGR24;
int w, h; int w, h;
/* Free the old framebuffer surface */ /* Free the old framebuffer surface */

View File

@ -4,8 +4,8 @@
#ifndef SDL_kolibriframebuffer_h_ #ifndef SDL_kolibriframebuffer_h_
#define SDL_kolibriframebuffer_h_ #define SDL_kolibriframebuffer_h_
extern int KOLIBRI_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); int KOLIBRI_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int KOLIBRI_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); int KOLIBRI_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void KOLIBRI_DestroyWindowFramebuffer(_THIS, SDL_Window *window); void KOLIBRI_DestroyWindowFramebuffer(_THIS, SDL_Window *window);
#endif /* SDL_kolibriframebuffer_h_ */ #endif /* SDL_kolibriframebuffer_h_ */

View File

@ -11,6 +11,6 @@ typedef struct _KOLIBRI_CursorData
void *null_cursor; void *null_cursor;
} KOLIBRI_CursorData; } KOLIBRI_CursorData;
extern void KOLIBRI_InitMouse(void); void KOLIBRI_InitMouse(void);
#endif /* SDL_kolibrimouse_h_ */ #endif /* SDL_kolibrimouse_h_ */

View File

@ -34,7 +34,7 @@ int KOLIBRI_VideoInit(_THIS)
screen_size = _ksys_screen_size(); screen_size = _ksys_screen_size();
/* Use 24-bpp desktop mode */ /* Use 24-bpp desktop mode */
mode.format = SDL_PIXELFORMAT_RGB24; mode.format = SDL_PIXELFORMAT_BGR24;
mode.w = screen_size.x + 1; mode.w = screen_size.x + 1;
mode.h = screen_size.y + 1; mode.h = screen_size.y + 1;
mode.refresh_rate = 60; mode.refresh_rate = 60;
@ -95,6 +95,13 @@ static SDL_VideoDevice *KOLIBRI_CreateDevice(void)
/* "Window" */ /* "Window" */
device->CreateSDLWindow = KOLIBRI_CreateWindow; device->CreateSDLWindow = KOLIBRI_CreateWindow;
device->MaximizeWindow = KOLIBRI_MaximizeWindow;
device->MinimizeWindow = KOLIBRI_MinimizeWindow;
device->RestoreWindow = KOLIBRI_RestoreWindow;
device->SetWindowFullscreen = KOLIBRI_SetWindowFullscreen;
device->SetWindowPosition = KOLIBRI_SetWindowPosition;
device->SetWindowResizable = KOLIBRI_SetWindowResizable;
device->SetWindowSize = KOLIBRI_SetWindowSize;
device->SetWindowTitle = KOLIBRI_SetWindowTitle; device->SetWindowTitle = KOLIBRI_SetWindowTitle;
device->DestroyWindow = KOLIBRI_DestroyWindow; device->DestroyWindow = KOLIBRI_DestroyWindow;

View File

@ -8,10 +8,13 @@
#include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_mouse_c.h"
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#include "SDL_syswm.h"
#include "SDL_kolibrivideo.h" #include "SDL_kolibrivideo.h"
#include "SDL_kolibriwindow.h" #include "SDL_kolibriwindow.h"
static int pid = 0;
void KOLIBRI_RepaintWnd(_THIS) void KOLIBRI_RepaintWnd(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
@ -20,24 +23,20 @@ void KOLIBRI_RepaintWnd(_THIS)
int win_pos_x, win_pos_y; int win_pos_x, win_pos_y;
int win_size_w, win_size_h; int win_size_w, win_size_h;
win_size_w = window->w + TRUE_WIN_WIDTH; win_size_w = window->w;
win_size_h = window->h + TRUE_WIN_HEIGHT; win_size_h = window->h;
if (wdata->skin == 0x33 || wdata->skin == 0x34) {
win_size_w += TRUE_WIN_WIDTH;
win_size_h += TRUE_WIN_HEIGHT;
}
_ksys_start_draw(); _ksys_start_draw();
_ksys_create_window(window->x, window->y, win_size_w, win_size_h, window->title, 0, 0x34); _ksys_create_window(window->x, window->y, win_size_w, win_size_h, window->title, 0, wdata->skin);
if (wdata->surface->pixels) if (wdata->surface->pixels)
_ksys_draw_bitmap(wdata->surface->pixels, 0, 0, wdata->surface->w, wdata->surface->h); _ksys_draw_bitmap(wdata->surface->pixels, 0, 0, wdata->surface->w, wdata->surface->h);
_ksys_end_draw(); _ksys_end_draw();
} }
void KOLIBRI_change_window_size_and_pos(int w, int h, int x, int y)
{
w += TRUE_WIN_WIDTH;
h += TRUE_WIN_HEIGHT;
_ksys_change_window(x, y, w, h);
}
int KOLIBRI_CreateWindow(_THIS, SDL_Window *window) int KOLIBRI_CreateWindow(_THIS, SDL_Window *window)
{ {
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
@ -52,6 +51,7 @@ int KOLIBRI_CreateWindow(_THIS, SDL_Window *window)
window->driverdata = wdata; window->driverdata = wdata;
data->window_id = SDL_GetWindowID(window); data->window_id = SDL_GetWindowID(window);
wdata->skin = 0x34;
_ksys_set_event_mask(0x27); _ksys_set_event_mask(0x27);
KOLIBRI_RepaintWnd(_this); KOLIBRI_RepaintWnd(_this);
@ -61,14 +61,64 @@ int KOLIBRI_CreateWindow(_THIS, SDL_Window *window)
return 0; return 0;
} }
void KOLIBRI_MaximizeWindow(_THIS, SDL_Window *window)
{
// TODO
}
void KOLIBRI_MinimizeWindow(_THIS, SDL_Window *window)
{
ksys_thread_t thread_info;
_ksys_thread_info(&thread_info, KSYS_THIS_SLOT);
pid = thread_info.pid;
asm_inline("int $0x40" ::"a"(18), "b"(22), "c"(1), "d"(pid));
}
void KOLIBRI_RestoreWindow(_THIS, SDL_Window *window)
{
asm_inline("int $0x40" ::"a"(18), "b"(22), "c"(3), "d"(pid));
}
void KOLIBRI_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
{
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
static int old_w, old_h, old_x, old_y;
static unsigned char old_skin;
if (fullscreen) {
old_w = window->w + (TRUE_WIN_WIDTH - 1);
old_h = window->h + (TRUE_WIN_HEIGHT - 1);
old_x = window->x;
old_y = window->y;
old_skin = wdata->skin;
wdata->skin = 0x01;
_ksys_change_window(0, 0, _ksys_screen_size().x + 1, _ksys_screen_size().y + 1);
} else {
wdata->skin = old_skin;
_ksys_change_window(old_x, old_y, old_w, old_h);
}
}
void KOLIBRI_SetWindowPosition(_THIS, SDL_Window *window) void KOLIBRI_SetWindowPosition(_THIS, SDL_Window *window)
{ {
KOLIBRI_change_window_size_and_pos(window->w, window->h, window->x, window->y); _ksys_change_window(window->x, window->y, window->w + (TRUE_WIN_WIDTH - 1), window->h + (TRUE_WIN_HEIGHT - 1));
}
void KOLIBRI_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
{
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
if (resizable)
wdata->skin = 0x33;
else
wdata->skin = 0x34;
KOLIBRI_RepaintWnd(_this);
} }
void KOLIBRI_SetWindowSize(_THIS, SDL_Window *window) void KOLIBRI_SetWindowSize(_THIS, SDL_Window *window)
{ {
KOLIBRI_change_window_size_and_pos(window->w, window->h, window->x, window->y); _ksys_change_window(window->x, window->y, window->w + (TRUE_WIN_WIDTH - 1), window->h + (TRUE_WIN_HEIGHT - 1));
} }
void KOLIBRI_SetWindowTitle(_THIS, SDL_Window *window) void KOLIBRI_SetWindowTitle(_THIS, SDL_Window *window)
@ -83,4 +133,16 @@ void KOLIBRI_DestroyWindow(_THIS, SDL_Window *window)
SDL_free(window->driverdata); SDL_free(window->driverdata);
} }
SDL_bool KOLIBRI_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
{
/* What is the point of this? What information should be included? */
if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_KOLIBRI;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d", SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
#endif /* SDL_VIDEO_DRIVER_KOLIBRI */ #endif /* SDL_VIDEO_DRIVER_KOLIBRI */

View File

@ -8,7 +8,7 @@
#define WINDOW_BORDER_H 4 #define WINDOW_BORDER_H 4
#define WINDOW_BORDER_W 9 #define WINDOW_BORDER_W 9
#define TRUE_WIN_HEIGHT _ksys_get_skin_height() + WINDOW_BORDER_H; #define TRUE_WIN_HEIGHT _ksys_get_skin_height() + WINDOW_BORDER_H
#define TRUE_WIN_WIDTH WINDOW_BORDER_W #define TRUE_WIN_WIDTH WINDOW_BORDER_W
typedef struct SDL_WindowData typedef struct SDL_WindowData
@ -17,9 +17,17 @@ typedef struct SDL_WindowData
unsigned char skin; unsigned char skin;
} SDL_WindowData; } SDL_WindowData;
extern void KOLIBRI_RepaintWnd(_THIS); void KOLIBRI_RepaintWnd(_THIS);
extern int KOLIBRI_CreateWindow(_THIS, SDL_Window *window); int KOLIBRI_CreateWindow(_THIS, SDL_Window *window);
extern void KOLIBRI_SetWindowTitle(_THIS, SDL_Window *window); void KOLIBRI_MaximizeWindow(_THIS, SDL_Window *window);
extern void KOLIBRI_DestroyWindow(_THIS, SDL_Window *window); void KOLIBRI_MinimizeWindow(_THIS, SDL_Window *window);
void KOLIBRI_RestoreWindow(_THIS, SDL_Window *window);
void KOLIBRI_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen);
void KOLIBRI_SetWindowPosition(_THIS, SDL_Window *window);
void KOLIBRI_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable);
void KOLIBRI_SetWindowSize(_THIS, SDL_Window *window);
void KOLIBRI_SetWindowTitle(_THIS, SDL_Window *window);
void KOLIBRI_DestroyWindow(_THIS, SDL_Window *window);
SDL_bool KOLIBRI_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
#endif /* SDL_kolibriwindow_h_ */ #endif /* SDL_kolibriwindow_h_ */