GL: use Ctrl-UP/Ctrl-DOWN

GL: use Ctrl-UP/Ctrl-DOWN instead of UP/DOWN in order not to interfere
with import/file keybindings.
This commit is contained in:
Martin Pulec
2019-11-26 16:45:05 +01:00
parent 184b51997e
commit 8deeeeb4fa
2 changed files with 13 additions and 4 deletions

View File

@@ -110,6 +110,8 @@ private:
#define K_RIGHT 0x1b5b43
#define K_LEFT 0x1b5b44
#define K_CTRL(x) (1 + ((x) >= 'A' && (x) <= 'Z' ? (x) - 'A' + 'a' : (x)) - 'a')
#define K_CTRL_UP 0x1b5b313b3541LL
#define K_CTRL_DOWN 0x1b5b313b3542LL
#define K_ALT(x) ('\e' << 8 | (x)) /// exception - include ESC, otherwise Alt-a would become 'a'
#define MAX_KEYCODE_NAME_LEN 8

View File

@@ -182,8 +182,8 @@ void main()
const static list<pair<int64_t, string>> keybindings {{'f', "toggle fullscreen"},
{'q', "quit"}, {'d', "toggle deinterlace"}, {'p', "pause video"},
{K_ALT('s'), "screenshot"}, {K_ALT('c'), "show/hide cursor"},
{K_DOWN, "make window smaller by a factor of 50%"},
{K_UP, "make window twice as big"}
{K_CTRL_DOWN, "make window smaller by a factor of 50%"},
{K_CTRL_UP, "make window twice as big"}
};
#ifdef HWACC_VDPAU
@@ -1002,6 +1002,13 @@ static int64_t translate_glut_to_ug(int key, bool is_special) {
}
#endif // defined FREEGLUT
if (is_special) {
if (glutGetModifiers() == GLUT_ACTIVE_CTRL) {
switch (key) {
case GLUT_KEY_UP: return K_CTRL_UP;
case GLUT_KEY_DOWN: return K_CTRL_DOWN;
default: return -1;
}
}
switch (key) {
case GLUT_KEY_LEFT: return K_LEFT;
case GLUT_KEY_UP: return K_UP;
@@ -1057,12 +1064,12 @@ static bool display_gl_process_key(struct state_gl *s, long long int key)
LOG(LOG_LEVEL_NOTICE) << MOD_NAME << "Show cursor (0 - on, 1 - off, 2 - autohide): " << s->show_cursor << "\n";
glutSetCursor(s->show_cursor == state_gl::SC_TRUE ? GLUT_CURSOR_INHERIT : GLUT_CURSOR_NONE);
break;
case K_UP:
case K_CTRL_UP:
s->window_size_factor *= 2;
glut_resize_window(s->fs, s->current_display_desc.height, s->aspect,
s->window_size_factor);
break;
case K_DOWN:
case K_CTRL_DOWN:
s->window_size_factor /= 2;
glut_resize_window(s->fs, s->current_display_desc.height, s->aspect,
s->window_size_factor);