Fix window clipping and introduce concept of "root" framebuffer window to allow for navigation and status bars

svn path=/trunk/netsurf/; revision=6456
This commit is contained in:
Vincent Sanders 2009-02-12 14:16:40 +00:00
parent 06ec51993d
commit 614de7d473
9 changed files with 160 additions and 24 deletions

View File

@ -99,7 +99,7 @@ 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_findfile.c
fb_findfile.c fb_rootwindow.c
# fb_1bpp_plotters.c
ifeq ($(NETSURF_FB_FRONTEND),linux)

View File

@ -35,6 +35,7 @@
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_cursor.h"
#include "framebuffer/fb_frontend.h"
#include "framebuffer/fb_rootwindow.h"
struct fb_cursor_s {
int x;
@ -262,11 +263,18 @@ fb_cursor_click(framebuffer_t *fb,
struct gui_window *g,
browser_mouse_state st)
{
/* check click lies within window */
if ((fb->cursor->x > g->x) &&
(fb->cursor->y > g->y) &&
(fb->cursor->x < g->x + g->width) &&
(fb->cursor->y < g->y + g->height)) {
browser_window_mouse_click(g->bw,
st,
fb->cursor->x,
fb->cursor->y + g->scrolly);
fb->cursor->x - g->x + g->scrollx,
fb->cursor->y - g->y + g->scrolly);
} else {
fb_rootwindow_click(st, fb->cursor->x, fb->cursor->y);
}
}
/*

View File

@ -67,7 +67,12 @@ char *
fb_findfile_asurl(const char *filename)
{
static char buffer[PATH_MAX];
char *f = fb_findfile(filename);
char *f;
if (strncmp(filename, "http://", 5) == 0)
return strdup(filename);
f = fb_findfile(filename);
if (f == NULL)
return NULL;

View File

@ -33,6 +33,7 @@
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_frontend.h"
#include "framebuffer/fb_options.h"
#include "utils/log.h"

View File

@ -99,6 +99,14 @@ void fb_os_input(struct gui_window *g, bool active)
switch (event.key.keysym.sym) {
case SDLK_PAGEDOWN:
fb_window_scroll(g, 0, g->height);
break;
case SDLK_PAGEUP:
fb_window_scroll(g, 0, -g->height);
break;
case SDLK_j:
fb_window_scroll(g, 0, 100);
break;
@ -135,9 +143,30 @@ void fb_os_input(struct gui_window *g, bool active)
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);*/
switch (event.button.button) {
case SDL_BUTTON_LEFT:
fb_cursor_click(framebuffer, g, BROWSER_MOUSE_CLICK_1);
break;
case SDL_BUTTON_RIGHT:
fb_cursor_click(framebuffer, g, BROWSER_MOUSE_CLICK_2);
break;
case SDL_BUTTON_WHEELUP:
fb_window_scroll(g, 0, -100);
break;
case SDL_BUTTON_WHEELDOWN:
fb_window_scroll(g, 0, 100);
break;
case SDL_BUTTON_MIDDLE:
default:
printf("Mouse button %d pressed at (%d,%d)\n",
event.button.button, event.button.x, event.button.y);
}
break;
case SDL_QUIT:

View File

@ -71,10 +71,11 @@ static void fb_pan(struct gui_window *g)
if (!c) return;
if (c->locked) return;
LOG(("panning %d, %d from %d, %d in content %d,%d",g->panx, g->pany,g->scrollx,g->scrolly,c->width, c->height));
LOG(("panning %d, %d from %d, %d in content %d,%d",
g->panx, g->pany,g->scrollx,g->scrolly,c->width, c->height));
/* dont pan off the top */
if ((g->scrolly + g->pany) < 0)
g->pany = -g->scrolly;
g->pany = - g->scrolly;
/* do not pan off the bottom of the content */
if ((g->scrolly + g->pany) > (c->height - g->height))
@ -94,8 +95,8 @@ static void fb_pan(struct gui_window *g)
g->width, g->height + g->pany,
g->x, g->y - g->pany);
g->scrolly += g->pany;
fb_queue_redraw(g, g->x, g->y,
g->x + g->width, g->y - g->pany);
fb_queue_redraw(g, 0, 0,
g->width, - g->pany);
}
if (g->pany > 0) {
/* we cannot pan more than a window height at a time */
@ -104,10 +105,12 @@ static void fb_pan(struct gui_window *g)
LOG(("panning down %d", g->pany));
fb_plotters_move_block(g->x, g->y + g->pany, g->width, g->height - g->pany, g->x, g->y);
fb_plotters_move_block(g->x, g->y + g->pany,
g->width, g->height - g->pany,
g->x, g->y);
g->scrolly += g->pany;
fb_queue_redraw(g, g->x, g->y + g->height - g->pany,
g->x + g->width, g->y + g->height);
fb_queue_redraw(g, 0, g->height - g->pany,
g->width, g->height);
}
g->pan_required = false;
@ -127,7 +130,18 @@ static void fb_redraw(struct gui_window *g)
if (!c) return;
if (c->locked) return;
content_redraw(c, 0, -g->scrolly, g->width, g->height,
/* adjust clipping co-ordinates according to window location */
g->redraw_box.y0 += g->y;
g->redraw_box.y1 += g->y;
g->redraw_box.x0 += g->x;
g->redraw_box.x1 += g->x;
/* redraw bounding box is relative to window */
content_redraw(c,
g->x - g->scrollx,
g->y - g->scrolly ,
g->width,
g->height,
g->redraw_box.x0, g->redraw_box.y0,
g->redraw_box.x1, g->redraw_box.y1,
g->bw->scale, 0xFFFFFF);
@ -165,7 +179,7 @@ void gui_init(int argc, char** argv)
/* load browser options */
options_read(fb_findfile("Options"));
default_stylesheet_url = fb_findfile_asurl("default.css");
default_stylesheet_url = fb_findfile_asurl("http://jennifer.kyllikki.org/~vince/res/default.css");
framebuffer = fb_os_init(argc, argv);
@ -228,7 +242,7 @@ void gui_poll(bool active)
fetch_poll();
//LOG(("enter schedule run"));
active = schedule_run() | active;
active = schedule_run() | active | redraws_pending;
fb_os_input(input_window, active);
@ -275,9 +289,9 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
return NULL;
g->x = 0;
g->y = 0;
g->y = 30;
g->width = framebuffer->width;
g->height = framebuffer->height;
g->height = framebuffer->height - 60;
g->bw = bw;
if (window_list == NULL) {
@ -323,7 +337,9 @@ void gui_window_set_title(struct gui_window *g, const char *title)
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
static void fb_queue_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
/* queue a redraw operation, co-ordinates are relative to the window */
static void
fb_queue_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
{
if (!g) return;

View File

@ -184,15 +184,13 @@ bool fb_clip(int x0, int y0, int x1, int y1)
g = window_list;
/* LOG(("x0 %d, y0 %d, x1 %d, y1 %d", x0, y0, x1, y1)); */
if (x1 < x0) SWAP(x0, x1);
if (y1 < y0) SWAP(y0, y1);
clip.x0 = g->x;
clip.y0 = g->y;
clip.x1 = g->x + g->width;
clip.y1 = g->x + g->height;
clip.y1 = g->y + g->height;
if (fb_plotters_clip_rect(&clip, &x0, &y0, &x1, &y1)) {
/* new clipping region is inside the root window */
@ -201,6 +199,11 @@ bool fb_clip(int x0, int y0, int x1, int y1)
fb_plot_ctx.x1 = x1;
fb_plot_ctx.y1 = y1;
}
LOG(("%d, %d - %d, %d clipped to %d, %d - %d, %d",
x0,y0,x1,y1,
fb_plot_ctx.x0, fb_plot_ctx.y0, fb_plot_ctx.x1, fb_plot_ctx.y1));
return true;
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.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/>.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <limits.h>
#include <unistd.h>
#ifdef WITH_HUBBUB
#include <hubbub/hubbub.h>
#endif
#include "desktop/gui.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
#include "desktop/options.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_frontend.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_schedule.h"
#include "framebuffer/fb_cursor.h"
#include "framebuffer/fb_rootwindow.h"
void fb_rootwindow_click(browser_mouse_state st , int x, int y)
{
LOG(("Click in root window"));
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,19 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.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/>.
*/
void fb_rootwindow_click(browser_mouse_state st , int x, int y);