prefs item "title"

This commit is contained in:
kanjitalk755
2021-02-27 18:29:57 +09:00
parent 2e5654e583
commit 623abaa243
7 changed files with 21 additions and 40 deletions

View File

@@ -546,34 +546,20 @@ static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth, bool nati
} }
// Set window name and class // Set window name and class
static void set_window_name(int name) static void set_window_name() {
{
if (!sdl_window) {
return;
}
const char *str = GetString(name);
SDL_SetWindowTitle(sdl_window, str);
}
static void set_window_name_grabbed() {
if (!sdl_window) return; if (!sdl_window) return;
int hotkey = PrefsFindInt32("hotkey"); const char *title = PrefsFindString("title");
if (!hotkey) hotkey = 1; std::string s = title ? title : GetString(STR_WINDOW_TITLE);
std::string s = GetString(STR_WINDOW_TITLE_GRABBED0); if (mouse_grabbed) {
if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1); s += GetString(STR_WINDOW_TITLE_GRABBED0);
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2); int hotkey = PrefsFindInt32("hotkey");
if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3); if (!hotkey) hotkey = 1;
s += GetString(STR_WINDOW_TITLE_GRABBED4); if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1);
SDL_SetWindowTitle(sdl_window, s.c_str()); if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
} if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3);
s += GetString(STR_WINDOW_TITLE_GRABBED4);
// Set mouse grab mode
static void set_grab_mode(bool grab)
{
if (!sdl_window) {
return;
} }
SDL_SetWindowGrab(sdl_window, grab ? SDL_TRUE : SDL_FALSE); SDL_SetWindowTitle(sdl_window, s.c_str());
} }
// Migrate preferences items (XXX to be handled in MigratePrefs()) // Migrate preferences items (XXX to be handled in MigratePrefs())
@@ -771,7 +757,7 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags
if (!sdl_window) { if (!sdl_window) {
int m = get_mag_rate(); int m = get_mag_rate();
sdl_window = SDL_CreateWindow( sdl_window = SDL_CreateWindow(
GetString(STR_WINDOW_TITLE), "",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
m * window_width, m * window_width,
@@ -781,6 +767,7 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags
shutdown_sdl_video(); shutdown_sdl_video();
return NULL; return NULL;
} }
set_window_name();
} }
if (flags & SDL_WINDOW_FULLSCREEN) SDL_SetWindowGrab(sdl_window, SDL_TRUE); if (flags & SDL_WINDOW_FULLSCREEN) SDL_SetWindowGrab(sdl_window, SDL_TRUE);
@@ -1109,7 +1096,7 @@ void driver_base::adapt_to_video_mode() {
SDL_ShowCursor(hardware_cursor); SDL_ShowCursor(hardware_cursor);
// Set window name/class // Set window name/class
mouse_grabbed ? set_window_name_grabbed() : set_window_name((int)STR_WINDOW_TITLE); set_window_name();
// Everything went well // Everything went well
init_ok = true; init_ok = true;
@@ -1209,7 +1196,7 @@ void driver_base::grab_mouse(void)
if (!mouse_grabbed) { if (!mouse_grabbed) {
mouse_grabbed = true; mouse_grabbed = true;
update_mouse_grab(); update_mouse_grab();
set_window_name_grabbed(); set_window_name();
disable_mouse_accel(); disable_mouse_accel();
ADBSetRelMouseMode(true); ADBSetRelMouseMode(true);
} }
@@ -1221,7 +1208,7 @@ void driver_base::ungrab_mouse(void)
if (mouse_grabbed) { if (mouse_grabbed) {
mouse_grabbed = false; mouse_grabbed = false;
update_mouse_grab(); update_mouse_grab();
set_window_name(STR_WINDOW_TITLE); set_window_name();
restore_mouse_accel(); restore_mouse_accel();
ADBSetRelMouseMode(false); ADBSetRelMouseMode(false);
} }

View File

@@ -212,8 +212,6 @@ enum {
// Mac window // Mac window
STR_WINDOW_TITLE = 4000, STR_WINDOW_TITLE = 4000,
STR_WINDOW_TITLE_FROZEN,
STR_WINDOW_TITLE_GRABBED,
STR_WINDOW_TITLE_GRABBED0, STR_WINDOW_TITLE_GRABBED0,
STR_WINDOW_TITLE_GRABBED1, STR_WINDOW_TITLE_GRABBED1,
STR_WINDOW_TITLE_GRABBED2, STR_WINDOW_TITLE_GRABBED2,

View File

@@ -82,6 +82,7 @@ prefs_desc common_prefs_items[] = {
{"swap_opt_cmd", TYPE_BOOLEAN, false, "swap option and command key"}, {"swap_opt_cmd", TYPE_BOOLEAN, false, "swap option and command key"},
{"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"}, {"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"},
{"host_domain", TYPE_STRING, true, "handle DNS requests for this domain on the host (slirp only)"}, {"host_domain", TYPE_STRING, true, "handle DNS requests for this domain on the host (slirp only)"},
{"title", TYPE_STRING, false, "window title"},
{NULL, TYPE_END, false, NULL} // End of list {NULL, TYPE_END, false, NULL} // End of list
}; };

View File

@@ -225,9 +225,7 @@ user_string_def common_strings[] = {
{STR_JIT_FOLLOW_CONST_JUMPS, "Translate through constant jumps (inline blocks)"}, {STR_JIT_FOLLOW_CONST_JUMPS, "Translate through constant jumps (inline blocks)"},
{STR_WINDOW_TITLE, "Basilisk II"}, {STR_WINDOW_TITLE, "Basilisk II"},
{STR_WINDOW_TITLE_FROZEN, "Basilisk II *** FROZEN ***"}, {STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED, "Basilisk II (mouse grabbed, press Ctrl-F5 to release)"},
{STR_WINDOW_TITLE_GRABBED0, "Basilisk II (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, {STR_WINDOW_TITLE_GRABBED1, "Ctrl-"},
#ifdef __APPLE__ #ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"}, {STR_WINDOW_TITLE_GRABBED2, "Opt-"},

View File

@@ -165,8 +165,6 @@ enum {
// Mac window // Mac window
STR_WINDOW_TITLE = 4000, STR_WINDOW_TITLE = 4000,
STR_WINDOW_TITLE_FROZEN,
STR_WINDOW_TITLE_GRABBED,
STR_WINDOW_TITLE_GRABBED0, STR_WINDOW_TITLE_GRABBED0,
STR_WINDOW_TITLE_GRABBED1, STR_WINDOW_TITLE_GRABBED1,
STR_WINDOW_TITLE_GRABBED2, STR_WINDOW_TITLE_GRABBED2,

View File

@@ -70,6 +70,7 @@ prefs_desc common_prefs_items[] = {
{"swap_opt_cmd", TYPE_BOOLEAN, false, "swap option and command key"}, {"swap_opt_cmd", TYPE_BOOLEAN, false, "swap option and command key"},
{"host_domain", TYPE_STRING, true, "handle DNS requests for this domain on the host (slirp only)"}, {"host_domain", TYPE_STRING, true, "handle DNS requests for this domain on the host (slirp only)"},
{"redir", TYPE_STRING, true, "port forwarding for slirp"}, {"redir", TYPE_STRING, true, "port forwarding for slirp"},
{"title", TYPE_STRING, false, "window title"},
{NULL, TYPE_END, false, NULL} // End of list {NULL, TYPE_END, false, NULL} // End of list
}; };

View File

@@ -171,9 +171,7 @@ user_string_def common_strings[] = {
{STR_JIT_68K_CTRL, "Enable built-in 68k DR Emulator (EXPERIMENTAL)"}, {STR_JIT_68K_CTRL, "Enable built-in 68k DR Emulator (EXPERIMENTAL)"},
{STR_WINDOW_TITLE, "SheepShaver"}, {STR_WINDOW_TITLE, "SheepShaver"},
{STR_WINDOW_TITLE_FROZEN, "SheepShaver *** FROZEN ***"}, {STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED, "SheepShaver (mouse grabbed, press Ctrl-F5 to release)"},
{STR_WINDOW_TITLE_GRABBED0, "SheepShaver (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, {STR_WINDOW_TITLE_GRABBED1, "Ctrl-"},
#ifdef __APPLE__ #ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"}, {STR_WINDOW_TITLE_GRABBED2, "Opt-"},