Skip to content

Commit

Permalink
toggle mouse pointer to be displayed locally with space bar
Browse files Browse the repository at this point in the history
  • Loading branch information
HouzuoGuo committed Feb 9, 2017
1 parent d04d1b9 commit 8aa79f4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ In general, the left hand side keys pan and zoom viewer, the right hand side key
You are most welcomed to contribute code and file bug report, feature request, and questions in the project's [issues page](https://github.com/HouzuoGuo/headmore/issues), you may also direct any inquiry to the author in [Email](mailto:guohouzuo@gmail.com).

## License
Copyright (c) 2016 Howard Guo <guohouzuo@gmail.com>
Copyright (c) 2017 Howard Guo <guohouzuo@gmail.com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

Expand Down
18 changes: 9 additions & 9 deletions geo.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <string.h>
#include "geo.h"

struct geo_facts geo_facts_of(struct vnc *vnc, caca_display_t * disp,
caca_canvas_t * view)
struct geo_facts
geo_facts_of(struct vnc *vnc, caca_display_t * disp, caca_canvas_t * view)
{
struct geo_facts ret;
ret.px_width = caca_get_display_width(disp);
Expand Down Expand Up @@ -55,9 +55,9 @@ void geo_zoom(struct geo *g, struct geo_facts facts, int offset)
(g->zoom <
0) ? 1.0 / g->zoom_lvls[-g->zoom] : g->zoom_lvls[g->zoom];
g->zoom_y =
g->zoom_x * facts.ch_width / facts.ch_height *
facts.vnc_height / facts.vnc_width * facts.ch_height /
facts.ch_width * facts.px_width / facts.px_height;
g->zoom_x * facts.ch_width / facts.ch_height * facts.vnc_height /
facts.vnc_width * facts.ch_height / facts.ch_width *
facts.px_width / facts.px_height;

if (g->zoom_y > g->zoom_x) {
float tmp = g->zoom_x;
Expand Down Expand Up @@ -90,8 +90,8 @@ void geo_pan(struct geo *g, int pan_x, int pan_y)
}
}

void geo_move_mouse(struct geo *g, struct geo_facts facts, int step_x,
int step_y)
void
geo_move_mouse(struct geo *g, struct geo_facts facts, int step_x, int step_y)
{
int speed = g->mouse_speed[g->zoom];
g->mouse_x += step_x * speed;
Expand All @@ -117,8 +117,8 @@ void geo_zoom_to_cursor(struct geo *g, struct geo_facts facts)
g->view_y = (float)g->mouse_y / (float)facts.vnc_height;
}

struct geo_dither_params geo_get_dither_params(struct geo *g,
struct geo_facts facts)
struct geo_dither_params
geo_get_dither_params(struct geo *g, struct geo_facts facts)
{
struct geo_dither_params ret;
ret.facts = facts;
Expand Down
6 changes: 5 additions & 1 deletion headmore.1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Pan viewer up, left, down, or right.
.B Q, E
Zoom out or in on the viewer.
.
.TP
.B Space bar
Toggle display mouse pointer locally. Mouse pointer is always displayed locally if current zoom is very far out.
.

.P
And the right hand side controls are:
Expand Down Expand Up @@ -117,4 +121,4 @@ Somewhat verbose messages from LibVNCClient and headmore are placed here, might
You are most welcomed to file bug report, feature request, and questions in the project's Github page (https://github.com/HouzuoGuo/headmore), you may also direct any inquiry to the author in Email.

.SH AUTHOR
Howard Guo <guohouzuo@gmail.com>, 2016
Howard Guo <guohouzuo@gmail.com>, 2017
Binary file modified key-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static char const *viewer_help[] = {
"~ Click back-tick in VNC ",
"wasd Pan viewer ",
"q/e Zoom out/in ",
"Space Toggle display mouse pointer ",
"============ RIGHT HAND ===========",
"F10 Quit ",
"ijkl Move mouse cursor ",
Expand All @@ -45,6 +46,7 @@ static struct _rfbClient *rfb(struct viewer *v)

bool viewer_init(struct viewer * v, struct vnc * vnc)
{
/* All bool switches are off by default */
memset(v, 0, sizeof(struct viewer));
/* Initialise visuals */
v->view = caca_create_canvas(0, 0);
Expand Down Expand Up @@ -170,14 +172,19 @@ void viewer_redraw(struct viewer *v)
/*
* Mouse cursors are usually wider than 14 pixels. If it will not take
* more than 5 characters to draw the cusor, then consider it very
* difficult to spot on the VNC canvas, and draw an easy to spot block
* right there.
* difficult to spot on the VNC canvas, and draw a red block right there.
*/
int mouse_ch_x = geo_dither_ch_px_x(&params, v->geo.mouse_x);
int mouse_ch_y = geo_dither_ch_px_y(&params, v->geo.mouse_y);
if (geo_dither_numch_x(&params, 12) < 5) {
caca_set_color_ansi(v->view, CACA_WHITE, CACA_RED);
int ch_x = geo_dither_ch_px_x(&params, v->geo.mouse_x);
int ch_y = geo_dither_ch_px_y(&params, v->geo.mouse_y);
caca_fill_box(v->view, ch_x - 1, ch_y - 1, 3, 3, '*');
caca_fill_box(v->view, mouse_ch_x - 1, mouse_ch_y - 1, 3, 3,
'*');
}
/* Draw local mouse pointer */
if (v->draw_mouse_pointer) {
caca_set_color_ansi(v->view, CACA_WHITE, CACA_RED);
caca_put_char(v->view, mouse_ch_x, mouse_ch_y, '*');
}
viewer_disp_status(v);
if (v->disp_help) {
Expand Down Expand Up @@ -440,6 +447,9 @@ bool viewer_handle_control(struct viewer * v, int caca_key)
/* Click back-tick (96 in ASCII) in VNC */
viewer_vnc_click_key(v, 96);
break;
case ' ':
v->draw_mouse_pointer = !v->draw_mouse_pointer;
break;
/* Right hand */
case 'i':
case 'I':
Expand Down
1 change: 1 addition & 0 deletions viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct viewer {
bool disp_help, input2vnc;
bool hold_lctrl, hold_lshift, hold_lalt, hold_lsuper, hold_ralt,
hold_rshift, hold_rctrl;
bool draw_mouse_pointer;
bool mouse_left, mouse_middle, mouse_right;
};

Expand Down

0 comments on commit 8aa79f4

Please sign in to comment.