Fix resource handling buy copying the GTK approach
Cleanup mouse movement handlig svn path=/trunk/netsurf/; revision=6486
This commit is contained in:
parent
f90e43e2b0
commit
d6cd92e0cc
1
Makefile
1
Makefile
|
@ -467,7 +467,6 @@ ifeq ($(TARGET),framebuffer)
|
|||
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
|
||||
|
||||
CFLAGS += '-DNETSURF_FB_RESPATH="$(NETSURF_FB_RESPATH_$(NETSURF_FB_FRONTEND))"'
|
||||
CFLAGS += '-DNETSURF_FB_HOMEPATH="$(NETSURF_FB_HOMEPATH_$(NETSURF_FB_FRONTEND))"'
|
||||
CFLAGS += -Dnsfb
|
||||
|
||||
ifeq ($(NETSURF_FB_FRONTEND),linux)
|
||||
|
|
|
@ -219,11 +219,6 @@ ifeq ($(TARGET),framebuffer)
|
|||
NETSURF_FB_RESPATH_dummy := ./
|
||||
NETSURF_FB_RESPATH_sdl := ./
|
||||
|
||||
NETSURF_FB_HOMEPATH_linux := ~/.netsurf/
|
||||
NETSURF_FB_HOMEPATH_able := (tftpboot)/
|
||||
NETSURF_FB_HOMEPATH_dummy := ./
|
||||
NETSURF_FB_HOMEPATH_sdl := ~/.netsurf/
|
||||
|
||||
endif
|
||||
|
||||
# Include any local overrides
|
||||
|
|
|
@ -137,8 +137,9 @@ static void fb_cursor_clear(framebuffer_t *fb)
|
|||
|
||||
}
|
||||
|
||||
/* move cursor to absolute position */
|
||||
void
|
||||
fb_cursor_move_abs(framebuffer_t *fb, int x, int y)
|
||||
fb_cursor_move(framebuffer_t *fb, int x, int y)
|
||||
{
|
||||
fb_cursor_clear(fb);
|
||||
|
||||
|
@ -152,13 +153,6 @@ fb_cursor_move_abs(framebuffer_t *fb, int x, int y)
|
|||
fb->cursor->x = fb->width;
|
||||
if (fb->cursor->y > fb->height)
|
||||
fb->cursor->y = fb->height;
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -25,8 +25,6 @@ int fb_cursor_y(framebuffer_t *fb);
|
|||
|
||||
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);
|
||||
|
|
|
@ -23,64 +23,80 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
#include "fb_findfile.h"
|
||||
|
||||
static bool
|
||||
fb_findfile_exists(char *buffer, const char *base, const char *filename)
|
||||
char *path_to_url(const char *path)
|
||||
{
|
||||
if (base == NULL)
|
||||
return false;
|
||||
|
||||
if (*base == '~') {
|
||||
snprintf(buffer, PATH_MAX, "%s/%s/%s",
|
||||
getenv("HOME") ? getenv("HOME") : "",
|
||||
base + 1, filename);
|
||||
} else {
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", base, filename);
|
||||
char *r = malloc(strlen(path) + 7 + 1);
|
||||
|
||||
strcpy(r, "file://");
|
||||
strcat(r, path);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a shared resource file by searching known places in order.
|
||||
*
|
||||
* \param buf buffer to write to. must be at least PATH_MAX chars
|
||||
* \param filename file to look for
|
||||
* \param def default to return if file not found
|
||||
* \return buf
|
||||
*
|
||||
* Search order is: ~/.netsurf/, $NETSURFRES/ (where NETSURFRES is an
|
||||
* environment variable), and finally the path specified by NETSURF_FB_RESPATH
|
||||
* from the Makefile
|
||||
*/
|
||||
|
||||
char *fb_find_resource(char *buf, const char *filename, const char *def)
|
||||
{
|
||||
char *cdir = getenv("HOME");
|
||||
char t[PATH_MAX];
|
||||
|
||||
if (cdir != NULL) {
|
||||
strcpy(t, cdir);
|
||||
strcat(t, "/.netsurf/");
|
||||
strcat(t, filename);
|
||||
if (realpath(t, buf) != NULL) {
|
||||
if (access(buf, R_OK) == 0)
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
cdir = getenv("NETSURFRES");
|
||||
|
||||
if (cdir != NULL) {
|
||||
if (realpath(cdir, buf) != NULL) {
|
||||
strcat(buf, "/");
|
||||
strcat(buf, filename);
|
||||
if (access(buf, R_OK) == 0)
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(t, NETSURF_FB_RESPATH);
|
||||
strcat(t, filename);
|
||||
if (realpath(t, buf) != NULL) {
|
||||
if (access(buf, R_OK) == 0)
|
||||
return buf;
|
||||
}
|
||||
|
||||
return (access(buffer, R_OK) == 0);
|
||||
|
||||
if (def[0] == '~') {
|
||||
snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1);
|
||||
if (realpath(t, buf) == NULL) {
|
||||
strcpy(buf, t);
|
||||
}
|
||||
} else {
|
||||
if (realpath(def, buf) == NULL) {
|
||||
strcpy(buf, def);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *
|
||||
fb_findfile(const char *filename)
|
||||
{
|
||||
static char buffer[PATH_MAX];
|
||||
|
||||
/* Search sequence is:
|
||||
* home/filename
|
||||
* res-env/filename
|
||||
* resources/filename
|
||||
*/
|
||||
|
||||
if (fb_findfile_exists(buffer, NETSURF_FB_HOMEPATH, filename))
|
||||
return buffer;
|
||||
if (fb_findfile_exists(buffer, getenv("NETSURF_RES"), filename))
|
||||
return buffer;
|
||||
if (fb_findfile_exists(buffer, NETSURF_FB_RESPATH, filename))
|
||||
return buffer;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
fb_findfile_asurl(const char *filename)
|
||||
{
|
||||
static char buffer[PATH_MAX];
|
||||
char *f;
|
||||
|
||||
if (strncmp(filename, "http://", 5) == 0)
|
||||
return strdup(filename);
|
||||
|
||||
f = fb_findfile(filename);
|
||||
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "file://%s", f);
|
||||
|
||||
return strdup(buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#ifndef NETSURF_FB_FINDFILE_H
|
||||
#define NETSURF_FB_FINDFILE_H
|
||||
|
||||
extern char *fb_findfile(const char *filename);
|
||||
extern char *fb_findfile_asurl(const char *filename);
|
||||
char *path_to_url(const char *path);
|
||||
|
||||
extern char *fb_find_resource(char *buf, const char *filename, const char *def);
|
||||
|
||||
#endif /* NETSURF_FB_FINDFILE_H */
|
||||
|
|
|
@ -139,7 +139,7 @@ void fb_os_input(struct gui_window *g, bool active)
|
|||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
fb_rootwindow_move_abs(framebuffer, g, event.motion.x, event.motion.y);
|
||||
fb_rootwindow_move(framebuffer, g, event.motion.x, event.motion.y, false);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
char *default_stylesheet_url;
|
||||
char *adblock_stylesheet_url;
|
||||
char *options_file_location;
|
||||
struct gui_window *input_window = NULL;
|
||||
struct gui_window *search_current_window;
|
||||
struct gui_window *window_list = NULL;
|
||||
|
@ -166,21 +167,33 @@ static void *myrealloc(void *ptr, size_t len, void *pw)
|
|||
|
||||
void gui_init(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
LOG(("argc %d, argv %p", argc, argv));
|
||||
|
||||
#ifdef WITH_HUBBUB
|
||||
if (hubbub_initialise(fb_findfile("Aliases"), myrealloc, NULL) !=
|
||||
fb_find_resource(buf, "Aliases", "./framebuffer/res/Aliases");
|
||||
LOG(("Using '%s' as Aliases file", buf));
|
||||
if (hubbub_initialise(buf, myrealloc, NULL) !=
|
||||
HUBBUB_OK)
|
||||
die("Unable to initialise HTML parsing library.\n");
|
||||
#endif
|
||||
|
||||
/* load browser messages */
|
||||
messages_load(fb_findfile("messages"));
|
||||
|
||||
fb_find_resource(buf, "messages", "./framebuffer/res/messages");
|
||||
LOG(("Using '%s' as Messages file", buf));
|
||||
messages_load(buf);
|
||||
|
||||
/* load browser options */
|
||||
options_read(fb_findfile("Options"));
|
||||
fb_find_resource(buf, "Options", "~/.netsurf/Options");
|
||||
LOG(("Using '%s' as Preferences file", buf));
|
||||
options_file_location = strdup(buf);
|
||||
options_read(buf);
|
||||
|
||||
default_stylesheet_url = fb_findfile_asurl("default.css");
|
||||
/* set up stylesheet urls */
|
||||
fb_find_resource(buf, "default.css", "./framebuffer/res/default.css");
|
||||
default_stylesheet_url = path_to_url(buf);
|
||||
LOG(("Using '%s' as Default CSS URL", default_stylesheet_url));
|
||||
|
||||
framebuffer = fb_os_init(argc, argv);
|
||||
|
||||
|
|
|
@ -426,11 +426,20 @@ fb_rootwindow_click(struct gui_window *g, browser_mouse_state st, int x, int y)
|
|||
|
||||
|
||||
void
|
||||
fb_rootwindow_move_abs(framebuffer_t *fb, struct gui_window *g, int x, int y)
|
||||
fb_rootwindow_move(framebuffer_t *fb,
|
||||
struct gui_window *g,
|
||||
int x,
|
||||
int y,
|
||||
bool relative)
|
||||
{
|
||||
struct fb_widget *widget;
|
||||
|
||||
fb_cursor_move_abs(fb, x, y);
|
||||
if (relative) {
|
||||
x += fb_cursor_x(fb);
|
||||
y += fb_cursor_y(fb);
|
||||
}
|
||||
|
||||
fb_cursor_move(fb, x, y);
|
||||
|
||||
widget = widget_list;
|
||||
while (widget != NULL) {
|
||||
|
|
|
@ -24,6 +24,8 @@ typedef int (*fb_widget_mouseclick_t)(struct gui_window *g, browser_mouse_state
|
|||
void fb_rootwindow_click(struct gui_window *g,
|
||||
browser_mouse_state st , int x, int y);
|
||||
void fb_rootwindow_input(struct gui_window *g, int value);
|
||||
void fb_rootwindow_move(framebuffer_t *fb, struct gui_window *g, int x, int y, bool relative);
|
||||
|
||||
void fb_rootwindow_status(const char* text);
|
||||
void fb_rootwindow_url(const char* text);
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
# This file is part of NetSurf, http://netsurf-browser.org/
|
||||
# Licensed under the GNU General Public License,
|
||||
# http://www.opensource.org/licenses/gpl-license
|
||||
# Copyright 2007 Rob Kendrick <rjek@netsurf-browser.org>
|
||||
|
||||
if [ -d ~/.netsurf ]; then
|
||||
LOG=~/.netsurf/log.txt
|
||||
elif [ -d /tmp ]; then
|
||||
LOG=/tmp/netsurf-log.txt
|
||||
else
|
||||
LOG=netsurf-log.txt
|
||||
fi
|
||||
|
||||
if [ -x nsfb-sdl ]; then
|
||||
TYPE=-sdl
|
||||
elif [ -x nsfb-linux ]; then
|
||||
TYPE=-linux
|
||||
elif [ -x nsfb-dummy ]; then
|
||||
TYPE=-dummy
|
||||
fi
|
||||
|
||||
NETSURFRES=$(dirname $0)/framebuffer/res/
|
||||
export NETSURFRES
|
||||
exec $(dirname $0)/nsfb${TYPE} "$@" 2>$LOG
|
Loading…
Reference in New Issue