r5361 vince - in /branches/vince/netsurf-fb: Makefile.sources framebuffer/fb_cursor.c framebuffer/fb_cursor.h framebuffer/fb_gui.c framebuffer/fb_gui.h framebuffer/fb_init_linux.c framebuffer/fb_plotters.c

netsurf at semichrome.net netsurf at semichrome.net
Wed Sep 17 11:48:45 BST 2008


Author: vince
Date: Wed Sep 17 05:48:44 2008
New Revision: 5361

URL: http://source.netsurf-browser.org?rev=5361&view=rev
Log:
initial cursor support

Added:
    branches/vince/netsurf-fb/framebuffer/fb_cursor.c
    branches/vince/netsurf-fb/framebuffer/fb_cursor.h
Modified:
    branches/vince/netsurf-fb/Makefile.sources
    branches/vince/netsurf-fb/framebuffer/fb_gui.c
    branches/vince/netsurf-fb/framebuffer/fb_gui.h
    branches/vince/netsurf-fb/framebuffer/fb_init_linux.c
    branches/vince/netsurf-fb/framebuffer/fb_plotters.c

Modified: branches/vince/netsurf-fb/Makefile.sources
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/Makefile.sources?rev=5361&r1=5360&r2=5361&view=diff
==============================================================================
--- branches/vince/netsurf-fb/Makefile.sources (original)
+++ branches/vince/netsurf-fb/Makefile.sources Wed Sep 17 05:48:44 2008
@@ -89,10 +89,10 @@
 S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
 
 # S_FRAMEBUFFER are sources purely for the framebuffer build
-S_FRAMEBUFFER := fb_gui.c tree.c history.c hotlist.c fb_schedule.c thumbnail.c \
-	misc.c fb_bitmap.c fb_font.c font_8x16.c fb_filetype.c login.c \
-	fb_plotters.c fb_8bpp_plotters.c \
-	fb_16bpp_plotters.c fb_32bpp_plotters.c
+S_FRAMEBUFFER := fb_gui.c tree.c history.c hotlist.c fb_schedule.c	\
+	thumbnail.c misc.c fb_bitmap.c fb_font.c font_8x16.c		\
+	fb_filetype.c login.c fb_cursor.c fb_plotters.c			\
+	fb_8bpp_plotters.c fb_16bpp_plotters.c fb_32bpp_plotters.c
 #	fb_1bpp_plotters.c
 
 ifeq ($(NETSURF_FB_FRONTEND),linux)

Added: branches/vince/netsurf-fb/framebuffer/fb_cursor.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_cursor.c?rev=5361&view=auto
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_cursor.c (added)
+++ branches/vince/netsurf-fb/framebuffer/fb_cursor.c Wed Sep 17 05:48:44 2008
@@ -1,0 +1,75 @@
+#include <sys/types.h>
+#include <stdint.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <string.h>
+#include <limits.h>
+
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "desktop/plotters.h"
+
+#include "framebuffer/fb_gui.h"
+#include "framebuffer/fb_plotters.h"
+#include "framebuffer/fb_bitmap.h"
+#include "framebuffer/fb_cursor.h"
+
+struct fb_cursor_s {
+        int x;
+        int y;
+        int width; /**< width */
+        int height; /**< height */
+    
+        struct bitmap *bitmap; /* pointer bitmap */
+
+        uint8_t *savedata; /* save under area */
+};
+
+void
+fb_cursor_move(framebuffer_t *fb, int x, int y)
+{
+        fb->cursor->x += x;
+        fb->cursor->y += y;
+}
+
+void 
+fb_cursor_plot(framebuffer_t *fb)
+{
+        bbox_t saved_plot_ctx;
+        saved_plot_ctx = fb_plot_ctx;
+
+        fb_plot_ctx.x0 = 0;
+        fb_plot_ctx.y0 = 0;
+        fb_plot_ctx.x1 = fb->width;
+        fb_plot_ctx.y1 = fb->height;
+
+        plot.bitmap(fb->cursor->x, fb->cursor->y, 
+                    fb->cursor->width, fb->cursor->height,
+                    fb->cursor->bitmap, 0, NULL);
+
+        fb_plot_ctx = saved_plot_ctx;
+}
+
+fb_cursor_t *
+fb_cursor_init(framebuffer_t *fb)
+{
+        fb_cursor_t *cursor;
+        cursor = calloc(1, sizeof(fb_cursor_t));
+
+        cursor->x = fb->width / 2;
+        cursor->y = fb->height / 2;
+
+        cursor->width = 16;
+        cursor->height = 16;
+        cursor->bitmap = bitmap_create(cursor->width, cursor->height, 0);
+        memset(cursor->bitmap->pixdata, 0xff, cursor->width * 4);
+
+        return cursor;
+}
+
+/*
+ * Local Variables:
+ * c-basic-offset:8
+ * End:
+ */

Added: branches/vince/netsurf-fb/framebuffer/fb_cursor.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_cursor.h?rev=5361&view=auto
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_cursor.h (added)
+++ branches/vince/netsurf-fb/framebuffer/fb_cursor.h Wed Sep 17 05:48:44 2008
@@ -1,0 +1,28 @@
+/*
+ * Copyright 2008 Chris Young <chris at unsatisfactorysoftware.co.uk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf 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; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FRAMEBUFFER_FB_CURSOR
+#define FRAMEBUFFER_FB_CURSOR
+
+void fb_cursor_move(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);
+
+#endif

Modified: branches/vince/netsurf-fb/framebuffer/fb_gui.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_gui.c?rev=5361&r1=5360&r2=5361&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_gui.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_gui.c Wed Sep 17 05:48:44 2008
@@ -28,9 +28,11 @@
 #include "desktop/options.h"
 #include "utils/messages.h"
 #include "utils/log.h"
+#include "framebuffer/fb_bitmap.h"
 #include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
 #include "framebuffer/fb_schedule.h"
+#include "framebuffer/fb_cursor.h"
 #include "content/urldb.h"
 #include "desktop/history_core.h"
 #include "content/fetch.h"
@@ -110,7 +112,7 @@
                 exit(1);
         }
 
-
+        framebuffer->cursor = fb_cursor_init(framebuffer);
 }
 
 void gui_init2(int argc, char** argv)
@@ -134,6 +136,7 @@
 {
     //    LOG(("gui_multitask"));
 }
+
 
 void gui_poll(bool active)
 {
@@ -143,10 +146,13 @@
     //LOG(("enter schedule run"));
     schedule_run();
 
+
     fb_os_input(input_window);
 
     if (redraws_pending == true) {
             struct gui_window *g;
+
+            fb_cursor_move(framebuffer, 0,0);
             
             redraws_pending = false;
 
@@ -157,6 +163,7 @@
             }
     }
 
+    fb_cursor_plot(framebuffer);
 }
 
 void gui_quit(void)

Modified: branches/vince/netsurf-fb/framebuffer/fb_gui.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_gui.h?rev=5361&r1=5360&r2=5361&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_gui.h (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_gui.h Wed Sep 17 05:48:44 2008
@@ -16,6 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+typedef struct fb_cursor_s fb_cursor_t;
+
 /* bounding box */
 typedef struct bbox_s {
         int x0;
@@ -24,13 +26,14 @@
         int y1;
 } bbox_t;
 
-typedef struct {
+typedef struct framebuffer_s {
     int width;
     int height;
     uint8_t *ptr; /**< Base of video memory. */
     int linelen; /**< length of a video line. */
     int bpp;
     colour palette[256]; /* palette for index modes */
+    fb_cursor_t *cursor;
 } framebuffer_t;
 
 struct gui_window {
@@ -51,3 +54,4 @@
 extern void fb_os_quit(framebuffer_t *fb);
 extern void fb_os_input(struct gui_window *g);
 
+extern framebuffer_t *framebuffer;

Modified: branches/vince/netsurf-fb/framebuffer/fb_init_linux.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_init_linux.c?rev=5361&r1=5360&r2=5361&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_init_linux.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_init_linux.c Wed Sep 17 05:48:44 2008
@@ -576,6 +576,22 @@
                 case KEY_D:
                         list_schedule();
                         break;
+
+                case KEY_UP:
+                        fb_cursor_move(0, -1);
+                        break;
+
+                case KEY_DOWN:
+                        fb_cursor_move(0, 1);
+                        break;
+
+                case KEY_LEFT:
+                        fb_cursor_move(-1, 0);
+                        break;
+
+                case KEY_RIGHT:
+                        fb_cursor_move(1, 0);
+                        break;
                 }
         }
 

Modified: branches/vince/netsurf-fb/framebuffer/fb_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_plotters.c?rev=5361&r1=5360&r2=5361&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_plotters.c Wed Sep 17 05:48:44 2008
@@ -35,6 +35,8 @@
 
 /* Current plotting context */
 bbox_t fb_plot_ctx;
+
+extern framebuffer_t *framebuffer;
 
 #define REGION(x,y,cx1,cx2,cy1,cy2) ( ( (y) > (cy2) ? 8 : 0) |  \
                                       ( (y) < (cy1) ? 4 : 0) |  \
@@ -171,6 +173,10 @@
 	return true;
 }
 
+void fb_plotters_clear_cursor(void)
+{
+}
+
 
 colour fb_plotters_ablend(colour pixel, colour scrpixel)
 {




More information about the netsurf-commits mailing list