Implement window title setting

This commit is contained in:
Cacodemon345
2021-08-23 14:09:43 +06:00
parent 1678783db5
commit e0b36b52ca
3 changed files with 57 additions and 5 deletions

View File

@@ -24,7 +24,7 @@
#include <86box/unix_sdl.h>
#include <86box/timer.h>
#include <86box/nvr.h>
#include <86box/unix_sdl.h>
static int first_use = 1;
static uint64_t StartingTime;
static uint64_t Frequency;
@@ -203,6 +203,15 @@ void dynld_close(void *handle)
wchar_t* plat_get_string(int i)
{
switch (i)
{
case IDS_2077:
return L"Click to capture mouse.";
case IDS_2078:
return L"Press F12-F8 to release mouse";
case IDS_2079:
return L"Press F12-F8 or middle button to release mouse";
}
return L"";
}
@@ -497,19 +506,21 @@ do_stop(void)
int ui_msgbox(int flags, void *message)
{
fprintf(stderr, "Got msgbox request. Flags: 0x%X, msgid: %llu\n", flags, (uint64_t) message);
return 0;
}
int ui_msgbox_header(int flags, void *message, void* header)
{
// Parameters that are passed will crash the program so keep these off for the time being.
fprintf(stderr, "Got msgbox request. Flags: 0x%X, msgid: %llu, hdrid: %llu\n", flags, (uint64_t) message, (uint64_t) header);
return 0;
}
void plat_get_exe_name(char *s, int size)
{
char* basepath = SDL_GetBasePath();
snprintf(s, size, "%s/86box", basepath);
snprintf(s, size, "%s%s", basepath, basepath[strlen(basepath) - 1] == '/' ? "86box" : "/86box");
}
void
@@ -533,7 +544,6 @@ wchar_t* ui_sb_bugui(wchar_t *str)
extern void sdl_blit(int x, int y, int y1, int y2, int w, int h);
int numlock = 0;
void ui_window_title(wchar_t* str) {}
void ui_sb_set_ready(int ready) {}
int main(int argc, char** argv)
{
@@ -565,10 +575,10 @@ int main(int argc, char** argv)
/* Initialize the rendering window, or fullscreen. */
do_start();
while (!is_quit)
{
static int onesec_tic = 0;
if (SDL_PollEvent(&event))
switch(event.type)
{
@@ -606,6 +616,11 @@ int main(int argc, char** argv)
extern void sdl_blit(int x, int y, int y1, int y2, int w, int h);
sdl_blit(params.x, params.y, params.y1, params.y2, params.w, params.h);
}
if (SDL_GetTicks() - onesec_tic >= 1000)
{
onesec_tic = SDL_GetTicks();
pc_onesec();
}
}
SDL_DestroyMutex(blitmtx);

View File

@@ -15,6 +15,7 @@
#include <86box/video.h>
#include <86box/ui.h>
#include <86box/version.h>
#include <86box/unix_sdl.h>
#define RENDERER_FULL_SCREEN 1
#define RENDERER_HARDWARE 2
@@ -418,3 +419,22 @@ void plat_resize(int w, int h)
{
SDL_SetWindowSize(sdl_win, w, h);
}
wchar_t sdl_win_title[512] = L"86Box";
wchar_t* ui_window_title(wchar_t* str)
{
char* res;
if (!res) return sdl_win_title;
if (sizeof(wchar_t) == 1)
{
SDL_SetWindowTitle(sdl_win, (char*)str);
return str;
}
res = SDL_iconv_string("UTF-8", sizeof(wchar_t) == 2 ? "UTF-16LE" : "UTF-32LE", (char*)str, wcslen(str) * sizeof(wchar_t));
if (res)
{
SDL_SetWindowTitle(sdl_win, res);
wcsncpy(sdl_win_title, str, 512);
SDL_free((void*)res);
}
return str;
}

View File

@@ -15,11 +15,28 @@ typedef struct event_pthread_t
int state;
} event_pthread_t;
typedef struct thread_param
{
void (*thread_rout)(void*);
void* param;
} thread_param;
void* thread_run_wrapper(thread_param* arg)
{
thread_param localparam = *arg;
free(arg);
localparam.thread_rout(localparam.param);
return NULL;
}
thread_t *thread_create(void (*thread_rout)(void *param), void *param)
{
pthread_t *thread = malloc(sizeof(pthread_t));
thread_param *thrparam = malloc(sizeof(thread_param));
thrparam->thread_rout = thread_rout;
thrparam->param = param;
pthread_create(thread, NULL, (void*)thread_rout, param);
pthread_create(thread, NULL, (void* (*)(void*))thread_run_wrapper, thrparam);
return thread;
}