Re: [hatari-devel] Keyboard shortcut to toggle Atari borders?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 11/19/2017 04:51 PM, Thomas Huth wrote:
Am Sun, 19 Nov 2017 13:23:44 +0200
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
Attached is patch implementing Borders shortcut, could you try it?

I think you don't have to add anything new to the
configs_ShortCut*Mod_Sdl1 arrays since they are only used for
loading legacy config files, but not for saving new data.

I see, I hadn't noticed that earlier.


And I think you also have to adapt gui-sdl/dlgKeyboard.c for
the new shortcut accordingly.

Yes, it appears to crash without it.

Attached is a fixed patch.


Thanks!

	- Eero

PS. Shortcut for toggling borders is actually quite handy.
I usually run Hatari without borders as they're empty for
most programs, so it's nice to be able to quickly toggle
it ON to check whether program actually has drawn something
to the borders...
diff -r 6f5bb2fa5270 src/configuration.c
--- a/src/configuration.c	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/configuration.c	Sun Nov 19 23:54:04 2017 +0200
@@ -329,6 +329,7 @@
 {
 	{ "kOptions",    Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] },
 	{ "kFullScreen", Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] },
+	{ "kBorders",    Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_BORDERS] },
 	{ "kMouseMode",  Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] },
 	{ "kColdReset",  Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] },
 	{ "kWarmReset",  Key_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] },
@@ -357,6 +358,7 @@
 {
 	{ "kOptions",    Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] },
 	{ "kFullScreen", Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] },
+	{ "kBorders",    Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_BORDERS] },
 	{ "kMouseMode",  Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MOUSEGRAB] },
 	{ "kColdReset",  Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_COLDRESET] },
 	{ "kWarmReset",  Key_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_WARMRESET] },
@@ -692,6 +694,7 @@
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG] = SDLK_PAUSE;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] = SDLK_o;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] = SDLK_f;
+	ConfigureParams.Shortcut.withModifier[SHORTCUT_BORDERS] = SDLK_b;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] = SDLK_m;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] = SDLK_c;
 	ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] = SDLK_r;
diff -r 6f5bb2fa5270 src/gui-sdl/dlgKeyboard.c
--- a/src/gui-sdl/dlgKeyboard.c	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/gui-sdl/dlgKeyboard.c	Sun Nov 19 23:54:04 2017 +0200
@@ -72,6 +72,7 @@
 static char *sc_names[SHORTCUT_KEYS] = {
 	"Edit settings",
 	"Toggle fullscreen",
+	"Toggle borders",
 	"Grab mouse",
 	"Cold reset",
 	"Warm reset",
diff -r 6f5bb2fa5270 src/includes/configuration.h
--- a/src/includes/configuration.h	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/includes/configuration.h	Sun Nov 19 23:54:04 2017 +0200
@@ -88,6 +88,7 @@
 typedef enum {
   SHORTCUT_OPTIONS,
   SHORTCUT_FULLSCREEN,
+  SHORTCUT_BORDERS,
   SHORTCUT_MOUSEGRAB,
   SHORTCUT_COLDRESET,
   SHORTCUT_WARMRESET,
diff -r 6f5bb2fa5270 src/shortcut.c
--- a/src/shortcut.c	Sun Nov 19 00:02:27 2017 +0200
+++ b/src/shortcut.c	Sun Nov 19 23:54:04 2017 +0200
@@ -50,6 +50,15 @@
 	}
 }
 
+/*-----------------------------------------------------------------------*/
+/**
+ * Shortcut to toggle borders
+ */
+static void ShortCut_Borders(void)
+{
+	ConfigureParams.Screen.bAllowOverscan = !ConfigureParams.Screen.bAllowOverscan;
+	Screen_ModeChanged(false);  /* false: re-create window only if size changed */
+}
 
 /*-----------------------------------------------------------------------*/
 /**
@@ -281,6 +290,9 @@
 	 case SHORTCUT_FULLSCREEN:
 		ShortCut_FullScreen();		/* Switch between fullscreen/windowed mode */
 		break;
+	 case SHORTCUT_BORDERS:
+		ShortCut_Borders();		/* Toggle Atari borders */
+		break;
 	 case SHORTCUT_MOUSEGRAB:
 		ShortCut_MouseGrab();		/* Toggle mouse grab */
 		break;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/