Fix focus element

svn path=/trunk/netsurf/; revision=13251
This commit is contained in:
Ole Loots 2011-12-06 21:06:41 +00:00
parent 3ba6a15fa7
commit e7e8024be8
16 changed files with 289 additions and 117 deletions

View File

@ -41,7 +41,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
ctxmenu.c
ctxmenu.c save.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list

View File

@ -239,6 +239,8 @@ void window_open( struct gui_window * gw, GRECT pos )
}
tb_adjust_size( gw );
/*TBD: get already present content and set size? */
input_window = gw;
window_set_focus( gw, BROWSER, gw->browser );
}
@ -485,7 +487,10 @@ static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data )
{
printf("oldtop: iw: %p\n", input_window);
input_window = (struct gui_window *) data;
printf("newtop: iw: %p, win: %p", input_window, win );
window_set_focus( input_window, BROWSER, &input_window->browser )
LOG(("newtop: iw: %p, win: %p", input_window, win ));
assert( input_window != NULL );
}

View File

@ -0,0 +1,10 @@
- Fixed redraw of rectangle outlines.
- Fixed redraw of Hotlist, looks better now.
- Use netsurfs textarea implementation for URL, to reduce code size.
- Fixed several redraw glitches.
- Added a context menu, offering some handy functions.
- NetSurf core now supports frames & iframes.
- Debug rendering works now ( fixed redraw of rectangle outlines )
- process commandline parameter w (width) / h (height) for default window size
- improved mouse drag within treeview, browser win, toolbar.
- Fixed file drop in frames

View File

@ -6,26 +6,22 @@ TODO's (no priority order)
-> only needed for <= 256 colors
- Make drawing of tiled bitmaps optional ( they are slooow )
-> already optimized, still needed?
- Implement PopUp Context Menu ( + "Open link in new Window" )
- only copy visible rects when copying screen rects ( during scroll ).
- Make context menu more stable, Bug lurking within core?
- Implement TreeView History
- Implement TreeView SSL Dialog
- Implement Native Select Menu
- Implement offscreen plotter
- Implement Options Dialog
- Implement Favicon Display
- Implement SystemColors
- Replace RSC strings with string from messages file.
- Implement Selection within URL Widget by depressing SHIFT + Mouse Click
- Implement Home / End Cursors within the URL Widget
- Implement Offscreen plotter.
- Test more pages that use a refferer.
- Optimize Offscreen Plotter: Save inactive framebuffers to disk?
- Ensure that a font-face is set to the default font when it couldn't be loaded.
- Loose focus for browser / url widget etc. when changing focus
( at best, implement callback for this...)
- Have browser_window specific cursor, window specifc cursor
- When minimized (not iconyfied) NetSurf doesn't recognize that.
- complete Iconify (webpage favicon )
- Tabs? ( several tab-favicons when iconyfied?)
- improve mouse tracking
- fix this:
path2url in: ./res/icons/dir.png

View File

@ -39,24 +39,52 @@ const char *fetch_filetype(const char *unix_path)
LOG(("unix path: %s", unix_path));
/* This line is added for devlopment versions running from the root dir: */
if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
res = (char*)"text/css";
else if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
res = (char*)"text/css";
else if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
res = (char*)"image/jpeg";
else if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
res = (char*)"image/jpeg";
else if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
res = (char*)"image/gif";
else if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
res = (char*)"image/png";
else if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
res = (char*)"image/jng";
else if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
res = (char*)"image/svg";
else if (2 < l && strcasecmp(unix_path + l - 3, "txt") == 0)
res = (char*)"text/plain";
if( strchr( unix_path, (int)'.' ) ){
if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
res = (char*)"text/css";
else if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
res = (char*)"text/css";
else if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
res = (char*)"image/jpeg";
else if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
res = (char*)"image/jpeg";
else if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
res = (char*)"image/gif";
else if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
res = (char*)"image/png";
else if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
res = (char*)"image/jng";
else if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
res = (char*)"image/svg";
else if (2 < l && strcasecmp(unix_path + l - 3, "txt") == 0)
res = (char*)"text/plain";
} else {
int n=0;
int c;
FILE * fp;
char buffer[16];
fp = fopen( unix_path, "r" );
if( fp ){
do {
c = fgetc (fp);
if( c != EOF )
buffer[n] = (char)c;
else
buffer[n] = 0;
n++;
} while (c != EOF && n<15);
fclose( fp );
if( n > 0 ){
if( n > 5 && strncasecmp("GIF89", buffer, 5) == 0 )
res = "image/gif";
else if( n > 4 && strncasecmp("PNG", &buffer[1], 3) ==0 )
res = "image/png";
else if( n > 10 && strncasecmp("JFIF", &buffer[5], 4) == 0 )
res = "image/jpeg";
}
}
}
error:
LOG(("mime type: %s", res ));
return( res );

View File

@ -33,8 +33,53 @@
#include "atari/misc.h"
#include "atari/osspec.h"
char * local_file_to_url( const char * filename )
{
#define BACKSLASH 0x5C
char * url;
if( strlen(filename) <= 2){
return( NULL );
}
char * fname_local = alloca( strlen(filename)+1 );
char * start = (char*)fname_local;
strcpy( start, filename );
/* if path points to unified filesystem, skip that info: */
if( fname_local[1] == ':' && fname_local[0] == 'U' ){
start = &fname_local[2];
}
/* if we got something like "C:\folder\file.txt", handle that: */
if( start[1] == ':' ){
start[1] = (char)tolower(start[0]);
start++;
}
/* skip leading slash, already included in file scheme: */
if( start[0] == (char)BACKSLASH || start[0] == '/' ){
start++;
}
/* convert backslashes: */
for( int i=0; i<strlen(start); i++ ){
if( start[i] == BACKSLASH ){
start[i] = '/';
}
}
// TODO: make file path absolute if it isn't yet.
url = malloc( strlen(start) + FILE_SCHEME_PREFIX_LEN + 1);
strcpy( url, FILE_SCHEME_PREFIX );
strcat( url, start );
return( url );
#undef BACKSLASH
}
/* convert an local path to an URL, memory for URL is allocated. */
char *path_to_url(const char *path_in)
{
#define BACKSLASH 0x5C
char * path_ptr=NULL;
char * path;
LOG(("path2url in: %s\n", path_in));
@ -45,7 +90,8 @@ char *path_to_url(const char *path_in)
} else {
path = path_ptr = (char*)malloc(PATH_MAX+1);
gemdos_realpath(path_in, path);
if( *path == '/' || *path == 0x5C ) {
if( *path == '/' || *path == BACKSLASH ) {
path++;
}
if( sys_type() != SYS_MINT ){
@ -63,7 +109,7 @@ char *path_to_url(const char *path_in)
int i=0;
while( url[i] != 0 ){
if( url[i] == 0x5C ){
if( url[i] == BACKSLASH ){
url[i] = '/';
}
i++;
@ -72,6 +118,7 @@ char *path_to_url(const char *path_in)
free( path_ptr );
LOG(("path2url out: %s\n", url));
return url;
#undef BACKSLASH
}

View File

@ -21,5 +21,6 @@
#define NS_ATARI_FINDFILE_H
extern char *atari_find_resource(char *buf, const char *filename, const char *def);
char * local_file_to_url( const char * filename );
#endif /* NETSURF_ATARI_FINDFILE_H */

View File

@ -31,8 +31,10 @@
#include "desktop/mouse.h"
#include "desktop/textinput.h"
#include "desktop/hotlist.h"
#include "desktop/save_complete.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
@ -45,6 +47,7 @@
#include "atari/res/netsurf.rsh"
#include "atari/search.h"
#include "atari/options.h"
#include "atari/findfile.h"
#include "cflib.h"
extern const char * cfg_homepage_url;
@ -100,19 +103,39 @@ static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
LOG(("%s", __FUNCTION__));
gw = input_window;
if( gw == NULL ) {
bw = browser_window_create("", 0, 0, true, false);
gw = bw->window;
}
/* TODO: reset url? */
LOG(("%s", __FUNCTION__));
/* Loose focus: */
window_set_focus( gw, WIDGET_NONE, NULL );
/* trigger on-focus event (select all text): */
window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
/* delete selection: */
tb_url_input( gw, NK_DEL );
}
static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
{
struct gui_window * gw;
struct browser_window * bw ;
LOG(("%s", __FUNCTION__));
const char * filename = file_select( messages_get("OpenFile"), "" );
if( filename != NULL ){
char * url = local_file_to_url( filename );
if( url ){
bw = browser_window_create(url, NULL, NULL, true, false);
free( url );
}
}
}
static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
@ -126,6 +149,41 @@ static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
{
LOG(("%s", __FUNCTION__));
static bool init = true;
bool is_folder=false;
const char * path;
if( !input_window )
return;
if( init ){
init = false;
save_complete_init();
}
do {
// TODO: localize string
path = file_select( "Select folder", "" );
if( path ) {
printf("testing: %s\n", path );
// dumb check if the selection is an folder:
/*FILE * fp;
fp = fopen( path, "r" );
if( !fp ){
is_folder = true;
} else {
fclose( fp );
form_alert(1, "[1][Please select an folder or abort!][OK]");
}
*/
is_folder = true;
}
} while( !is_folder && path != NULL );
if( path != NULL ){
save_complete( input_window->browser->bw->current_content, path );
}
}
static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
@ -516,9 +574,11 @@ static void set_menu_title(int rid, const char * nsid)
{
static int count=0;
char * msgstr;
msgstr = (char*)messages_get(nsid);
msgstr = (char*)messages_get(nsid);
if(msgstr != NULL) {
if(msgstr[0] != 0) {
// TODO: modify resource tree, adjust width of menu to chars
// actually used.
assert(count < NUM_MENU_TITLES);
menu_titles[count] = malloc( strlen(msgstr)+3 );
strcpy((char*)menu_titles[count], " ");
@ -543,7 +603,6 @@ void bind_global_events( void )
EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
/* TODO: maybe instant redraw after this is better! */
set_menu_title( MAINMENU_T_FILE, "Page");
set_menu_title( MAINMENU_T_EDIT, "Edit" );
set_menu_title( MAINMENU_T_NAVIGATE, "Navigate");
@ -618,6 +677,8 @@ void bind_global_events( void )
i=0;
while( menu_evnt_tbl[i].rid != -1 ) {
if( menu_evnt_tbl[i].menustr != NULL ) {
// TODO: modify resource tree, adjust width of menu to chars
// actually used.
MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
}
i++;

View File

@ -555,31 +555,6 @@ gui_window_set_search_ico(hlcache_handle *ico)
TODO();
}
bool
save_complete_gui_save(const char *path,
const char *filename,
size_t len,
const char *sourcedata,
lwc_string *mime_type)
{
TODO();
LOG(("%s", filename));
return false;
}
int
save_complete_htmlSaveFileFormat(const char *path,
const char *filename,
xmlDocPtr cur,
const char *encoding,
int format)
{
LOG(("%s", filename));
TODO();
return 0;
}
void gui_window_new_content(struct gui_window *w)
{
w->browser->scroll.current.x = 0;
@ -810,6 +785,7 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
if( bres )
urldb_set_cert_permissions(url, true);
*/
// TODO: localize string
int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort]");
bres = (b==1)? true : false;
LOG(("Trust: %d", bres ));

View File

@ -302,6 +302,36 @@ long nkc_to_input_key(short nkc, long * ucs4_out)
return ( ik );
}
/**
* Show default file selector
*
* \param title The selector title.
* \param name Default file name
* \return a static char pointer or null if the user aborted the selection.
*/
const char * file_select( const char * title, const char * name ) {
static char path[PATH_MAX]=""; // First usage : current directory
static char fullname[PATH_MAX]="";
char tmpname[255];
char * use_title = (char*)title;
if( strlen(name)>254)
return( NULL );
strcpy( tmpname, name );
if( use_title == NULL ){
use_title = (char*)"";
}
if( FselInput( path, tmpname, (char*)"", use_title, NULL, NULL)) {
strncpy( fullname, path, PATH_MAX-1 );
strncat( fullname, tmpname, PATH_MAX-strlen(fullname)-1 );
return( (const char*)&fullname );
}
return( NULL );
}
void dbg_lgrect( char * str, LGRECT * r )
{

View File

@ -43,4 +43,5 @@ void * ldg_open( char * name, short * global );
void * ldg_find( char * name, short * ldg );
int ldg_close( void * ldg, short * global );
long nkc_to_input_key(short nkc, long * ucs4_out);
const char * file_select( const char * title, const char * name );
#endif

View File

@ -71,13 +71,17 @@ int atari_plotter_init( char* drvrname, char * fdrvrname )
LOG(("using plotters: %s, %s", drvrname, fdrvrname));
fplotter = new_font_plotter(vdih, fdrvrname, 0, &err );
if(err)
die(("Unable to load font plotter %s -> %s", fdrvrname, plotter_err_str(err) ));
if(err){
char * desc = plotter_err_str(err);
die(("Unable to load font plotter %s -> %s", fdrvrname, desc ));
}
plotter = new_plotter( vdih, drvrname, &loc_pos, drvinfo->max_bpp,
flags, fplotter, &err );
if(err)
die(("Unable to load graphics plotter %s -> %s", drvrname, plotter_err_str(err) ));
if(err){
char * desc = plotter_err_str(err);
die(("Unable to load graphics plotter %s -> %s", drvrname, desc ));
}
return( err );
}

View File

@ -90,7 +90,9 @@ void schedule_remove(void (*callback)(void *p), void *p)
if (schedule_list == NULL)
return;
#ifdef DEBUG_SCHEDULER
LOG(("removing %p, %p", callback, p));
#endif
cur_nscb = schedule_list;
prev_nscb = NULL;
@ -99,7 +101,9 @@ void schedule_remove(void (*callback)(void *p), void *p)
if ((cur_nscb->callback == callback) &&
(cur_nscb->p == p)) {
/* item to remove */
#ifdef DEBUG_SCHEDULER
LOG(("callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p));
#endif
/* remove callback */
unlnk_nscb = cur_nscb;
@ -152,14 +156,18 @@ schedule_run(void)
prev_nscb->next = unlnk_nscb->next;
}
#ifdef DEBUG_SCHEDULER
LOG(("callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p));
#endif
/* call callback */
unlnk_nscb->callback(unlnk_nscb->p);
free(unlnk_nscb);
/* need to deal with callback modifying the list. */
if (schedule_list == NULL) {
#ifdef DEBUG_SCHEDULER
LOG(("schedule_list == NULL"));
#endif
return -1; /* no more callbacks scheduled */
}
@ -182,8 +190,9 @@ schedule_run(void)
/* make rettime relative to now and convert to ms */
nexttime = (nexttime - now)*10;
#ifdef DEBUG_SCHEDULER
LOG(("returning time to next event as %ldms", nexttime ));
#endif
/*return next event time in milliseconds (24days max wait) */
return ( nexttime );
}

View File

@ -101,24 +101,28 @@ touch $dst"cookies"
cp $src"atari/doc" $dst -R
cp $src"ns.prg" $dst
chmod +x $dst"ns.prg"
strip $dst"ns.prg"
stack -S 256k $dst"ns.prg"
m68k-atari-mint-strip $dst"ns.prg"
m68k-atari-mint-stack -S 256k $dst"ns.prg"
cp $src"atari/res/" $dst -rL
cp $src"\!NetSurf/Resources/AdBlock,f79" $dst"res/adblock.css" -rL
cp $src"\!NetSurf/Resources/CSS,f79" $dst"res/default.css" -rL
cp $src"\!NetSurf/Resources/Quirks,f79" $dst"res/quirks.css" -rL
cp $src"\!NetSurf/Resources/internal.css,f79" $dst"res/internal.css" -rL
cp $src"\!NetSurf/Resources/SearchEngines" $dst"res/search" -rL
cp $src"\!NetSurf/Resources/ca-bundle" $dst"res/cabundle" -rL
cp $src"\!NetSurf/Resources/en/Messages" $dst"res/messages" -rL
cp $src"\!NetSurf/Resources/Icons/content.png" $dst"res/icons/content.png" -rL
cp $src"\!NetSurf/Resources/Icons/directory.png" $dst"res/icons/dir.png" -rL
cp $src"!NetSurf/Resources/AdBlock,f79" $dst"res/adblock.css" -rL
cp $src"!NetSurf/Resources/CSS,f79" $dst"res/default.css" -rL
cp $src"!NetSurf/Resources/Quirks,f79" $dst"res/quirks.css" -rL
cp $src"!NetSurf/Resources/internal.css,f79" $dst"res/internal.css" -rL
cp $src"!NetSurf/Resources/SearchEngines" $dst"res/search" -rL
cp $src"!NetSurf/Resources/ca-bundle" $dst"res/cabundle" -rL
cp $src"!NetSurf/Resources/en/Messages" $dst"res/messages" -rL
cp $src"!NetSurf/Resources/Icons/content.png" $dst"res/icons/content.png" -rL
cp $src"!NetSurf/Resources/Icons/directory.png" $dst"res/icons/dir.png" -rL
#remove uneeded files:
rm $dst"res/netsurf.rsm"
rm $dst"res/netsurf.rsh"
rm $dst"res/.svn" -r
rm $dst"res/icons/.svn" -r
rm $dst"res/fonts/.svn" -r
rm $dst"doc/.svn" -r
rm $dst"download/.svn" -r
if [ "$inc_short_fonts" = "1" ]
then
@ -159,8 +163,8 @@ http_proxy_auth:0
http_proxy_auth_user:
http_proxy_auth_pass:
suppress_curl_debug:1
font_size:120
font_min_size:110
font_size:130
font_min_size:120
memory_cache_size:204800
block_advertisements:0
minimum_gif_delay:0
@ -177,9 +181,9 @@ hotlist_path:./res/hotlist
incremental_reflow:1
min_reflow_period:350
core_select_menu:1
max_fetchers:6
max_fetchers:3
max_fetchers_per_host:2
max_cached_fetch_handles:6
max_cached_fetch_handles:5
target_blank:1
suppress_images:0
remove_backgrounds:0

View File

@ -688,7 +688,7 @@ bool tb_url_input( struct gui_window * gw, short nkc )
else if( ik == KEY_CR || ik == KEY_NL ){
char tmp_url[PATH_MAX];
if( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
window_set_focus( gw, BROWSER, gw->browser->bw);
window_set_focus( gw, BROWSER, gw->browser);
browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
ret = true;
}