diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2020-01-18 18:20:00 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-05-07 14:57:15 +0200 |
commit | afceb7ebaed13dd680a1acfb8354b736a1fd2cc3 (patch) | |
tree | b9991ad80c428cde0dcbfa075bed3af13c1e1afc /nx-X11/programs/Xserver/hw/nxagent/Dialog.c | |
parent | b7169bdcaf320e219dec23e79882176bc4b69d4c (diff) | |
download | nx-libs-afceb7ebaed13dd680a1acfb8354b736a1fd2cc3.tar.gz nx-libs-afceb7ebaed13dd680a1acfb8354b736a1fd2cc3.tar.bz2 nx-libs-afceb7ebaed13dd680a1acfb8354b736a1fd2cc3.zip |
Dialog.c: show configured keystrokes in dialogs
Instead of hardcoding the keystrokes in Dialog.h determine the
currently configured keystrokes for the action and insert them into
the dialog strings.
Fixes ArcticaProject/nx-libs#438
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Dialog.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c index 2d4eb6229..808e1501f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c @@ -41,6 +41,7 @@ #include "Display.h" #include "Dialog.h" #include "Utils.h" +#include "Keystroke.h" #include <nx/NX.h> #include "compext/Compext.h" @@ -187,6 +188,7 @@ void nxagentLaunchDialog(DialogType dialogType) int *pid; char *type; char *message; + char *strings[2] = {NULL}; /* don't forget to add free() calls if you change the number */ int local; const char *window = NULL; @@ -247,6 +249,7 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_TYPE; local = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_LOCAL; pid = &nxagentEnableRandRModeDialogPid; + strings[0] = nxagentFindFirstKeystroke("resize"); break; } case DIALOG_DISABLE_DESKTOP_RESIZE_MODE: @@ -255,6 +258,8 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_TYPE; local = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_LOCAL; pid = &nxagentDisableRandRModeDialogPid; + strings[0] = nxagentFindFirstKeystroke("resize"); + strings[1] = nxagentFindMatchingKeystrokes("viewport_"); break; } case DIALOG_ENABLE_DEFER_MODE: @@ -263,6 +268,7 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ENABLE_DEFER_MODE_TYPE; local = DIALOG_ENABLE_DEFER_MODE_LOCAL; pid = &nxagentEnableDeferModePid; + strings[0] = nxagentFindFirstKeystroke("defer"); break; } case DIALOG_DISABLE_DEFER_MODE: @@ -271,6 +277,7 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_DISABLE_DEFER_MODE_TYPE; local = DIALOG_DISABLE_DEFER_MODE_LOCAL; pid = &nxagentDisableDeferModePid; + strings[0] = nxagentFindFirstKeystroke("defer"); break; } case DIALOG_ENABLE_AUTOGRAB_MODE: @@ -279,6 +286,7 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ENABLE_AUTOGRAB_MODE_TYPE; local = DIALOG_ENABLE_AUTOGRAB_MODE_LOCAL; pid = &nxagentEnableAutograbModePid; + strings[0] = nxagentFindFirstKeystroke("autograb"); break; } case DIALOG_DISABLE_AUTOGRAB_MODE: @@ -287,6 +295,7 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_DISABLE_AUTOGRAB_MODE_TYPE; local = DIALOG_DISABLE_AUTOGRAB_MODE_LOCAL; pid = &nxagentDisableAutograbModePid; + strings[0] = nxagentFindFirstKeystroke("autograb"); break; } default: @@ -321,6 +330,17 @@ void nxagentLaunchDialog(DialogType dialogType) return; } + char *msg = NULL; + if (-1 == asprintf(&msg, message, strings[0], strings[1])) + { + #ifdef DEBUG + fprintf(stderr, "%s: could not allocate message string.\n", __func__); + #endif + SAFE_free(strings[0]); + SAFE_free(strings[1]); + return; + } + /* * We don't want to receive SIGCHLD before we store the child pid. */ @@ -331,9 +351,13 @@ void nxagentLaunchDialog(DialogType dialogType) sigprocmask(SIG_BLOCK, &set, &oldSet); - *pid = NXTransDialog(nxagentDialogName, message, window, + *pid = NXTransDialog(nxagentDialogName, msg, window, type, local, dialogDisplay); + SAFE_free(strings[0]); + SAFE_free(strings[1]); + SAFE_free(msg); + #ifdef TEST fprintf(stderr, "nxagentLaunchDialog: Launched dialog %s with pid [%d] on display %s.\n", DECODE_DIALOG_TYPE(dialogType), *pid, dialogDisplay); |