SDL: now window is always centered.

git-svn-id: svn://kolibrios.org@9769 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-04-15 22:15:59 +00:00
parent 635fbac815
commit bfe9af6494
3 changed files with 101 additions and 107 deletions

View File

@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ksys.h>
#include "SDL.h"
#include "SDL_error.h"
@ -113,32 +114,6 @@ static SDL_GrabMode SDL_WM_GrabInputOff(void);
static int lock_count = 0;
#endif
typedef union{
unsigned val;
struct{
short x;
short y;
};
}ksys_pos_t;
static inline
ksys_pos_t _ksys_screen_size()
{
ksys_pos_t size;
ksys_pos_t size_tmp;
__asm__ __volatile__(
"int $0x40"
:"=a"(size_tmp)
:"a"(14)
:"memory"
);
size.x = size_tmp.y;
size.y = size_tmp.x;
return size;
}
/*
* Initialize the video and event subsystems -- determine native pixel format
*/

View File

@ -1,5 +1,6 @@
#include <menuet/os.h>
#include <kos32sys.h>
#include <sys/ksys.h>
#include <stdlib.h>
#include <stdio.h>
#include "SDL.h"
@ -200,7 +201,10 @@ void MenuetOS_PumpEvents(_THIS)
SDL_PrivateKeyboard(code,&key);
break;
case 3:
if(get_os_button()==1) exit(0);
if (_ksys_get_button()==1) {
SDL_CloseAudio();
exit(0);
}
break;
case 6: {
int __tmp,mx,my;

View File

@ -11,7 +11,8 @@
#include <string.h>
static SDL_VideoDevice * vm_suf=NULL;
static int was_initialized=0;
static int was_initialized = 0;
static int scrn_size_defined = 0;
static int has_null_cursor=0;
static void* null_cursor;
@ -19,12 +20,22 @@ static void* null_cursor;
#define WINDOW_BORDER_H 4
#define WINDOW_BORDER_W 9
ksys_pos_t screen_size = {0};
void kos_SDL_RepaintWnd(void)
{
int win_pos_x, win_pos_y;
int win_size_w = vm_suf->hidden->win_size_x+WINDOW_BORDER_W;
int win_size_h = vm_suf->hidden->win_size_y+_ksys_get_skin_height()+WINDOW_BORDER_H;
if (!screen_size.val) {
screen_size = _ksys_screen_size();
win_pos_x = screen_size.x/2-win_size_w/2;
win_pos_y = screen_size.y/2-win_size_h/2;
}
_ksys_start_draw();
_ksys_create_window(1, 1, vm_suf->hidden->win_size_x+WINDOW_BORDER_W,
vm_suf->hidden->win_size_y+_ksys_get_skin_height()+ WINDOW_BORDER_H,
vm_suf->hidden->__title, 0, 0x34);
_ksys_create_window(win_pos_x, win_pos_y, win_size_w, win_size_h, vm_suf->hidden->__title, 0, 0x34);
if (vm_suf && vm_suf->hidden->__video_buffer) {
_ksys_draw_bitmap(vm_suf->hidden->__video_buffer, 0, 0,
@ -105,7 +116,9 @@ SDL_Surface *kos_SetVideoMode(_THIS, SDL_Surface *current, int width, int height
if (was_initialized) {
unsigned newheight = height+_ksys_get_skin_height()+WINDOW_BORDER_H;
unsigned newwidth = width+WINDOW_BORDER_W;
_ksys_change_window(-1, -1, newwidth, newheight);
int win_pos_x = screen_size.x/2-newwidth/2;
int win_pos_y = screen_size.y/2-newheight/2;
_ksys_change_window(win_pos_x, win_pos_y, newwidth, newheight);
} else {
_ksys_set_event_mask(0x27);
was_initialized=1;
@ -200,6 +213,7 @@ void kos_FreeWMCursor(_THIS, WMcursor* cursor)
{
_ksys_delete_cursor(cursor);
}
void kos_CheckMouseMode(_THIS)
{
if (this->input_grab == SDL_GRAB_OFF)
@ -223,6 +237,7 @@ static SDL_VideoDevice *kos_CreateDevice(int indx)
memset(dev,0,(sizeof *dev));
dev->hidden = (struct SDL_PrivateVideoData*)malloc((sizeof *dev->hidden));
}
if ((dev==NULL) || (dev->hidden==NULL)) {
SDL_OutOfMemory();
if(dev) {
@ -263,7 +278,7 @@ static SDL_VideoDevice *kos_CreateDevice(int indx)
return dev;
}
VideoBootStrap mosvideo_bootstrab={
VideoBootStrap mosvideo_bootstrab = {
"kolibrios", "KolibriOS Device Driver",
kos_Available, kos_CreateDevice,
};