summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framebuffer/fb_cursor.c41
-rw-r--r--framebuffer/fb_cursor.h2
-rw-r--r--framebuffer/fb_frontend.h2
-rw-r--r--framebuffer/fb_frontend_ablefb.c6
-rw-r--r--framebuffer/fb_frontend_dummy.c7
-rw-r--r--framebuffer/fb_frontend_linuxfb.c5
-rw-r--r--framebuffer/fb_frontend_sdl.c44
-rw-r--r--framebuffer/fb_gui.c2
-rw-r--r--framebuffer/fb_plotters.c16
9 files changed, 114 insertions, 11 deletions
diff --git a/framebuffer/fb_cursor.c b/framebuffer/fb_cursor.c
index 5bd1b1a80..e2c066be7 100644
--- a/framebuffer/fb_cursor.c
+++ b/framebuffer/fb_cursor.c
@@ -34,6 +34,7 @@
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_cursor.h"
+#include "framebuffer/fb_frontend.h"
struct fb_cursor_s {
int x;
@@ -125,6 +126,7 @@ static void fb_cursor_clear(framebuffer_t *fb)
uint8_t *pvid;
int yloop;
int height = fb->cursor->height;
+ bbox_t cursorbox;
if ((fb->height - fb->cursor->y) < height)
height = fb->height - fb->cursor->y ;
@@ -152,15 +154,24 @@ static void fb_cursor_clear(framebuffer_t *fb)
pvid += fb->linelen;
}
+ /* callback to the os specific routine in case it needs to do something
+ * explicit to redraw
+ */
+ cursorbox.x0 = fb->cursor->x;
+ cursorbox.y0 = fb->cursor->y;
+ cursorbox.x1 = fb->cursor->x + fb->cursor->width;
+ cursorbox.y1 = fb->cursor->y + fb->cursor->height;
+ fb_os_redraw(&cursorbox);
+
}
void
-fb_cursor_move(framebuffer_t *fb, int x, int y)
+fb_cursor_move_abs(framebuffer_t *fb, int x, int y)
{
fb_cursor_clear(fb);
- fb->cursor->x += x;
- fb->cursor->y += y;
+ fb->cursor->x = x;
+ fb->cursor->y = y;
if (fb->cursor->x < 0)
fb->cursor->x = 0;
if (fb->cursor->y < 0)
@@ -172,14 +183,25 @@ fb_cursor_move(framebuffer_t *fb, int x, int y)
}
+void
+fb_cursor_move(framebuffer_t *fb, int x, int y)
+{
+ fb_cursor_move_abs(fb, fb->cursor->x + x, fb->cursor->y + y);
+}
+
void
fb_cursor_plot(framebuffer_t *fb)
{
bbox_t saved_plot_ctx;
+ bbox_t cursorbox;
+ /* if cursor is not currently plotted give up early */
if (fb->cursor->plotted)
return;
+ /* enlarge the clipping rectangle to the whole screen for plotting the
+ * cursor
+ */
saved_plot_ctx = fb_plot_ctx;
fb_plot_ctx.x0 = 0;
@@ -187,13 +209,26 @@ fb_cursor_plot(framebuffer_t *fb)
fb_plot_ctx.x1 = fb->width;
fb_plot_ctx.y1 = fb->height;
+ /* save under the cursor */
fb_cursor_save(fb);
+ /* plot the cursor image */
plot.bitmap(fb->cursor->x, fb->cursor->y,
fb->cursor->width, fb->cursor->height,
fb->cursor->bitmap, 0, NULL);
+ /* callback to the os specific routine in case it needs to do something
+ * explicit to redraw
+ */
+ cursorbox.x0 = fb->cursor->x;
+ cursorbox.y0 = fb->cursor->y;
+ cursorbox.x1 = fb->cursor->x + fb->cursor->width;
+ cursorbox.y1 = fb->cursor->y + fb->cursor->height;
+ fb_os_redraw(&cursorbox);
+
fb->cursor->plotted = true;
+
+ /* restore clipping rectangle */
fb_plot_ctx = saved_plot_ctx;
}
diff --git a/framebuffer/fb_cursor.h b/framebuffer/fb_cursor.h
index 30a474db6..85fdeb62d 100644
--- a/framebuffer/fb_cursor.h
+++ b/framebuffer/fb_cursor.h
@@ -21,6 +21,8 @@
void fb_cursor_move(struct framebuffer_s *fb, int x, int y);
+void fb_cursor_move_abs(struct framebuffer_s *fb, int x, int y);
+
void fb_cursor_plot(struct framebuffer_s *fb);
fb_cursor_t *fb_cursor_init(struct framebuffer_s *fb);
diff --git a/framebuffer/fb_frontend.h b/framebuffer/fb_frontend.h
index cbb53d061..624e3e016 100644
--- a/framebuffer/fb_frontend.h
+++ b/framebuffer/fb_frontend.h
@@ -23,6 +23,6 @@ extern framebuffer_t *fb_os_init(int argc, char** argv);
extern void fb_os_quit(framebuffer_t *fb);
extern void fb_os_input(struct gui_window *g);
extern void fb_os_option_override(void);
-extern void fb_os_redraw(struct gui_window *g, struct bbox_s *box);
+extern void fb_os_redraw(struct bbox_s *box);
#endif /* NETSURF_FB_FRONTEND_H */
diff --git a/framebuffer/fb_frontend_ablefb.c b/framebuffer/fb_frontend_ablefb.c
index 16fdf5aeb..865e02b19 100644
--- a/framebuffer/fb_frontend_ablefb.c
+++ b/framebuffer/fb_frontend_ablefb.c
@@ -134,6 +134,12 @@ fb_os_option_override(void)
option_max_fetchers = option_max_fetchers_per_host = 1;
}
+/* called by generic code to inform os code of screen update */
+void
+fb_os_redraw(struct bbox_s *box)
+{
+}
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/framebuffer/fb_frontend_dummy.c b/framebuffer/fb_frontend_dummy.c
index 4580513d7..5e9040779 100644
--- a/framebuffer/fb_frontend_dummy.c
+++ b/framebuffer/fb_frontend_dummy.c
@@ -64,13 +64,18 @@ framebuffer_t *fb_os_init(int argc, char** argv)
void fb_os_quit(framebuffer_t *fb)
{
- free(fb->ptr);
}
void fb_os_input(struct gui_window *g)
{
}
+/* called by generic code to inform os code of screen update */
+void
+fb_os_redraw(struct bbox_s *box)
+{
+}
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/framebuffer/fb_frontend_linuxfb.c b/framebuffer/fb_frontend_linuxfb.c
index d33eef7bb..9d43ce237 100644
--- a/framebuffer/fb_frontend_linuxfb.c
+++ b/framebuffer/fb_frontend_linuxfb.c
@@ -672,6 +672,11 @@ fb_os_option_override(void)
{
}
+/* called by generic code to inform os code of screen update */
+void
+fb_os_redraw(struct bbox_s *box)
+{
+}
/*
* Local Variables:
diff --git a/framebuffer/fb_frontend_sdl.c b/framebuffer/fb_frontend_sdl.c
index 6041abcae..a953912ad 100644
--- a/framebuffer/fb_frontend_sdl.c
+++ b/framebuffer/fb_frontend_sdl.c
@@ -34,6 +34,7 @@
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_frontend.h"
+#include "framebuffer/fb_cursor.h"
#include "utils/log.h"
@@ -74,6 +75,8 @@ framebuffer_t *fb_os_init(int argc, char** argv)
newfb->ptr = sdl_screen->pixels;
newfb->linelen = sdl_screen->pitch;
+ SDL_ShowCursor(SDL_DISABLE);
+
return newfb;
}
@@ -89,10 +92,40 @@ void fb_os_input(struct gui_window *g)
switch (event.type) {
case SDL_KEYDOWN:
- printf("The %s key was pressed!\n",
- SDL_GetKeyName(event.key.keysym.sym));
+
+ switch (event.key.keysym.sym) {
+
+ case SDLK_j:
+ fb_window_scroll(g, 0, 100);
+ break;
+
+ case SDLK_k:
+ fb_window_scroll(g, 0, -100);
+ break;
+
+ case SDLK_q:
+ browser_window_destroy(g->bw);
+ break;
+
+ default:
+ printf("The %s key was pressed!\n",
+ SDL_GetKeyName(event.key.keysym.sym));
+ break;
+ }
break;
+ case SDL_MOUSEMOTION:
+ fb_cursor_move_abs(framebuffer,
+ event.motion.x,
+ event.motion.y);
+ break;
+
+ case SDL_MOUSEBUTTONDOWN:
+ fb_cursor_click(framebuffer, g, BROWSER_MOUSE_CLICK_1);
+ /* printf("Mouse button %d pressed at (%d,%d)\n",
+ event.button.button, event.button.x, event.button.y);*/
+ break;
+
case SDL_QUIT:
browser_window_destroy(g->bw);
}
@@ -104,10 +137,13 @@ fb_os_option_override(void)
{
}
+/* called by generic code to inform os code of screen update */
void
-fb_os_redraw(struct gui_window *g, struct bbox_s *box)
+fb_os_redraw(struct bbox_s *box)
{
- SDL_UpdateRect(sdl_screen, box->x0, box->y0, box->x1, box->y1);
+ SDL_UpdateRect(sdl_screen,
+ box->x0, box->y0,
+ box->x1 - box->x0, box->y1 - box->y0);
}
/*
diff --git a/framebuffer/fb_gui.c b/framebuffer/fb_gui.c
index 6d5e6b9f4..b769ece06 100644
--- a/framebuffer/fb_gui.c
+++ b/framebuffer/fb_gui.c
@@ -126,7 +126,7 @@ static void fb_redraw(struct gui_window *g)
g->redraw_box.x0, g->redraw_box.y0, g->redraw_box.x1, g->redraw_box.y1,
g->bw->scale, 0xFFFFFF);
- fb_os_redraw(g, &g->redraw_box);
+ fb_os_redraw(&g->redraw_box);
g->redraw_required = false;
g->redraw_box.y0 = g->redraw_box.x0 = INT_MAX;
diff --git a/framebuffer/fb_plotters.c b/framebuffer/fb_plotters.c
index 28f64177f..a7bbfc28a 100644
--- a/framebuffer/fb_plotters.c
+++ b/framebuffer/fb_plotters.c
@@ -29,6 +29,7 @@
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_font.h"
+#include "framebuffer/fb_frontend.h"
/* Currently selected ploting routines. */
struct plotter_table plot;
@@ -277,7 +278,6 @@ bool fb_plotters_bitmap_tile(int x, int y,
bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int dsty)
{
- LOG(("from (%d,%d) w %d h %d to (%d,%d)",srcx,srcy,width,height,dstx,dsty));
uint8_t *srcptr = (framebuffer->ptr +
(srcy * framebuffer->linelen) +
(srcx));
@@ -286,7 +286,21 @@ bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx,
(dsty * framebuffer->linelen) +
(dstx));
+ bbox_t redrawbox;
+
+ 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);
+
+ /* callback to the os specific routine in case it needs to do something
+ * explicit to redraw
+ */
+ redrawbox.x0 = dstx;
+ redrawbox.y0 = dsty;
+ redrawbox.x1 = dstx + width;
+ redrawbox.y1 = dsty + height;
+ fb_os_redraw(&redrawbox);
+
return true;
}