Fix horizontal panning
Fix linux fb keymap svn path=/trunk/netsurf/; revision=6613
This commit is contained in:
parent
5d2c6f8ad9
commit
b6c4a4589f
|
@ -592,58 +592,116 @@ void fb_os_quit(framebuffer_t *fb)
|
|||
fb_cleanup();
|
||||
}
|
||||
|
||||
|
||||
static int keymap[] = {
|
||||
-1, -1, '1', '2', '3', '4', '5', '6', '7', '8', /* 0 - 9 */
|
||||
'9', '0', '-', '=', 8, 9, 'q', 'w', 'e', 'r', /* 10 - 19 */
|
||||
't', 'y', 'u', 'i', 'o', 'p', '[', ']', 13, -1, /* 20 - 29 */
|
||||
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 30 - 39 */
|
||||
'\'', '#', -1, '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 40 - 49 */
|
||||
'm', ',', '.', '/', -1, -1, -1, ' ', -1, -1, /* 50 - 59 */
|
||||
};
|
||||
|
||||
static int sh_keymap[] = {
|
||||
-1, -1, '!', '"', '£', '$', '%', '^', '&', '*', /* 0 - 9 */
|
||||
'(', ')', '_', '+', 8, 9, 'Q', 'W', 'E', 'R', /* 10 - 19 */
|
||||
'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 13, -1, /* 20 - 29 */
|
||||
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', /* 30 - 39 */
|
||||
'@', '~', -1, '|', 'Z', 'X', 'C', 'V', 'B', 'N', /* 40 - 49 */
|
||||
'M', '<', '>', '?', -1, -1, -1, ' ', -1, -1, /* 50 - 59 */
|
||||
};
|
||||
|
||||
|
||||
/* performs character mapping */
|
||||
static int keycode_to_ascii(int code, bool shift)
|
||||
{
|
||||
int ascii = -1;
|
||||
|
||||
if (shift) {
|
||||
if ((code >= 0) && (code < sizeof(sh_keymap)))
|
||||
ascii = sh_keymap[code];
|
||||
} else {
|
||||
if ((code >= 0) && (code < sizeof(keymap)))
|
||||
ascii = keymap[code];
|
||||
}
|
||||
return ascii;
|
||||
}
|
||||
|
||||
void fb_os_input(struct gui_window *g, bool active)
|
||||
{
|
||||
ssize_t amt;
|
||||
struct input_event event;
|
||||
fb_input_dev *d;
|
||||
|
||||
int ascii = -1;
|
||||
static bool shift = false;
|
||||
|
||||
for (d = inputdevs; d != NULL; d = d->next) {
|
||||
amt = read(d->fd, &event, sizeof(struct input_event));
|
||||
|
||||
if (amt > 0) {
|
||||
if (event.type == EV_KEY) {
|
||||
if (event.value == 0)
|
||||
if (event.value == 0) {
|
||||
/* key up */
|
||||
switch (event.code) {
|
||||
case KEY_LEFTSHIFT:
|
||||
case KEY_RIGHTSHIFT:
|
||||
shift = false;
|
||||
break;
|
||||
|
||||
case BTN_LEFT:
|
||||
fb_rootwindow_click(g,
|
||||
BROWSER_MOUSE_CLICK_1,
|
||||
fb_cursor_x(framebuffer),
|
||||
fb_cursor_y(framebuffer));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.code) {
|
||||
case KEY_J:
|
||||
case KEY_PAGEDOWN:
|
||||
fb_window_scroll(g, 0, g->height);
|
||||
break;
|
||||
|
||||
case KEY_PAGEUP:
|
||||
fb_window_scroll(g, 0, -g->height);
|
||||
break;
|
||||
|
||||
case KEY_DOWN:
|
||||
fb_window_scroll(g, 0, 100);
|
||||
break;
|
||||
|
||||
case KEY_K:
|
||||
|
||||
case KEY_UP:
|
||||
fb_window_scroll(g, 0, -100);
|
||||
break;
|
||||
|
||||
case KEY_Q:
|
||||
browser_window_destroy(g->bw);
|
||||
break;
|
||||
|
||||
case KEY_D:
|
||||
list_schedule();
|
||||
break;
|
||||
|
||||
case KEY_UP:
|
||||
fb_cursor_move(framebuffer, 0, -1);
|
||||
break;
|
||||
|
||||
case KEY_DOWN:
|
||||
fb_cursor_move(framebuffer, 0, 1);
|
||||
break;
|
||||
|
||||
|
||||
case KEY_LEFT:
|
||||
fb_cursor_move(framebuffer, -1, 0);
|
||||
fb_window_scroll(g, -100, 0);
|
||||
break;
|
||||
|
||||
case KEY_RIGHT:
|
||||
fb_cursor_move(framebuffer, 1, 0);
|
||||
fb_window_scroll(g, 100, 0);
|
||||
break;
|
||||
|
||||
case KEY_ESC:
|
||||
browser_window_destroy(g->bw);
|
||||
break;
|
||||
|
||||
case BTN_LEFT:
|
||||
fb_rootwindow_click(g,
|
||||
BROWSER_MOUSE_CLICK_1,
|
||||
BROWSER_MOUSE_PRESS_1,
|
||||
fb_cursor_x(framebuffer),
|
||||
fb_cursor_y(framebuffer));
|
||||
break;
|
||||
|
||||
case KEY_LEFTSHIFT:
|
||||
case KEY_RIGHTSHIFT:
|
||||
shift = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
ascii = keycode_to_ascii(event.code, shift);
|
||||
|
||||
}
|
||||
} else if (event.type == EV_REL) {
|
||||
switch (event.code) {
|
||||
|
@ -660,6 +718,12 @@ void fb_os_input(struct gui_window *g, bool active)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ascii != -1) {
|
||||
fb_rootwindow_input(g, ascii);
|
||||
ascii = -1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,18 +126,14 @@ void fb_os_input(struct gui_window *g, bool active)
|
|||
break;
|
||||
|
||||
case SDLK_LEFT:
|
||||
if (history_back_available(g->bw->history))
|
||||
history_back(g->bw, g->bw->history);
|
||||
fb_window_scroll(g, -100, 0);
|
||||
break;
|
||||
|
||||
case SDLK_RIGHT:
|
||||
if (history_forward_available(g->bw->history))
|
||||
history_forward(g->bw, g->bw->history);
|
||||
fb_window_scroll(g, 100, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("The %s key was pressed!\n",
|
||||
SDL_GetKeyName(event.key.keysym.sym));
|
||||
fb_rootwindow_input(g, event.key.keysym.sym);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,14 @@ static void fb_pan(struct gui_window *g)
|
|||
if ((g->scrolly + g->pany) > (c->height - g->height))
|
||||
g->pany = (c->height - g->height) - g->scrolly;
|
||||
|
||||
/* dont pan off the left */
|
||||
if ((g->scrollx + g->panx) < 0)
|
||||
g->panx = - g->scrollx;
|
||||
|
||||
/* do not pan off the right of the content */
|
||||
if ((g->scrollx + g->panx) > (c->width - g->width))
|
||||
g->panx = (c->width - g->width) - g->scrollx;
|
||||
|
||||
LOG(("panning %d, %d",g->panx, g->pany));
|
||||
|
||||
/* pump up the volume. dance, dance! lets do it */
|
||||
|
@ -117,6 +125,36 @@ static void fb_pan(struct gui_window *g)
|
|||
g->width, g->height);
|
||||
}
|
||||
|
||||
if (g->panx < 0) {
|
||||
/* we cannot pan more than a window width at a time */
|
||||
if (g->panx < -g->width)
|
||||
g->panx = -g->width;
|
||||
|
||||
LOG(("panning left %d", g->panx));
|
||||
|
||||
fb_plotters_move_block(g->x, g->y,
|
||||
g->width + g->panx, g->height ,
|
||||
g->x - g->panx, g->y );
|
||||
g->scrollx += g->panx;
|
||||
fb_queue_redraw(g, 0, 0,
|
||||
- g->panx, g->height);
|
||||
}
|
||||
|
||||
if (g->panx > 0) {
|
||||
/* we cannot pan more than a window width at a time */
|
||||
if (g->panx > g->width)
|
||||
g->panx = g->width;
|
||||
|
||||
LOG(("panning right %d", g->panx));
|
||||
|
||||
fb_plotters_move_block(g->x + g->panx, g->y,
|
||||
g->width - g->panx, g->height,
|
||||
g->x, g->y);
|
||||
g->scrollx += g->panx;
|
||||
fb_queue_redraw(g, g->width - g->panx, 0,
|
||||
g->width, g->height);
|
||||
}
|
||||
|
||||
g->pan_required = false;
|
||||
g->panx = 0;
|
||||
g->pany = 0;
|
||||
|
@ -270,7 +308,9 @@ void gui_poll(bool active)
|
|||
if (redraws_pending == true) {
|
||||
struct gui_window *g;
|
||||
|
||||
fb_cursor_move(framebuffer, fb_cursor_x(framebuffer), fb_cursor_y(framebuffer));
|
||||
fb_cursor_move(framebuffer,
|
||||
fb_cursor_x(framebuffer),
|
||||
fb_cursor_y(framebuffer));
|
||||
|
||||
redraws_pending = false;
|
||||
|
||||
|
|
|
@ -471,18 +471,28 @@ bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx,
|
|||
{
|
||||
uint8_t *srcptr = (framebuffer->ptr +
|
||||
(srcy * framebuffer->linelen) +
|
||||
(srcx));
|
||||
((srcx * framebuffer->bpp) / 8));
|
||||
|
||||
uint8_t *dstptr = (framebuffer->ptr +
|
||||
(dsty * framebuffer->linelen) +
|
||||
(dstx));
|
||||
((dstx * framebuffer->bpp) / 8));
|
||||
|
||||
bbox_t redrawbox;
|
||||
int hloop;
|
||||
|
||||
LOG(("from (%d,%d) w %d h %d to (%d,%d)",srcx,srcy,width,height,dstx,dsty));
|
||||
|
||||
memmove(dstptr, srcptr, (width * height * framebuffer->bpp) / 8);
|
||||
|
||||
if (width == framebuffer->width) {
|
||||
/* take shortcut and use memmove */
|
||||
memmove(dstptr, srcptr, (width * height * framebuffer->bpp) / 8);
|
||||
} else {
|
||||
|
||||
for (hloop = height; hloop > 0; hloop--) {
|
||||
memmove(dstptr, srcptr, (width * framebuffer->bpp) / 8);
|
||||
srcptr += framebuffer->linelen;
|
||||
dstptr += framebuffer->linelen;
|
||||
}
|
||||
}
|
||||
/* callback to the os specific routine in case it needs to do something
|
||||
* explicit to redraw
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue