diff options
Diffstat (limited to 'frontends/atari')
26 files changed, 719 insertions, 645 deletions
diff --git a/frontends/atari/Makefile b/frontends/atari/Makefile index b4fb16ec1..a2f27e2f2 100644 --- a/frontends/atari/Makefile +++ b/frontends/atari/Makefile @@ -47,6 +47,7 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall -Dnsatari \ -D_BSD_SOURCE \ -D_XOPEN_SOURCE=600 \ -D_POSIX_C_SOURCE=200112L \ + -DNSLOG_LEVEL_0x0010=NSLOG_LEVEL_INFO \ $(shell $(PKG_CONFIG) --cflags openssl ) \ $(shell $(PKG_CONFIG) --cflags libcurl ) diff --git a/frontends/atari/bitmap.c b/frontends/atari/bitmap.c index cbb719586..ae42da837 100644 --- a/frontends/atari/bitmap.c +++ b/frontends/atari/bitmap.c @@ -81,7 +81,9 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns { struct bitmap * bitmap; - LOG("width %d (rowstride: %d, bpp: %d), height %d, state %u", w, rowstride, bpp, h, state); + NSLOG(netsurf, INFO, + "width %d (rowstride: %d, bpp: %d), height %d, state %u", w, + rowstride, bpp, h, state); if( rowstride == 0) { rowstride = bpp * w; @@ -107,10 +109,10 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns } else { free(bitmap); bitmap=NULL; - LOG("Out of memory!"); + NSLOG(netsurf, INFO, "Out of memory!"); } } - LOG("bitmap %p", bitmap); + NSLOG(netsurf, INFO, "bitmap %p", bitmap); return bitmap; } @@ -194,7 +196,7 @@ static unsigned char *bitmap_get_buffer(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return NULL; } @@ -218,7 +220,7 @@ size_t atari_bitmap_get_rowstride(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } return bm->rowstride; @@ -231,7 +233,7 @@ void atari_bitmap_destroy(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } @@ -272,11 +274,12 @@ static void bitmap_set_opaque(void *bitmap, bool opaque) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } - LOG("setting bitmap %p to %s", bm, opaque ? "opaque" : "transparent"); + NSLOG(netsurf, INFO, "setting bitmap %p to %s", bm, + opaque ? "opaque" : "transparent"); bm->opaque = opaque; } @@ -293,7 +296,7 @@ static bool bitmap_test_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -305,11 +308,12 @@ static bool bitmap_test_opaque(void *bitmap) while (tst-- > 0) { if (bm->pixdata[(tst << 2) + 3] != 0xff) { - LOG("bitmap %p has transparency", bm); + NSLOG(netsurf, INFO, + "bitmap %p has transparency", bm); return false; } } - LOG("bitmap %p is opaque", bm); + NSLOG(netsurf, INFO, "bitmap %p is opaque", bm); return true; } @@ -320,7 +324,7 @@ bool atari_bitmap_get_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -334,7 +338,7 @@ int atari_bitmap_get_width(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } @@ -348,7 +352,7 @@ int atari_bitmap_get_height(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } return(bm->height); diff --git a/frontends/atari/certview.c b/frontends/atari/certview.c index 6950d31f8..80d18a059 100644 --- a/frontends/atari/certview.c +++ b/frontends/atari/certview.c @@ -81,7 +81,7 @@ static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw, assert(ssl_d); - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(sslcert_viewer_init(cb_t, cw, ssl_d)); } @@ -97,7 +97,7 @@ static void atari_sslcert_viewer_finish(struct core_window *cw) /* This will also free the session data: */ sslcert_viewer_fini(cvwin->ssl_session_data); - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); } static void atari_sslcert_viewer_draw(struct core_window *cw, int x, @@ -123,7 +123,7 @@ static void atari_sslcert_viewer_keypress(struct core_window *cw, uint32_t ucs4) cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw); - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); sslcert_viewer_keypress(cvwin->ssl_session_data, ucs4); } @@ -150,14 +150,14 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) short retval = 0; OBJECT *toolbar; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if(ev_out->emo_events & MU_MESAG){ switch (msg[0]) { case WM_TOOLBAR: toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT); - LOG("CERTVIEWER WM_TOOLBAR"); + NSLOG(netsurf, INFO, "CERTVIEWER WM_TOOLBAR"); tv = (struct core_window*) gemtk_wm_get_user_data(win); assert(tv); cvwin = (struct atari_sslcert_viewer_s *) @@ -238,7 +238,7 @@ static void atari_sslcert_viewer_init(struct atari_sslcert_viewer_s * cvwin, if (cvwin->tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, "Failed to allocate treeview"); return; } @@ -280,7 +280,7 @@ static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin) assert(cvwin->init); assert(cvwin->window); - LOG("cvwin %p", cvwin); + NSLOG(netsurf, INFO, "cvwin %p", cvwin); if (atari_treeview_is_open(cvwin->tv)) atari_treeview_close(cvwin->tv); @@ -289,5 +289,5 @@ static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin) cvwin->window = NULL; atari_treeview_delete(cvwin->tv); free(cvwin); - LOG("done"); + NSLOG(netsurf, INFO, "done"); } diff --git a/frontends/atari/cookies.c b/frontends/atari/cookies.c index 9045009fc..df2de0d4c 100644 --- a/frontends/atari/cookies.c +++ b/frontends/atari/cookies.c @@ -63,7 +63,7 @@ static nserror atari_cookie_manager_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw %p",cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(cookie_manager_init(cb_t, cw)); } @@ -71,7 +71,7 @@ atari_cookie_manager_init_phase2(struct core_window *cw, static void atari_cookie_manager_finish(struct core_window *cw) { - LOG("cw %p",cw); + NSLOG(netsurf, INFO, "cw %p", cw); cookie_manager_fini(); } @@ -89,7 +89,7 @@ atari_cookie_manager_draw(struct core_window *cw, static void atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4) { - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); cookie_manager_keypress(ucs4); } @@ -108,13 +108,13 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) { short retval = 0; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if (ev_out->emo_events & MU_MESAG) { switch (msg[0]) { case WM_TOOLBAR: - LOG("WM_TOOLBAR"); + NSLOG(netsurf, INFO, "WM_TOOLBAR"); break; case WM_CLOSED: @@ -158,7 +158,8 @@ void atari_cookie_manager_init(void) if (atari_cookie_manager.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } @@ -209,7 +210,7 @@ void atari_cookie_manager_destroy(void) atari_treeview_delete(atari_cookie_manager.tv); atari_cookie_manager.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } diff --git a/frontends/atari/ctxmenu.c b/frontends/atari/ctxmenu.c index e25d8e522..ef4f01ae2 100644 --- a/frontends/atari/ctxmenu.c +++ b/frontends/atari/ctxmenu.c @@ -288,7 +288,9 @@ void context_popup(struct gui_window * gw, short x, short y) /* the GEMDOS cmdline contains the length of the commandline in the first byte: */ cmdline[0] = (unsigned char)strlen(tempfile); - LOG("Creating temporay source file: %s\n", tempfile); + NSLOG(netsurf, INFO, + "Creating temporay source file: %s\n", + tempfile); fp_tmpfile = fopen(tempfile, "w"); if (fp_tmpfile != NULL){ fwrite(data, size, 1, fp_tmpfile); @@ -306,7 +308,8 @@ void context_popup(struct gui_window * gw, short x, short y) } } else { - LOG("Invalid content!"); + NSLOG(netsurf, INFO, + "Invalid content!"); } } else { form_alert(0, "[1][Set option \"atari_editor\".][OK]"); diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c index addba2764..ded68ca5b 100644 --- a/frontends/atari/deskmenu.c +++ b/frontends/atari/deskmenu.c @@ -181,7 +181,7 @@ static void __CDECL menu_about(short item, short title, void *data) nserror error; char buf[PATH_MAX]; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "abort menu"); strcpy((char*)&buf, "file://"); strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) ); @@ -208,7 +208,7 @@ static void __CDECL menu_new_win(short item, short title, void *data) nserror error; const char *addr; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (nsoption_charp(homepage_url) != NULL) { addr = nsoption_charp(homepage_url); @@ -236,7 +236,7 @@ static void __CDECL menu_open_url(short item, short title, void *data) { struct gui_window * gw; struct browser_window * bw ; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); gw = input_window; if( gw == NULL ) { @@ -251,7 +251,7 @@ static void __CDECL menu_open_url(short item, short title, void *data) static void __CDECL menu_open_file(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); const char * filename = file_select(messages_get("OpenFile"), ""); if( filename != NULL ){ @@ -280,7 +280,7 @@ static void __CDECL menu_open_file(short item, short title, void *data) static void __CDECL menu_close_win(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; gui_window_destroy( input_window ); @@ -288,7 +288,7 @@ static void __CDECL menu_close_win(short item, short title, void *data) static void __CDECL menu_save_page(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); static bool init = true; bool is_folder=false; const char * path; @@ -319,7 +319,7 @@ static void __CDECL menu_quit(short item, short title, void *data) { short buff[8]; memset( &buff, 0, sizeof(short)*8 ); - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); gemtk_wm_send_msg(NULL, AP_TERM, 0, 0, 0, 0); } @@ -331,21 +331,21 @@ static void __CDECL menu_cut(short item, short title, void *data) static void __CDECL menu_copy(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != NULL ) browser_window_key_press( input_window->browser->bw, NS_KEY_COPY_SELECTION); } static void __CDECL menu_paste(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != NULL ) browser_window_key_press( input_window->browser->bw, NS_KEY_PASTE); } static void __CDECL menu_find(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window != NULL) { if (input_window->search) { window_close_search(input_window->root); @@ -358,13 +358,13 @@ static void __CDECL menu_find(short item, short title, void *data) static void __CDECL menu_choices(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); open_settings(); } static void __CDECL menu_stop(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; @@ -378,7 +378,7 @@ static void __CDECL menu_reload(short item, short title, void *data) if(input_window == NULL) return; toolbar_reload_click(input_window->root->toolbar); - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); } @@ -408,7 +408,7 @@ static void __CDECL menu_dec_scale(short item, short title, void *data) static void __CDECL menu_toolbars(short item, short title, void *data) { static int state = 0; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != null && input_window->root->toolbar != null ){ state = !state; // TODO: implement toolbar hide @@ -418,7 +418,7 @@ static void __CDECL menu_toolbars(short item, short title, void *data) static void __CDECL menu_savewin(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window && input_window->browser) { GRECT rect; wind_get_grect(gemtk_wm_get_handle(input_window->root->win), WF_CURRXYWH, @@ -438,7 +438,7 @@ static void __CDECL menu_savewin(short item, short title, void *data) static void __CDECL menu_debug_render(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); html_redraw_debug = !html_redraw_debug; if( input_window != NULL ) { if ( input_window->browser != NULL @@ -469,7 +469,7 @@ static void __CDECL menu_bg_images(short item, short title, void *data) static void __CDECL menu_back(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_back_click(input_window->root->toolbar); @@ -477,7 +477,7 @@ static void __CDECL menu_back(short item, short title, void *data) static void __CDECL menu_forward(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_forward_click(input_window->root->toolbar); @@ -485,7 +485,7 @@ static void __CDECL menu_forward(short item, short title, void *data) static void __CDECL menu_home(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_home_click(input_window->root->toolbar); @@ -493,20 +493,20 @@ static void __CDECL menu_home(short item, short title, void *data) static void __CDECL menu_lhistory(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; } static void __CDECL menu_ghistory(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_global_history_open(); } static void __CDECL menu_add_bookmark(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window) { if( browser_window_has_content(input_window->browser->bw) ){ atari_hotlist_add_page( @@ -519,26 +519,26 @@ static void __CDECL menu_add_bookmark(short item, short title, void *data) static void __CDECL menu_bookmarks(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_hotlist_open(); } static void __CDECL menu_cookies(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_cookie_manager_open(); } static void __CDECL menu_vlog(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); verbose_log = !verbose_log; menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0); } static void __CDECL menu_help_content(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); } /* @@ -580,14 +580,16 @@ static void register_menu_str( struct s_menu_item_evnt * mi ) while (i > 2) { if ((strncmp(" ", &str[i], 2) == 0) && (strlen(&str[i]) > 2)) { // "Standard" Keyboard Shortcut Element found: - LOG("Standard Keyboard Shortcut: \"%s\"\n", &str[i]); + NSLOG(netsurf, INFO, + "Standard Keyboard Shortcut: \"%s\"\n", &str[i]); x = i+2; is_std_shortcut = true; break; } if( str[i] == '['){ - LOG("Keyboard Shortcut: \"%s\"\n", &str[i]); + NSLOG(netsurf, INFO, "Keyboard Shortcut: \"%s\"\n", + &str[i]); // "Custom" Keyboard Shortcut Element found (identified by [): x = i; break; @@ -662,8 +664,12 @@ static void register_menu_str( struct s_menu_item_evnt * mi ) } } - LOG("Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n", - str, accel->mod, accel->keycode, accel->ascii); + NSLOG(netsurf, INFO, + "Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n", + str, + accel->mod, + accel->keycode, + accel->ascii); } } diff --git a/frontends/atari/download.c b/frontends/atari/download.c index d756e6694..7a1c7d2b7 100644 --- a/frontends/atari/download.c +++ b/frontends/atari/download.c @@ -194,7 +194,7 @@ static void on_close(struct gui_download_window * dw) static void gui_download_window_destroy( struct gui_download_window * gdw) { - LOG("gdw %p", gdw); + NSLOG(netsurf, INFO, "gdw %p", gdw); if (gdw->status == NSATARI_DOWNLOAD_WORKING) { download_context_abort(gdw->ctx); @@ -253,7 +253,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent) char alert[200]; - LOG("Creating download window for gui window: %p", parent); + NSLOG(netsurf, INFO, "Creating download window for gui window: %p", + parent); /* TODO: Implement real form and use messages file strings! */ @@ -330,7 +331,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent) gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb); strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1); - LOG("created download: %s (total size: %d)", gdw->destination, gdw->size_total); + NSLOG(netsurf, INFO, "created download: %s (total size: %d)", + gdw->destination, gdw->size_total); GRECT work, curr; work.g_x = 0; @@ -357,7 +359,7 @@ static nserror gui_download_window_data(struct gui_download_window *dw, uint32_t tnow = clck / (CLOCKS_PER_SEC>>3); uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->start; - LOG("dw %p",dw); + NSLOG(netsurf, INFO, "dw %p", dw); if (dw->abort == true){ dw->status = NSATARI_DOWNLOAD_CANCELED; @@ -405,7 +407,7 @@ static nserror gui_download_window_data(struct gui_download_window *dw, static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { - LOG("%s", error_msg); + NSLOG(netsurf, INFO, "%s", error_msg); strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1); dw->status = NSATARI_DOWNLOAD_ERROR; @@ -416,7 +418,7 @@ static void gui_download_window_error(struct gui_download_window *dw, static void gui_download_window_done(struct gui_download_window *dw) { - LOG("dw %p", dw); + NSLOG(netsurf, INFO, "dw %p", dw); // TODO: change abort to close dw->status = NSATARI_DOWNLOAD_COMPLETE; diff --git a/frontends/atari/filetype.c b/frontends/atari/filetype.c index d27076e9c..706347137 100644 --- a/frontends/atari/filetype.c +++ b/frontends/atari/filetype.c @@ -36,7 +36,7 @@ const char *fetch_filetype(const char *unix_path) char * res = (char*)"text/html"; l = strlen(unix_path); - LOG("unix path: %s", unix_path); + NSLOG(netsurf, INFO, "unix path: %s", unix_path); /* This line is added for devlopment versions running from the root dir: */ if( strchr( unix_path, (int)'.' ) ){ @@ -85,6 +85,6 @@ const char *fetch_filetype(const char *unix_path) } } - LOG("mime type: %s", res); + NSLOG(netsurf, INFO, "mime type: %s", res); return( res ); } diff --git a/frontends/atari/findfile.c b/frontends/atari/findfile.c index 45ca6d916..8784727bc 100644 --- a/frontends/atari/findfile.c +++ b/frontends/atari/findfile.c @@ -31,7 +31,7 @@ char * local_file_to_url( const char * filename ) #define BACKSLASH 0x5C char * url; - LOG("in: %s", filename); + NSLOG(netsurf, INFO, "in: %s", filename); if( strlen(filename) <= 2){ return( NULL ); @@ -55,7 +55,7 @@ char * local_file_to_url( const char * filename ) free(fname_local); - LOG("out: %s", url); + NSLOG(netsurf, INFO, "out: %s", url); return( url ); #undef BACKSLASH @@ -81,10 +81,10 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) { char *cdir = NULL; char t[PATH_MAX]; - LOG("%s (def: %s)", filename, def); + NSLOG(netsurf, INFO, "%s (def: %s)", filename, def); strcpy(t, NETSURF_GEM_RESPATH); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) { return buf; @@ -92,7 +92,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) } strcpy(t, "./"); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) { return buf; @@ -104,7 +104,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) strcpy(t, cdir); strcat(t, "/.netsurf/"); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) return buf; @@ -116,19 +116,19 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) if (gemdos_realpath(cdir, buf) != NULL) { strcat(buf, "/"); strcat(buf, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (access(buf, R_OK) == 0) return buf; } } if (def[0] == '~') { snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) == NULL) { strcpy(buf, t); } } else { - LOG("checking %s", (char *)def); + NSLOG(netsurf, INFO, "checking %s", (char *)def); if (gemdos_realpath(def, buf) == NULL) { strcpy(buf, def); } diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index 4876d3106..6ee63b301 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -139,11 +139,11 @@ static void atari_poll(void) evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); if(gemtk_wm_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out) == 0) { if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { - LOG("WM: %d\n", aes_msg_out[0]); + NSLOG(netsurf, INFO, "WM: %d\n", aes_msg_out[0]); switch(aes_msg_out[0]) { case MN_SELECTED: - LOG("Menu Item: %d\n", aes_msg_out[4]); + NSLOG(netsurf, INFO, "Menu Item: %d\n", aes_msg_out[4]); deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); break; @@ -195,13 +195,14 @@ gui_window_create(struct browser_window *bw, gui_window_create_flags flags) { struct gui_window *gw=NULL; - LOG("gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, existing, (int)flags); + NSLOG(netsurf, INFO, "gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, + existing, (int)flags); gw = calloc(1, sizeof(struct gui_window)); if (gw == NULL) return NULL; - LOG("new window: %p, bw: %p\n", gw, bw); + NSLOG(netsurf, INFO, "new window: %p, bw: %p\n", gw, bw); window_create(gw, bw, existing, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\ |WIDGET_SCROLL); if (gw->root->win) { @@ -253,7 +254,7 @@ void gui_window_destroy(struct gui_window *gw) if (gw == NULL) return; - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if (input_window == gw) { gui_set_input_gui_window(NULL); @@ -444,7 +445,8 @@ gui_window_set_scroll(struct gui_window *gw, const struct rect *rect) return NSERROR_BAD_PARAMETER; } - LOG("scroll (gui_window: %p) %d, %d\n", gw, rect->x0, rect->y0); + NSLOG(netsurf, INFO, "scroll (gui_window: %p) %d, %d\n", gw, rect->x0, + rect->y0); window_scroll_by(gw->root, rect->x0, rect->y0); return NSERROR_OK; @@ -771,7 +773,8 @@ static void gui_401login_open(nsurl *url, const char *realm, char * out = NULL; bres = login_form_do( url, (char*)realm, &out); if (bres) { - LOG("url: %s, realm: %s, auth: %s\n", nsurl_access(url), realm, out); + NSLOG(netsurf, INFO, "url: %s, realm: %s, auth: %s\n", + nsurl_access(url), realm, out); urldb_set_auth_details(url, realm, out); } if (out != NULL) { @@ -789,7 +792,7 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, void *cbpw) { struct sslcert_session_data *data; - LOG("url %s", nsurl_access(url)); + NSLOG(netsurf, INFO, "url %s", nsurl_access(url)); // TODO: localize string int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort|Details...]"); @@ -812,7 +815,8 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, void gui_set_input_gui_window(struct gui_window *gw) { - LOG("Setting input window from: %p to %p\n", input_window, gw); + NSLOG(netsurf, INFO, "Setting input window from: %p to %p\n", + input_window, gw); input_window = gw; } @@ -823,7 +827,7 @@ struct gui_window * gui_get_input_window(void) static void gui_quit(void) { - LOG("quitting"); + NSLOG(netsurf, INFO, "quitting"); struct gui_window *gw = window_list; struct gui_window *tmp = window_list; @@ -852,9 +856,9 @@ static void gui_quit(void) rsrc_free(); - LOG("Shutting down plotter"); + NSLOG(netsurf, INFO, "Shutting down plotter"); plot_finalise(); - LOG("done"); + NSLOG(netsurf, INFO, "done"); } /** @@ -866,7 +870,7 @@ process_cmdline(int argc, char** argv) int opt; bool set_default_dimensions = true; - LOG("argc %d, argv %p", argc, argv); + NSLOG(netsurf, INFO, "argc %d, argv %p", argc, argv); if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) { @@ -959,7 +963,7 @@ static nserror set_defaults(struct nsoption_s *defaults) /* Set defaults for absent option strings */ nsoption_setnull_charp(cookie_file, strdup("cookies")); if (nsoption_charp(cookie_file) == NULL) { - LOG("Failed initialising string options"); + NSLOG(netsurf, INFO, "Failed initialising string options"); return NSERROR_BAD_PARAMETER; } return NSERROR_OK; @@ -976,7 +980,7 @@ static void gui_init(int argc, char** argv) OBJECT * cursors; atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc"); - LOG("Using RSC file: %s ", (char *)&buf); + NSLOG(netsurf, INFO, "Using RSC file: %s ", (char *)&buf); if (rsrc_load(buf)==0) { char msg[1024]; @@ -1012,15 +1016,16 @@ static void gui_init(int argc, char** argv) create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP, cursors, &gem_cursors.help); - LOG("Enabling core select menu"); + NSLOG(netsurf, INFO, "Enabling core select menu"); nsoption_set_bool(core_select_menu, true); - LOG("Loading url.db from: %s", nsoption_charp(url_file)); + NSLOG(netsurf, INFO, "Loading url.db from: %s", nsoption_charp(url_file)); if( strlen(nsoption_charp(url_file)) ) { urldb_load(nsoption_charp(url_file)); } - LOG("Loading cookies from: %s", nsoption_charp(cookie_file)); + NSLOG(netsurf, INFO, "Loading cookies from: %s", + nsoption_charp(cookie_file)); if( strlen(nsoption_charp(cookie_file)) ) { urldb_load_cookies(nsoption_charp(cookie_file)); } @@ -1028,10 +1033,10 @@ static void gui_init(int argc, char** argv) if (process_cmdline(argc,argv) != true) die("unable to process command line.\n"); - LOG("Initializing NKC..."); + NSLOG(netsurf, INFO, "Initializing NKC..."); nkc_init(); - LOG("Initializing plotters..."); + NSLOG(netsurf, INFO, "Initializing plotters..."); struct redraw_context ctx = { .interactive = true, .background_images = true, @@ -1172,18 +1177,18 @@ int main(int argc, char** argv) ret = messages_add_from_file(messages); /* common initialisation */ - LOG("Initialising core..."); + NSLOG(netsurf, INFO, "Initialising core..."); ret = netsurf_init(store); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } - LOG("Initializing GUI..."); + NSLOG(netsurf, INFO, "Initializing GUI..."); gui_init(argc, argv); graf_mouse( ARROW , NULL); - LOG("Creating initial browser window..."); + NSLOG(netsurf, INFO, "Creating initial browser window..."); addr = option_homepage_url; if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) { if (stat(addr, &stat_buf) == 0) { @@ -1205,7 +1210,7 @@ int main(int argc, char** argv) if (ret != NSERROR_OK) { atari_warn_user(messages_get_errorcode(ret), 0); } else { - LOG("Entering Atari event mainloop..."); + NSLOG(netsurf, INFO, "Entering Atari event mainloop..."); while (!atari_quit) { atari_poll(); } @@ -1219,7 +1224,11 @@ int main(int argc, char** argv) fclose(stdout); fclose(stderr); #endif - LOG("exit_gem"); + NSLOG(netsurf, INFO, "exit_gem"); + + /* finalise logging */ + nslog_finalise(); + exit_gem(); return 0; diff --git a/frontends/atari/history.c b/frontends/atari/history.c index 56aafd056..ec602684f 100644 --- a/frontends/atari/history.c +++ b/frontends/atari/history.c @@ -39,13 +39,13 @@ static nserror atari_global_history_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(global_history_init(cb_t, cw)); } static void atari_global_history_finish(struct core_window *cw) { - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); global_history_fini(); } @@ -58,7 +58,7 @@ static void atari_global_history_draw(struct core_window *cw, int x, static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4) { - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); global_history_keypress(ucs4); } @@ -67,7 +67,7 @@ atari_global_history_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y) { - LOG("x: %d, y: %d\n", x, y); + NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y); global_history_mouse_action(mouse, x, y); } @@ -82,7 +82,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) { short retval = 0; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if (ev_out->emo_events & MU_MESAG) { switch (msg[0]) { @@ -134,7 +134,8 @@ void atari_global_history_init(void) if (atari_global_history.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } } @@ -181,7 +182,7 @@ void atari_global_history_destroy(void) atari_treeview_delete(atari_global_history.tv); atari_global_history.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } void atari_global_history_redraw(void) diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c index 659b3a562..3a54c98eb 100644 --- a/frontends/atari/hotlist.c +++ b/frontends/atari/hotlist.c @@ -72,13 +72,13 @@ static struct atari_treeview_callbacks atari_hotlist_treeview_callbacks = { static nserror atari_hotlist_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw:%p", cw); + NSLOG(netsurf, INFO, "cw:%p", cw); return hotlist_manager_init(cb_t, cw); } static void atari_hotlist_finish(struct core_window *cw) { - LOG("cw:%p", cw); + NSLOG(netsurf, INFO, "cw:%p", cw); hotlist_fini(); } @@ -93,7 +93,7 @@ static void atari_hotlist_keypress(struct core_window *cw, uint32_t ucs4) { //GUIWIN *gemtk_win; //GRECT area; - LOG("ucs4: %"PRIu32 , ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); hotlist_keypress(ucs4); //gemtk_win = atari_treeview_get_gemtk_window(cw); //atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &area); @@ -104,7 +104,7 @@ static void atari_hotlist_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y) { - LOG("x: %d, y: %d\n", x, y); + NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y); hotlist_mouse_action(mouse, x, y); } @@ -123,7 +123,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) GRECT tb_area; GUIWIN * gemtk_win; - LOG("gw:%p", win); + NSLOG(netsurf, INFO, "gw:%p", win); tv = (struct atari_treeview_window*) gemtk_wm_get_user_data(win); cw = (struct core_window *)tv; @@ -132,7 +132,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[0]) { case WM_TOOLBAR: - LOG("WM_TOOLBAR"); + NSLOG(netsurf, INFO, "WM_TOOLBAR"); toolbar = gemtk_obj_get_tree(TOOLBAR_HOTLIST); @@ -198,7 +198,7 @@ void atari_hotlist_init(void) strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 ); } - LOG("Hotlist: %s", (char *)&hl.path); + NSLOG(netsurf, INFO, "Hotlist: %s", (char *)&hl.path); hotlist_init(hl.path, hl.path); if( hl.window == NULL ){ @@ -224,7 +224,8 @@ void atari_hotlist_init(void) if (hl.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } @@ -276,7 +277,7 @@ void atari_hotlist_destroy(void) atari_treeview_delete(hl.tv); hl.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } void atari_hotlist_redraw(void) @@ -299,7 +300,7 @@ void atari_hotlist_add_page( const char * url, const char * title ) return; if (hotlist_has_url(nsurl)) { - LOG("URL already added as Bookmark"); + NSLOG(netsurf, INFO, "URL already added as Bookmark"); nsurl_unref(nsurl); return; } diff --git a/frontends/atari/osspec.c b/frontends/atari/osspec.c index f64402e8d..ca042f164 100644 --- a/frontends/atari/osspec.c +++ b/frontends/atari/osspec.c @@ -119,14 +119,14 @@ char *gemdos_realpath(const char * path, char * rpath) return(rpath); } - LOG("realpath in: %s\n", path); + NSLOG(netsurf, INFO, "realpath in: %s\n", path); r = realpath(path, work); if (r != NULL) { unx2dos((const char *)r, rpath); - LOG("realpath out: %s\n", rpath); + NSLOG(netsurf, INFO, "realpath out: %s\n", rpath); return(rpath); } else { - LOG("realpath out: NULL!\n"); + NSLOG(netsurf, INFO, "realpath out: NULL!\n"); } return (NULL); } diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c index 17d3c3bfd..1688e978b 100644 --- a/frontends/atari/plot/font_freetype.c +++ b/frontends/atari/plot/font_freetype.c @@ -154,11 +154,12 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Po error = FT_New_Face(library, ft_face->fontfile, ft_face->index, face); if (error) { - LOG("Could not find font (code %d)\n", error); + NSLOG(netsurf, INFO, "Could not find font (code %d)\n", error); } else { error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE); if (error) { - LOG("Could not select charmap (code %d)\n", error); + NSLOG(netsurf, INFO, + "Could not select charmap (code %d)\n", error); } else { for (cidx = 0; cidx < (*face)->num_charmaps; cidx++) { if ((*face)->charmap == (*face)->charmaps[cidx]) { @@ -168,7 +169,7 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Po } } } - LOG("Loaded face from %s\n", ft_face->fontfile); + NSLOG(netsurf, INFO, "Loaded face from %s\n", ft_face->fontfile); return error; } @@ -190,7 +191,9 @@ ft_new_face(const char *option, const char *resname, const char *fontfile) } error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)newf, &aface); if (error) { - LOG("Could not find font face %s (code %d)\n", fontfile, error); + NSLOG(netsurf, INFO, + "Could not find font face %s (code %d)\n", fontfile, + error); free(newf); newf = font_faces[FONT_FACE_DEFAULT]; /* use default */ } @@ -292,7 +295,8 @@ static bool ft_font_init(void) /* freetype library initialise */ error = FT_Init_FreeType( &library ); if (error) { - LOG("Freetype could not initialised (code %d)\n", error); + NSLOG(netsurf, INFO, + "Freetype could not initialised (code %d)\n", error); return false; } @@ -311,7 +315,9 @@ static bool ft_font_init(void) NULL, &ft_cmanager); if (error) { - LOG("Freetype could not initialise cache manager (code %d)\n", error); + NSLOG(netsurf, INFO, + "Freetype could not initialise cache manager (code %d)\n", + error); FT_Done_FreeType(library); return false; } @@ -330,7 +336,8 @@ static bool ft_font_init(void) FONT_PKG_PATH FONT_FILE_SANS ); if (font_faces[FONT_FACE_SANS_SERIF] == NULL) { - LOG("Could not find default font (code %d)\n", error); + NSLOG(netsurf, INFO, + "Could not find default font (code %d)\n", error); FTC_Manager_Done(ft_cmanager); FT_Done_FreeType(library); return false; @@ -688,7 +695,7 @@ int ctor_font_plotter_freetype( FONT_PLOTTER self ) self->draw_glyph = draw_glyph8; } - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { ft_font_init(); fontbmp = atari_bitmap_create(48, 48, 0); diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c index 3575bc3e1..709697f74 100644 --- a/frontends/atari/plot/font_internal.c +++ b/frontends/atari/plot/font_internal.c @@ -96,7 +96,7 @@ int ctor_font_plotter_internal( FONT_PLOTTER self ) self->str_split = str_split; self->pixel_pos = pixel_pos; self->text = text; - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { vdih = self->vdi_handle; fontbmp = atari_bitmap_create(48, 48, 0); diff --git a/frontends/atari/plot/font_vdi.c b/frontends/atari/plot/font_vdi.c index ef5499207..7cd82ddc9 100644 --- a/frontends/atari/plot/font_vdi.c +++ b/frontends/atari/plot/font_vdi.c @@ -70,7 +70,7 @@ int ctor_font_plotter_vdi( FONT_PLOTTER self ) self->str_split = str_split; self->pixel_pos = pixel_pos; self->text = text; - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { vdih = self->vdi_handle; } diff --git a/frontends/atari/plot/plot.c b/frontends/atari/plot/plot.c index 2324f82d9..14c670352 100644 --- a/frontends/atari/plot/plot.c +++ b/frontends/atari/plot/plot.c @@ -1628,7 +1628,7 @@ int plot_init(const struct redraw_context *ctx, char *fdrvrname) short work_out[57]; atari_plot_vdi_handle=graf_handle(&dummy, &dummy, &dummy, &dummy); v_opnvwk(work_in, &atari_plot_vdi_handle, work_out); - LOG("Plot VDI handle: %d", atari_plot_vdi_handle); + NSLOG(netsurf, INFO, "Plot VDI handle: %d", atari_plot_vdi_handle); } read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo); if(verbose_log) { @@ -1640,7 +1640,8 @@ int plot_init(const struct redraw_context *ctx, char *fdrvrname) atari_font_flags, &err); if (err) { const char * desc = plot_err_str(err); - LOG("Unable to load font plotter %s -> %s", fdrvrname, desc ); + NSLOG(netsurf, INFO, "Unable to load font plotter %s -> %s", + fdrvrname, desc); die("font plotter"); } diff --git a/frontends/atari/rootwin.c b/frontends/atari/rootwin.c index 0b77cbba5..6576eac77 100644 --- a/frontends/atari/rootwin.c +++ b/frontends/atari/rootwin.c @@ -105,7 +105,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[0]) { case WM_REDRAW: - LOG("WM_REDRAW"); + NSLOG(netsurf, INFO, "WM_REDRAW"); on_redraw(data->rootwin, msg); break; @@ -113,7 +113,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_SIZED: case WM_MOVED: case WM_FULLED: - LOG("WM_SIZED"); + NSLOG(netsurf, INFO, "WM_SIZED"); on_resized(data->rootwin); break; @@ -132,7 +132,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_TOPPED: case WM_NEWTOP: case WM_UNICONIFY: - LOG("WM_TOPPED"); + NSLOG(netsurf, INFO, "WM_TOPPED"); gui_set_input_gui_window(data->rootwin->active_gui_window); //window_restore_active_gui_window(data->rootwin); // TODO: use something like "restore_active_gui_window_state()" @@ -143,7 +143,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) // TODO: this needs to iterate through all gui windows and // check if the rootwin is this window... if (data->rootwin->active_gui_window != NULL) { - LOG("WM_CLOSED initiated destroy for bw %p", data->rootwin->active_gui_window->browser->bw); + NSLOG(netsurf, INFO, "WM_CLOSED initiated destroy for bw %p", + data->rootwin->active_gui_window->browser->bw); browser_window_destroy( data->rootwin->active_gui_window->browser->bw); } @@ -166,13 +167,16 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) // handle key uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta, (short)ev_out->emo_kreturn); - LOG("rootwin MU_KEYBD input, nkc: %x\n", nkc); + NSLOG(netsurf, INFO, "rootwin MU_KEYBD input, nkc: %x\n", nkc); retval = on_window_key_input(data->rootwin, nkc); // printf("on_window_key_input: %d\n", retval); } if ((ev_out->emo_events & MU_BUTTON) != 0) { - LOG("rootwin MU_BUTTON input, x: %d, y: %d\n", ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_x); + NSLOG(netsurf, INFO, + "rootwin MU_BUTTON input, x: %d, y: %d\n", + ev_out->emo_mouse.p_x, + ev_out->emo_mouse.p_x); window_get_grect(data->rootwin, BROWSER_AREA_CONTENT, &area); if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, @@ -312,13 +316,13 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw) struct gui_window *w; input_window = NULL; - LOG("window: %p, gui_window: %p", rootwin, gw); + NSLOG(netsurf, INFO, "window: %p, gui_window: %p", rootwin, gw); w = window_list; // find the next active tab: while( w != NULL ) { if(w->root == rootwin && w != gw) { - LOG("activating next tab %p", w); + NSLOG(netsurf, INFO, "activating next tab %p", w); gui_set_input_gui_window(w); break; } @@ -338,7 +342,7 @@ int window_destroy(ROOTWIN *rootwin) assert(rootwin != NULL); - LOG("%p", rootwin); + NSLOG(netsurf, INFO, "%p", rootwin); if (gemtk_wm_get_user_data(rootwin->win) != NULL) { free(gemtk_wm_get_user_data(rootwin->win)); @@ -404,7 +408,7 @@ void window_restore_active_gui_window(ROOTWIN *rootwin) GRECT tb_area; struct gui_window *gw; - LOG("rootwin %p", rootwin); + NSLOG(netsurf, INFO, "rootwin %p", rootwin); assert(rootwin->active_gui_window); @@ -499,7 +503,7 @@ void window_set_focus(struct s_gui_win_root *rootwin, assert(rootwin != NULL); if (rootwin->focus.type != type || rootwin->focus.element != element) { - LOG("Set focus: %p (%d)\n", element, type); + NSLOG(netsurf, INFO, "Set focus: %p (%d)\n", element, type); rootwin->focus.type = type; rootwin->focus.element = element; switch( type ) { @@ -563,11 +567,11 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw) { struct gui_window *old_gw = rootwin->active_gui_window; - LOG("gw %p",gw); + NSLOG(netsurf, INFO, "gw %p", gw); if (rootwin->active_gui_window != NULL) { if(rootwin->active_gui_window == gw) { - LOG("nothing to do..."); + NSLOG(netsurf, INFO, "nothing to do..."); return; } } @@ -576,7 +580,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw) rootwin->active_gui_window = gw; if (old_gw != NULL) { - LOG("restoring window..."); + NSLOG(netsurf, INFO, "restoring window..."); window_restore_active_gui_window(rootwin); } } @@ -651,7 +655,7 @@ void window_open_search(ROOTWIN *rootwin, bool reformat) GRECT area; OBJECT *obj; - LOG("rootwin %p", rootwin); + NSLOG(netsurf, INFO, "rootwin %p", rootwin); gw = rootwin->active_gui_window; bw = gw->browser->bw; @@ -1478,7 +1482,13 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8]) buff[size] = 0; - LOG("file: %s, ext: %s, size: %ld dropped at: %d,%d\n", (char *)buff, (char *)&ext, size, mx, my); + NSLOG(netsurf, INFO, + "file: %s, ext: %s, size: %ld dropped at: %d,%d\n", + (char *)buff, + (char *)&ext, + size, + mx, + my); gui_window_get_scroll(gw, &sx, &sy); @@ -1500,7 +1510,8 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8]) if (ret != NSERROR_OK) { free(buff); /* A bad encoding should never happen */ - LOG("utf8_from_local_encoding failed"); + NSLOG(netsurf, INFO, + "utf8_from_local_encoding failed"); assert(ret != NSERROR_BAD_ENCODING); /* no memory */ goto error; diff --git a/frontends/atari/schedule.c b/frontends/atari/schedule.c index 48980426d..9a7836b1f 100644 --- a/frontends/atari/schedule.c +++ b/frontends/atari/schedule.c @@ -23,15 +23,10 @@ #include "utils/sys_time.h" #include "utils/errors.h" +#include "utils/log.h" #include "atari/schedule.h" -#ifdef DEBUG_SCHEDULER -#include "utils/log.h" -#else -#define LOG(x...) -#endif - #define MS_NOW() ((clock() * 1000) / CLOCKS_PER_SEC) /* linked list of scheduled callbacks */ @@ -71,7 +66,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - LOG("removing %p, %p", callback, p); + NSLOG(schedule, DEBUG, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -80,7 +75,9 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) if ((cur_nscb->callback == callback) && (cur_nscb->p == p)) { /* item to remove */ - LOG("callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p); + NSLOG(schedule, DEBUG, + "callback entry %p removing %p(%p)", cur_nscb, + cur_nscb->callback, cur_nscb->p); /* remove callback */ unlnk_nscb = cur_nscb; @@ -118,7 +115,8 @@ nserror atari_schedule(int ival, void (*callback)(void *p), void *p) nscb->timeout = MS_NOW() + ival; - LOG("adding callback %p for %p(%p) at %d ms", nscb, callback, p, nscb->timeout); + NSLOG(schedule, DEBUG, "adding callback %p for %p(%p) at %d ms", nscb, + callback, p, nscb->timeout); nscb->callback = callback; nscb->p = p; @@ -164,7 +162,9 @@ int schedule_run(void) prev_nscb->next = unlnk_nscb->next; } - LOG("callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p); + NSLOG(schedule, DEBUG, + "callback entry %p running %p(%p)", unlnk_nscb, + unlnk_nscb->callback, unlnk_nscb->p); /* call callback */ unlnk_nscb->callback(unlnk_nscb->p); @@ -173,7 +173,7 @@ int schedule_run(void) /* need to deal with callback modifying the list. */ if (schedule_list == NULL) { - LOG("schedule_list == NULL"); + NSLOG(schedule, DEBUG, "schedule_list == NULL"); return -1; /* no more callbacks scheduled */ } @@ -198,7 +198,8 @@ int schedule_run(void) /* make rettime relative to now and convert to ms */ nexttime = nexttime - now; - LOG("returning time to next event as %ldms", nexttime); + NSLOG(schedule, DEBUG, "returning time to next event as %ldms", + nexttime); /*return next event time in milliseconds (24days max wait) */ return nexttime; @@ -210,14 +211,15 @@ void list_schedule(void) { struct nscallback *cur_nscb; - LOG("schedule list at ms clock %ld", MS_NOW()); + NSLOG(schedule, DEBUG, "schedule list at ms clock %ld", MS_NOW()); cur_nscb = schedule_list; while (cur_nscb != NULL) { - LOG("Schedule %p at %ld", cur_nscb, cur_nscb->timeout); + NSLOG(schedule, DEBUG, "Schedule %p at %ld", cur_nscb, + cur_nscb->timeout); cur_nscb = cur_nscb->next; } - LOG("Maxmium callbacks scheduled: %d", max_scheduled); + NSLOG(schedule, DEBUG, "Maxmium callbacks scheduled: %d", max_scheduled); } diff --git a/frontends/atari/search.c b/frontends/atari/search.c index 4da7f16a3..8df4ad676 100644 --- a/frontends/atari/search.c +++ b/frontends/atari/search.c @@ -67,7 +67,7 @@ struct gui_search_table *atari_search_table = &search_table; */ void nsatari_search_set_status(bool found, void *p) { - LOG("%p set status: %d\n", p, found); + NSLOG(netsurf, INFO, "%p set status: %d\n", p, found); // TODO: maybe update GUI } @@ -80,7 +80,7 @@ void nsatari_search_set_status(bool found, void *p) void nsatari_search_set_hourglass(bool active, void *p) { SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; - LOG("active: %d, session: %p", active, p); + NSLOG(netsurf, INFO, "active: %d, session: %p", active, p); if (active) { gui_window_set_pointer(s->g, GUI_POINTER_PROGRESS); } else { @@ -99,7 +99,7 @@ void nsatari_search_set_hourglass(bool active, void *p) */ void nsatari_search_add_recent(const char *string, void *p) { - LOG("%p add recent: %s\n", p, string); + NSLOG(netsurf, INFO, "%p add recent: %s\n", p, string); } @@ -115,7 +115,7 @@ void nsatari_search_set_forward_state(bool active, void *p) GRECT area; SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; /* deactivate back cb */ - LOG("%p: set forward state: %d\n", p, active); + NSLOG(netsurf, INFO, "%p: set forward state: %d\n", p, active); gw = s->g; @@ -142,7 +142,7 @@ void nsatari_search_set_back_state(bool active, void *p) GRECT area; SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; /* deactivate back cb */ - LOG("%p: set back state: %d\n", p, active); + NSLOG(netsurf, INFO, "%p: set back state: %d\n", p, active); s->state.back_avail = active; gw = s->g; @@ -224,7 +224,7 @@ void nsatari_search_restore_form( struct s_search_form_session *s, OBJECT *obj) void nsatari_search_session_destroy(struct s_search_form_session *s) { if (s != NULL) { - LOG("session %p", s); + NSLOG(netsurf, INFO, "session %p", s); browser_window_search_clear(s->g->browser->bw); free(s); } diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c index ed1fb2e45..7084bacf7 100644 --- a/frontends/atari/settings.c +++ b/frontends/atari/settings.c @@ -172,7 +172,7 @@ static char **read_locales(void) atari_warn_user("Failed to load locales: %s",buf); return(NULL); } else { - LOG("Reading locales from: %s...", buf); + NSLOG(netsurf, INFO, "Reading locales from: %s...", buf); } /* Count items: */ @@ -257,15 +257,15 @@ static void display_settings(void) /* "Cache" tab: */ tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / (1024*1024); - snprintf( spare, 255, "%d", tmp_option_memory_cache_size ); + snprintf( spare, 255, "%u", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 4 ); tmp_option_disc_cache_size = nsoption_int(disc_cache_size) / (1024*1024); - snprintf( spare, 255, "%d", tmp_option_disc_cache_size ); + snprintf( spare, 255, "%u", tmp_option_disc_cache_size ); set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 4 ); tmp_option_disc_cache_age = nsoption_int(disc_cache_age); - snprintf( spare, 255, "%02d", tmp_option_disc_cache_age ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_age ); set_text( SETTINGS_EDIT_CACHE_AGE, spare, 3 ); /* "Paths" tab: */ @@ -303,7 +303,7 @@ static void display_settings(void) // TODO: activate this option? tmp_option_min_reflow_period = nsoption_int(min_reflow_period); - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); + snprintf( spare, 255, "%04u", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); @@ -597,7 +597,7 @@ static void form_event(int index, int external) tmp_option_memory_cache_size = 1; if( tmp_option_memory_cache_size > 999 ) tmp_option_memory_cache_size = 999; - snprintf( spare, 255, "%02d", tmp_option_memory_cache_size ); + snprintf( spare, 255, "%02u", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_MEM_CACHE); @@ -614,7 +614,7 @@ static void form_event(int index, int external) tmp_option_disc_cache_size = 1; if( tmp_option_disc_cache_size > 9999 ) tmp_option_disc_cache_size = 9999; - snprintf( spare, 255, "%02d", tmp_option_disc_cache_size ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_size ); set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_DISC_CACHE); @@ -630,7 +630,7 @@ static void form_event(int index, int external) if( tmp_option_disc_cache_age > 99 ) tmp_option_disc_cache_age = 0; - snprintf( spare, 255, "%02d", tmp_option_disc_cache_age ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_age ); set_text( SETTINGS_EDIT_CACHE_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_CACHE_AGE); @@ -645,7 +645,7 @@ static void form_event(int index, int external) if( tmp_option_max_cached_fetch_handles > 31 ) tmp_option_max_cached_fetch_handles = 31; - snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); + snprintf( spare, 255, "%02u", tmp_option_max_cached_fetch_handles ); set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_CACHED_CONNECTIONS); @@ -660,7 +660,7 @@ static void form_event(int index, int external) if( tmp_option_max_fetchers > 31 ) tmp_option_max_fetchers = 31; - snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); + snprintf( spare, 255, "%02u", tmp_option_max_fetchers ); set_text( SETTINGS_EDIT_MAX_FETCHERS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS); @@ -675,7 +675,7 @@ static void form_event(int index, int external) if( tmp_option_max_fetchers_per_host > 31 ) tmp_option_max_fetchers_per_host = 31; - snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); + snprintf( spare, 255, "%02u", tmp_option_max_fetchers_per_host ); set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS_PER_HOST); @@ -691,7 +691,7 @@ static void form_event(int index, int external) if( tmp_option_expire_url > 99 ) tmp_option_expire_url = 0; - snprintf( spare, 255, "%02d", tmp_option_expire_url ); + snprintf( spare, 255, "%02u", tmp_option_expire_url ); set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_HISTORY_AGE); @@ -726,7 +726,7 @@ static void form_event(int index, int external) if( tmp_option_font_min_size < 10 ) tmp_option_font_min_size = 10; - snprintf( spare, 255, "%03d", tmp_option_font_min_size ); + snprintf( spare, 255, "%03u", tmp_option_font_min_size ); set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_FONT_SIZE); @@ -744,7 +744,7 @@ static void form_event(int index, int external) if( tmp_option_font_size < 50 ) tmp_option_font_size = 50; - snprintf( spare, 255, "%03d", tmp_option_font_size ); + snprintf( spare, 255, "%03u", tmp_option_font_size ); set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_DEF_FONT_SIZE); @@ -760,7 +760,7 @@ static void form_event(int index, int external) if( tmp_option_min_reflow_period > 9999 ) tmp_option_min_reflow_period = 10; - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); + snprintf( spare, 255, "%04u", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_REFLOW_PERIOD); @@ -980,12 +980,12 @@ void open_settings(void) void close_settings(void) { - LOG("closing"); + NSLOG(netsurf, INFO, "closing"); gemtk_wm_remove(settings_guiwin); settings_guiwin = NULL; wind_close(h_aes_win); wind_delete(h_aes_win); h_aes_win = 0; - LOG("Done"); + NSLOG(netsurf, INFO, "Done"); } diff --git a/frontends/atari/statusbar.c b/frontends/atari/statusbar.c index 3a216f9a8..fe2008c82 100644 --- a/frontends/atari/statusbar.c +++ b/frontends/atari/statusbar.c @@ -166,7 +166,7 @@ CMP_STATUSBAR sb_create( struct gui_window * gw ) void sb_destroy( CMP_STATUSBAR s ) { - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if( s ) { if( s->comp ){ mt_CompDelete( &app, s->comp ); @@ -206,7 +206,7 @@ CMP_STATUSBAR sb_create( struct gui_window * gw ) void sb_destroy( CMP_STATUSBAR s ) { - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if( s ) { free( s ); } diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c index 1b9371763..fdfedcbee 100644 --- a/frontends/atari/toolbar.c +++ b/frontends/atari/toolbar.c @@ -269,7 +269,7 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) int i; struct s_toolbar *t; - LOG("owner %p", owner); + NSLOG(netsurf, INFO, "owner %p", owner); assert(init == true); @@ -327,8 +327,9 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) t->throbber.max_index = THROBBER_MAX_INDEX; t->throbber.running = false; - LOG("created toolbar: %p, root: %p, textarea: %p, throbber: %p", - t, owner, t->url.textarea, &t->throbber); + NSLOG(netsurf, INFO, + "created toolbar: %p, root: %p, textarea: %p, throbber: %p", t, + owner, t->url.textarea, &t->throbber); return( t ); } @@ -458,7 +459,7 @@ toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw, short button) { - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); struct s_tb_button * bt; bool enable = false; @@ -582,7 +583,7 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area) void toolbar_set_url(struct s_toolbar *tb, const char *text) { - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); textarea_set_text(tb->url.textarea, text); @@ -668,7 +669,7 @@ bool toolbar_text_input(struct s_toolbar *tb, char *text) { bool handled = true; - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); return(handled); } @@ -757,7 +758,7 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button) short mx, my, mb, kstat; struct gui_window * gw; - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); if (obj==TOOLBAR_AREA_URL) { diff --git a/frontends/atari/treeview.c b/frontends/atari/treeview.c index a72d268cf..23db41309 100644 --- a/frontends/atari/treeview.c +++ b/frontends/atari/treeview.c @@ -16,21 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <sys/types.h> -#include <string.h> - #include "assert.h" -#include "cflib.h" -#include "netsurf/inttypes.h" -#include "utils/nsoption.h" #include "utils/log.h" #include "utils/messages.h" -#include "utils/utils.h" -#include "netsurf/plotters.h" -#include "netsurf/mouse.h" +#include "netsurf/inttypes.h" #include "netsurf/core_window.h" -#include "desktop/treeview.h" +#include "netsurf/plotters.h" #include "atari/gui.h" #include "atari/plot/plot.h" @@ -40,29 +32,6 @@ #include "atari/res/netsurf.rsh" -/** - * Declare Core Window Callbacks: - */ - -nserror atari_treeview_invalidate_area(struct core_window *cw, const struct rect *r); -void atari_treeview_update_size(struct core_window *cw, int width, int height); -void atari_treeview_scroll_visible(struct core_window *cw, - const struct rect *r); -void atari_treeview_get_window_dimensions(struct core_window *cw, - int *width, int *height); - // TODO: implement drag status! -void atari_treeview_drag_status(struct core_window *cw, - core_window_drag_status ds); - -static struct core_window_callback_table cw_t = { - .invalidate = atari_treeview_invalidate_area, - .update_size = atari_treeview_update_size, - .scroll_visible = atari_treeview_scroll_visible, - .get_window_dimensions = atari_treeview_get_window_dimensions, - .drag_status = atari_treeview_drag_status -}; - - struct atari_treeview_window { struct atari_treeview_window * prev_open; struct atari_treeview_window * next_open; @@ -80,23 +49,12 @@ struct atari_treeview_window { static struct atari_treeview_window * treeviews_open; -/* native GUI event handlers: */ -static void on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]); -static void on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]); -static void on_redraw_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]); - -/* static utils: */ -//static void atari_treeview_dump_info(struct atari_treeview_window *tv, char *s); - /** * Schedule a redraw of the treeview content * */ -static void atari_treeview_redraw_grect_request(struct core_window *cw, - GRECT *area) +static void +atari_treeview_redraw_grect_request(struct core_window *cw, GRECT *area) { struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; if (cw != NULL) { @@ -114,264 +72,77 @@ static void atari_treeview_redraw_grect_request(struct core_window *cw, int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h; tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, area->g_x); tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, area->g_y); - tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x; - tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y; - } - //dbg_grect("atari_treeview_request_redraw_grect", &tv->rdw_area); - } -} - - -void atari_treeview_get_grect(struct core_window *cw, enum treeview_area_e mode, - GRECT *dest) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + if ( oldx1 > newx1 ) { + tv->rdw_area.g_w = oldx1 - tv->rdw_area.g_x; + } else { + tv->rdw_area.g_w = newx1 - tv->rdw_area.g_x; + } - if (mode == TREEVIEW_AREA_CONTENT) { - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, dest); - } - else if (mode == TREEVIEW_AREA_TOOLBAR) { - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, dest); + if ( oldy1 > newy1 ) { + tv->rdw_area.g_h = oldy1 - tv->rdw_area.g_y; + } else { + tv->rdw_area.g_h = newy1 - tv->rdw_area.g_y; + } + } + //dbg_grect("atari_treeview_request_redraw_grect", &tv->rdw_area); } } -GUIWIN * atari_treeview_get_gemtk_window(struct core_window *cw) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - return(tv->window); -} -/* -static void atari_treeview_dump_info(struct atari_treeview_window *tv, - char * title) +#ifdef ATARI_TREEVIEW_DUMP +static void +atari_treeview_dump_info(struct atari_treeview_window *tv, char * title) { printf("Treeview Dump (%s)\n", title); printf("=================================\n"); gemtk_wm_dump_window_info(atari_treeview_get_gemtk_window((struct core_window *)tv)); GEMTK_DBG_GRECT("Redraw Area: \n", &tv->rdw_area) - dbg_grect("Redraw Area2: \n", &tv->rdw_area); + dbg_grect("Redraw Area2: \n", &tv->rdw_area); printf("Extent: x: %d, y: %d\n", tv->extent.x, tv->extent.y); } -*/ +#endif -static bool atari_treeview_is_iconified(struct core_window *cw){ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; +static bool atari_treeview_is_iconified(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - return((gemtk_wm_get_state(tv->window)&GEMTK_WM_STATUS_ICONIFIED) != 0); + return((gemtk_wm_get_state(tv->window)&GEMTK_WM_STATUS_ICONIFIED) != 0); } -static void atari_treeview_redraw_icon(struct core_window *cw, GRECT *clip) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - GRECT visible, work; - OBJECT * tree = gemtk_obj_get_tree(ICONIFY); - short aesh = gemtk_wm_get_handle(tv->window); - - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_WORK, &work); - - tree->ob_x = work.g_x; - tree->ob_y = work.g_y; - tree->ob_width = work.g_w; - tree->ob_height = work.g_h; - - wind_get_grect(aesh, WF_FIRSTXYWH, &visible); - while (visible.g_h > 0 && visible.g_w > 0) { - - if (rc_intersect(&work, &visible)) { - objc_draw(tree, 0, 8, visible.g_x, visible.g_y, visible.g_w, - visible.g_h); - } else { - //dbg_grect("redraw vis area outside", &visible); - } - - wind_get_grect(aesh, WF_NEXTXYWH, &visible); - } -} -void atari_treeview_redraw(struct core_window *cw) +static void atari_treeview_redraw_icon(struct core_window *cw, GRECT *clip) { struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - short pxy[4]; + GRECT visible, work; + OBJECT * tree = gemtk_obj_get_tree(ICONIFY); + short aesh = gemtk_wm_get_handle(tv->window); - if (tv != NULL && tv->is_open) { - if( tv->redraw && ((plot_get_flags() & PLOT_FLAG_OFFSCREEN) == 0) ) { + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_WORK, &work); - short todo[4]; - GRECT work; - short handle = gemtk_wm_get_handle(tv->window); - struct gemtk_wm_scroll_info_s *slid; + tree->ob_x = work.g_x; + tree->ob_y = work.g_y; + tree->ob_width = work.g_w; + tree->ob_height = work.g_h; - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work); - slid = gemtk_wm_get_scroll_info(tv->window); - -// // Debug code: this 3 lines help to inspect the redraw -// // areas... -// pxy[0] = work.g_x; -// pxy[1] = work.g_y; -// pxy[2] = pxy[0] + work.g_w-1; -// pxy[3] = pxy[1] + work.g_h-1; -// -// vsf_color(plot_get_vdi_handle(), 0); -// v_bar(plot_get_vdi_handle(), (short*)&pxy); -// evnt_timer(500); + wind_get_grect(aesh, WF_FIRSTXYWH, &visible); + while (visible.g_h > 0 && visible.g_w > 0) { - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &atari_plotters - }; - plot_set_dimensions(&ctx, - work.g_x, - work.g_y, - work.g_w, - work.g_h); - if (plot_lock() == false) - return; - - if( wind_get(handle, WF_FIRSTXYWH, - &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) { - while (todo[2] && todo[3]) { - - if(!rc_intersect(&work, (GRECT*)&todo)){ - if (wind_get(handle, WF_NEXTXYWH, - &todo[0], &todo[1], &todo[2], &todo[3])==0) { - break; - } - continue; - } - pxy[0] = todo[0]; - pxy[1] = todo[1]; - pxy[2] = todo[0] + todo[2]-1; - pxy[3] = todo[1] + todo[3]-1; - vs_clip(plot_get_vdi_handle(), 1, (short*)&pxy); - - // Debug code: this 3 lines help to inspect the redraw - // areas... - -// vsf_color(plot_get_vdi_handle(), 3); -// v_bar(plot_get_vdi_handle(), (short*)&pxy); -// evnt_timer(500); - - - /* convert screen to treeview coords: */ - todo[0] = todo[0] - work.g_x ;//+ slid->x_pos*slid->x_unit_px; - todo[1] = todo[1] - work.g_y ;//+ slid->y_pos*slid->y_unit_px; - if( todo[0] < 0 ){ - todo[2] = todo[2] + todo[0]; - todo[0] = 0; - } - if( todo[1] < 0 ){ - todo[3] = todo[3] + todo[1]; - todo[1] = 0; - } - - if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) { - struct rect clip; - - clip.x0 = todo[0]+(slid->x_pos*slid->x_unit_px); - clip.y0 = todo[1]+(slid->y_pos*slid->y_unit_px); - clip.x1 = clip.x0 + todo[2]+(slid->x_pos*slid->x_unit_px); - clip.y1 = clip.y0 + todo[3]+(slid->y_pos*slid->y_unit_px); - - tv->io->draw(cw, -(slid->x_pos*slid->x_unit_px), - -(slid->y_pos*slid->y_unit_px), - &clip, &ctx); - } - vs_clip(plot_get_vdi_handle(), 0, (short*)&pxy); - if (wind_get(handle, WF_NEXTXYWH, - &todo[0], &todo[1], &todo[2], &todo[3])==0) { - break; - } - } - } else { - plot_unlock(); - return; - } - plot_unlock(); - tv->redraw = false; - tv->rdw_area.g_x = 65000; - tv->rdw_area.g_y = 65000; - tv->rdw_area.g_w = -1; - tv->rdw_area.g_h = -1; + if (rc_intersect(&work, &visible)) { + objc_draw(tree, 0, 8, visible.g_x, visible.g_y, visible.g_w, + visible.g_h); } else { - /* just copy stuff from the offscreen buffer */ + //dbg_grect("redraw vis area outside", &visible); } - } -} - -/** - * GEMTK (netsurf's GEM toolkit) event sink - * -*/ -static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) -{ - short retval = 0; - struct atari_treeview_window *tv = (struct atari_treeview_window *) - gemtk_wm_get_user_data(win); - struct core_window *cw = (struct core_window *)tv; - - if( (ev_out->emo_events & MU_MESAG) != 0 ) { - // handle message - switch (msg[0]) { - - case WM_REDRAW: - on_redraw_event(cw, ev_out, msg); - break; - - default: - break; - } - } - if( (ev_out->emo_events & MU_KEYBD) != 0 ) { - on_keybd_event(cw, ev_out, msg); - } - if( (ev_out->emo_events & MU_BUTTON) != 0 ) { - LOG("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); - on_mbutton_event(cw, ev_out, msg); - } - - if(tv != NULL && tv->io->gemtk_user_func != NULL){ - tv->io->gemtk_user_func(win, ev_out, msg); - } - - // TODO: evaluate return values of event handler functions and pass them on: - return(retval); -} - - -static void __CDECL on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]) -{ - long kstate = 0; - long kcode = 0; - long ucs4; - long ik; - unsigned short nkc = 0; - unsigned char ascii; - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - - kstate = ev_out->emo_kmeta; - kcode = ev_out->emo_kreturn; - nkc= gem_to_norm( (short)kstate, (short)kcode ); - ascii = (nkc & 0xFF); - ik = nkc_to_input_key(nkc, &ucs4); - - if (ik == 0) { - if (ascii >= 9) { - tv->io->keypress(cw, ucs4); - } - } else { - tv->io->keypress(cw, ik); + wind_get_grect(aesh, WF_NEXTXYWH, &visible); } } -static void __CDECL on_redraw_event(struct core_window *cw, - EVMULT_OUT *ev_out, - short msg[8]) +static void __CDECL +on_redraw_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8]) { GRECT work, clip; struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; @@ -428,9 +199,9 @@ static void __CDECL on_redraw_event(struct core_window *cw, } } -static void __CDECL on_mbutton_event(struct core_window *cw, - EVMULT_OUT *ev_out, - short msg[8]) + +static void __CDECL +on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8]) { struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; struct gemtk_wm_scroll_info_s *slid; @@ -447,26 +218,26 @@ static void __CDECL on_mbutton_event(struct core_window *cw, /* mouse click relative origin: */ - short origin_rel_x = (mx-work.g_x) + - (slid->x_pos*slid->x_unit_px); - short origin_rel_y = (my-work.g_y) + - (slid->y_pos*slid->y_unit_px); + short origin_rel_x = (mx-work.g_x) + (slid->x_pos*slid->x_unit_px); + short origin_rel_y = (my-work.g_y) + (slid->y_pos*slid->y_unit_px); /* Only pass on events in the content area: */ - if( origin_rel_x >= 0 && origin_rel_y >= 0 - && mx < work.g_x + work.g_w - && my < work.g_y + work.g_h ) - { + if ((origin_rel_x >= 0) && + (origin_rel_y >= 0) && + (mx < work.g_x + work.g_w) && + (my < work.g_y + work.g_h)) { if (ev_out->emo_mclicks == 2) { tv->io->mouse_action(cw, - BROWSER_MOUSE_CLICK_1|BROWSER_MOUSE_DOUBLE_CLICK, - origin_rel_x, origin_rel_y); + BROWSER_MOUSE_CLICK_1 | + BROWSER_MOUSE_DOUBLE_CLICK, + origin_rel_x, + origin_rel_y); return; } graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy); /* check for click or hold: */ - if( (mbut&1) == 0 ){ + if ((mbut & 1) == 0 ) { int bms; bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1; if(ev_out->emo_mclicks == 2 ) { @@ -486,172 +257,124 @@ static void __CDECL on_mbutton_event(struct core_window *cw, tv->startdrag.x = origin_rel_x; tv->startdrag.y = origin_rel_y; /* First, report mouse press, to trigger entry selection */ - tv->io->mouse_action(cw, BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1, cur_rel_x, - cur_rel_y); + tv->io->mouse_action(cw, + BROWSER_MOUSE_CLICK_1 | + BROWSER_MOUSE_PRESS_1, + cur_rel_x, + cur_rel_y); atari_treeview_redraw(cw); - tv->io->mouse_action(cw, BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON, - cur_rel_x, cur_rel_y); - do{ - if (abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5) { + tv->io->mouse_action(cw, + BROWSER_MOUSE_DRAG_1 | + BROWSER_MOUSE_DRAG_ON, + cur_rel_x, + cur_rel_y); + do { + if (abs(prev_x-cur_rel_x) > 5 || + abs(prev_y-cur_rel_y) > 5) { tv->io->mouse_action(cw, - BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON, - cur_rel_x, cur_rel_y); + BROWSER_MOUSE_HOLDING_1 | + BROWSER_MOUSE_DRAG_ON, + cur_rel_x, + cur_rel_y); prev_x = cur_rel_x; prev_y = cur_rel_y; } if (tv->redraw) { // TODO: maybe GUI poll would fit better here? - // ... is gui_poll re-entrance save? + // ... is gui_poll re-entrance save? atari_treeview_redraw(cw); } /* sample mouse button state: */ - graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy); - cur_rel_x = (cur_rel_x-work.g_x)+(slid->x_pos*slid->x_unit_px); - cur_rel_y = (cur_rel_y-work.g_y)+(slid->y_pos*slid->y_unit_px); - } while( mbut & 1 ); + graf_mkstate(&cur_rel_x, + &cur_rel_y, + &mbut, + &dummy); + cur_rel_x = (cur_rel_x-work.g_x) + + (slid->x_pos*slid->x_unit_px); + cur_rel_y = (cur_rel_y-work.g_y) + + (slid->y_pos*slid->y_unit_px); + } while (mbut & 1); /* End drag: */ - tv->io->mouse_action(cw, BROWSER_MOUSE_HOVER, cur_rel_x, cur_rel_y); + tv->io->mouse_action(cw, + BROWSER_MOUSE_HOVER, + cur_rel_x, + cur_rel_y); gem_set_cursor(&gem_cursors.arrow); } } } -struct core_window * -atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, - void * user_data, uint32_t flags) +static void __CDECL +on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8]) { + long kstate = 0; + long kcode = 0; + long ucs4; + long ik; + unsigned short nkc = 0; + unsigned char ascii; + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - /* allocate the core_window struct: */ - struct atari_treeview_window * tv; - struct gemtk_wm_scroll_info_s *slid; - - tv = calloc(1, sizeof(struct atari_treeview_window)); - if (tv == NULL) { - LOG("calloc failed"); - atari_warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); - return NULL; - } - - /* Store the window ref inside the new treeview: */ - tv->window = win; - tv->io = callbacks; - tv->user_data = user_data; - - // Setup gemtk event handler function: - gemtk_wm_set_event_handler(win, handle_event); - - // bind window user data to treeview ref: - gemtk_wm_set_user_data(win, (void*)tv); - - // Get acces to the gemtk scroll info struct: - slid = gemtk_wm_get_scroll_info(tv->window); - - // Setup line and column height/width of the window, - // each scroll takes the configured steps: - slid->y_unit_px = 16; - slid->x_unit_px = 16; - - assert(tv->io); - assert(tv->io->init_phase2); + kstate = ev_out->emo_kmeta; + kcode = ev_out->emo_kreturn; + nkc= gem_to_norm( (short)kstate, (short)kcode ); + ascii = (nkc & 0xFF); + ik = nkc_to_input_key(nkc, &ucs4); - /* Now that the window is configured for treeview content, */ - /* call init_phase2 which must create the treeview */ - /* descriptor, and at least setup the the default */ - /* event handlers of the treeview: */ - /* It would be more simple to not pass around the callbacks */ - /* but the treeview constructor requires them for initialization... */ - nserror err = tv->io->init_phase2((struct core_window *)tv, &cw_t); - if (err != NSERROR_OK) { - free(tv); - tv = NULL; + if (ik == 0) { + if (ascii >= 9) { + tv->io->keypress(cw, ucs4); + } + } else { + tv->io->keypress(cw, ik); } - - return((struct core_window *)tv); } -void atari_treeview_delete(struct core_window * cw) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; - - assert(tv); - assert(tv->io->finish); - tv->io->finish(cw); +/** + * GEMTK (netsurf's GEM toolkit) event sink + * + */ +static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) +{ + short retval = 0; + struct atari_treeview_window *tv = (struct atari_treeview_window *) + gemtk_wm_get_user_data(win); + struct core_window *cw = (struct core_window *)tv; - free(tv); -} + if( (ev_out->emo_events & MU_MESAG) != 0 ) { + // handle message + switch (msg[0]) { + case WM_REDRAW: + on_redraw_event(cw, ev_out, msg); + break; -void atari_treeview_open(struct core_window *cw, GRECT *pos) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; - if (tv->window != NULL && tv->is_open == false) { - tv->is_open = true; - wind_open_grect(gemtk_wm_get_handle(tv->window), pos); - gemtk_wm_link(tv->window); - if (treeviews_open == NULL) { - treeviews_open = tv; - treeviews_open->next_open = NULL; - treeviews_open->prev_open = NULL; - } else { - struct atari_treeview_window * tmp; - tmp = treeviews_open; - while(tmp->next_open != NULL){ - tmp = tmp->next_open; - } - tmp->next_open = tv; - tv->prev_open = tmp; - tv->next_open = NULL; + default: + break; } } -} - -bool atari_treeview_is_open(struct core_window *cw) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; - return(tv->is_open); -} - -void atari_treeview_set_user_data(struct core_window * cw, - void *user_data_ptr) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; - tv->user_data = user_data_ptr; -} - -void * atari_treeview_get_user_data(struct core_window * cw) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; - return(tv->user_data); -} + if ((ev_out->emo_events & MU_KEYBD) != 0 ) { + on_keybd_event(cw, ev_out, msg); + } + if ((ev_out->emo_events & MU_BUTTON) != 0 ) { + NSLOG(netsurf, INFO, "Treeview click at: %d,%d\n", + ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); + on_mbutton_event(cw, ev_out, msg); + } -void atari_treeview_close(struct core_window *cw) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; - if (tv->window != NULL) { - tv->is_open = false; - wind_close(gemtk_wm_get_handle(tv->window)); - gemtk_wm_unlink(tv->window); - /* unlink the window: */ - if (tv->prev_open != NULL) { - tv->prev_open->next_open = tv->next_open; - } else { - treeviews_open = tv->next_open; - } - if (tv->next_open != NULL) { - tv->next_open->prev_open = tv->prev_open; - } + if (tv != NULL && tv->io->gemtk_user_func != NULL){ + tv->io->gemtk_user_func(win, ev_out, msg); } -} + // TODO: evaluate return values of event handler functions and pass them on: + return(retval); +} -/** - * Core Window Callbacks: - */ /** * callback from core to request an invalidation of a window area. @@ -664,7 +387,9 @@ void atari_treeview_close(struct core_window *cw) * \param[in] r area to redraw or NULL for the entire window area. * \return NSERROR_OK on success or appropriate error code. */ -nserror atari_treeview_invalidate_area(struct core_window *cw, const struct rect *r) +static nserror +atari_treeview_invalidate_area(struct core_window *cw, + const struct rect *r) { GRECT area; struct gemtk_wm_scroll_info_s * slid; @@ -693,6 +418,7 @@ nserror atari_treeview_invalidate_area(struct core_window *cw, const struct rect return NSERROR_OK; } + /** * Update the limits of the window * @@ -700,7 +426,8 @@ nserror atari_treeview_invalidate_area(struct core_window *cw, const struct rect * \param width the width in px, or negative if don't care * \param height the height in px, or negative if don't care */ -void atari_treeview_update_size(struct core_window *cw, int width, int height) +static void +atari_treeview_update_size(struct core_window *cw, int width, int height) { GRECT area; struct gemtk_wm_scroll_info_s *slid; @@ -732,8 +459,10 @@ void atari_treeview_update_size(struct core_window *cw, int width, int height) tv->extent.y = height; - /*printf("units content: %d, units viewport: %d\n", (height/slid->y_unit_px), - (area.g_h/slid->y_unit_px));*/ + /* printf("units content: %d, units viewport: %d\n", + (height/slid->y_unit_px), + (area.g_h/slid->y_unit_px)); + */ gemtk_wm_update_slider(tv->window, GEMTK_WM_VH_SLIDER); } } @@ -745,10 +474,11 @@ void atari_treeview_update_size(struct core_window *cw, int width, int height) * \param cw the core window object * \param r rectangle to make visible */ -void atari_treeview_scroll_visible(struct core_window *cw, const struct rect *r) +static void +atari_treeview_scroll_visible(struct core_window *cw, const struct rect *r) { /* atari frontend doesn't support dragging outside the treeview */ - /* so there is no need to implement this? */ + /* so there is no need to implement this? */ } @@ -759,10 +489,13 @@ void atari_treeview_scroll_visible(struct core_window *cw, const struct rect *r) * \param width to be set to viewport width in px, if non NULL * \param height to be set to viewport height in px, if non NULL */ -void atari_treeview_get_window_dimensions(struct core_window *cw, - int *width, int *height) +static void +atari_treeview_get_window_dimensions(struct core_window *cw, + int *width, + int *height) { - if (cw != NULL && (width != NULL || height != NULL)) { + if ((cw != NULL) && + (width != NULL || height != NULL)) { GRECT work; atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &work); *width = work.g_w; @@ -777,33 +510,322 @@ void atari_treeview_get_window_dimensions(struct core_window *cw, * \param cw the core window object * \param ds the current drag status */ -void atari_treeview_drag_status(struct core_window *cw, - core_window_drag_status ds) +static void +atari_treeview_drag_status(struct core_window *cw, core_window_drag_status ds) { } + +/** + * Declare Core Window Callbacks: + */ +static struct core_window_callback_table cw_t = { + .invalidate = atari_treeview_invalidate_area, + .update_size = atari_treeview_update_size, + .scroll_visible = atari_treeview_scroll_visible, + .get_window_dimensions = atari_treeview_get_window_dimensions, + .drag_status = atari_treeview_drag_status +}; + + +/* exported interface documented in atari/treeview.h */ +struct core_window * +atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, + void * user_data, uint32_t flags) +{ + + /* allocate the core_window struct: */ + struct atari_treeview_window * tv; + struct gemtk_wm_scroll_info_s *slid; + + tv = calloc(1, sizeof(struct atari_treeview_window)); + if (tv == NULL) { + NSLOG(netsurf, INFO, "calloc failed"); + atari_warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); + return NULL; + } + + /* Store the window ref inside the new treeview: */ + tv->window = win; + tv->io = callbacks; + tv->user_data = user_data; + + // Setup gemtk event handler function: + gemtk_wm_set_event_handler(win, handle_event); + + // bind window user data to treeview ref: + gemtk_wm_set_user_data(win, (void*)tv); + + // Get acces to the gemtk scroll info struct: + slid = gemtk_wm_get_scroll_info(tv->window); + + // Setup line and column height/width of the window, + // each scroll takes the configured steps: + slid->y_unit_px = 16; + slid->x_unit_px = 16; + + assert(tv->io); + assert(tv->io->init_phase2); + + /* Now that the window is configured for treeview content, */ + /* call init_phase2 which must create the treeview */ + /* descriptor, and at least setup the the default */ + /* event handlers of the treeview: */ + /* It would be more simple to not pass around the callbacks */ + /* but the treeview constructor requires them for initialization... */ + nserror err = tv->io->init_phase2((struct core_window *)tv, &cw_t); + if (err != NSERROR_OK) { + free(tv); + tv = NULL; + } + + return((struct core_window *)tv); +} + + +/* exported interface documented in atari/treeview.h */ +void +atari_treeview_get_grect(struct core_window *cw, + enum treeview_area_e mode, + GRECT *dest) +{ + + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + + if (mode == TREEVIEW_AREA_CONTENT) { + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, dest); + } + else if (mode == TREEVIEW_AREA_TOOLBAR) { + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, dest); + } +} + + +/* exported interface documented in atari/treeview.h */ +GUIWIN * atari_treeview_get_gemtk_window(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + return(tv->window); +} + + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_redraw(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + short pxy[4]; + + if (tv != NULL && tv->is_open) { + if( tv->redraw && ((plot_get_flags() & PLOT_FLAG_OFFSCREEN) == 0) ) { + + short todo[4]; + GRECT work; + short handle = gemtk_wm_get_handle(tv->window); + struct gemtk_wm_scroll_info_s *slid; + + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work); + slid = gemtk_wm_get_scroll_info(tv->window); + +// // Debug code: this 3 lines help to inspect the redraw +// // areas... +// pxy[0] = work.g_x; +// pxy[1] = work.g_y; +// pxy[2] = pxy[0] + work.g_w-1; +// pxy[3] = pxy[1] + work.g_h-1; +// +// vsf_color(plot_get_vdi_handle(), 0); +// v_bar(plot_get_vdi_handle(), (short*)&pxy); +// evnt_timer(500); + + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &atari_plotters + }; + plot_set_dimensions(&ctx, + work.g_x, + work.g_y, + work.g_w, + work.g_h); + if (plot_lock() == false) + return; + + if( wind_get(handle, WF_FIRSTXYWH, + &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) { + while (todo[2] && todo[3]) { + + if(!rc_intersect(&work, (GRECT*)&todo)){ + if (wind_get(handle, WF_NEXTXYWH, + &todo[0], &todo[1], &todo[2], &todo[3])==0) { + break; + } + continue; + } + pxy[0] = todo[0]; + pxy[1] = todo[1]; + pxy[2] = todo[0] + todo[2]-1; + pxy[3] = todo[1] + todo[3]-1; + vs_clip(plot_get_vdi_handle(), 1, (short*)&pxy); + + // Debug code: this 3 lines help to inspect the redraw + // areas... + +// vsf_color(plot_get_vdi_handle(), 3); +// v_bar(plot_get_vdi_handle(), (short*)&pxy); +// evnt_timer(500); + + + /* convert screen to treeview coords: */ + todo[0] = todo[0] - work.g_x ;//+ slid->x_pos*slid->x_unit_px; + todo[1] = todo[1] - work.g_y ;//+ slid->y_pos*slid->y_unit_px; + if( todo[0] < 0 ){ + todo[2] = todo[2] + todo[0]; + todo[0] = 0; + } + if( todo[1] < 0 ){ + todo[3] = todo[3] + todo[1]; + todo[1] = 0; + } + + if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) { + struct rect clip; + + clip.x0 = todo[0]+(slid->x_pos*slid->x_unit_px); + clip.y0 = todo[1]+(slid->y_pos*slid->y_unit_px); + clip.x1 = clip.x0 + todo[2]+(slid->x_pos*slid->x_unit_px); + clip.y1 = clip.y0 + todo[3]+(slid->y_pos*slid->y_unit_px); + + tv->io->draw(cw, -(slid->x_pos*slid->x_unit_px), + -(slid->y_pos*slid->y_unit_px), + &clip, &ctx); + } + vs_clip(plot_get_vdi_handle(), 0, (short*)&pxy); + if (wind_get(handle, WF_NEXTXYWH, + &todo[0], &todo[1], &todo[2], &todo[3])==0) { + break; + } + } + } else { + plot_unlock(); + return; + } + plot_unlock(); + tv->redraw = false; + tv->rdw_area.g_x = 65000; + tv->rdw_area.g_y = 65000; + tv->rdw_area.g_w = -1; + tv->rdw_area.g_h = -1; + } else { + /* just copy stuff from the offscreen buffer */ + } + } +} + + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_delete(struct core_window * cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; + + assert(tv); + assert(tv->io->finish); + + tv->io->finish(cw); + + free(tv); +} + + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_open(struct core_window *cw, GRECT *pos) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; + if (tv->window != NULL && tv->is_open == false) { + tv->is_open = true; + wind_open_grect(gemtk_wm_get_handle(tv->window), pos); + gemtk_wm_link(tv->window); + if (treeviews_open == NULL) { + treeviews_open = tv; + treeviews_open->next_open = NULL; + treeviews_open->prev_open = NULL; + } else { + struct atari_treeview_window * tmp; + tmp = treeviews_open; + while(tmp->next_open != NULL){ + tmp = tmp->next_open; + } + tmp->next_open = tv; + tv->prev_open = tmp; + tv->next_open = NULL; + } + } +} + + +/* exported interface documented in atari/treeview.h */ +bool atari_treeview_is_open(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; + return(tv->is_open); +} + + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_set_user_data(struct core_window *cw, void *user_data_ptr) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; + tv->user_data = user_data_ptr; +} + + +/* exported interface documented in atari/treeview.h */ +void * atari_treeview_get_user_data(struct core_window * cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; + return(tv->user_data); +} + + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_close(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; + if (tv->window != NULL) { + tv->is_open = false; + wind_close(gemtk_wm_get_handle(tv->window)); + gemtk_wm_unlink(tv->window); + /* unlink the window: */ + if (tv->prev_open != NULL) { + tv->prev_open->next_open = tv->next_open; + } else { + treeviews_open = tv->next_open; + } + if (tv->next_open != NULL) { + tv->next_open->prev_open = tv->prev_open; + } + } +} + + +/* exported interface documented in atari/treeview.h */ void atari_treeview_flush_redraws(void) { struct atari_treeview_window *tmp; tmp = treeviews_open; - if(tmp){ - while(tmp){ - assert(tmp->is_open); - if(tmp->redraw){ - if (atari_treeview_is_iconified((struct core_window *)tmp)) { - /* No content redraw for iconified windows */ - /* because otherwise the icon draw function would */ - /* have to deal with plot canvas coords */ - continue; - } - - atari_treeview_redraw((struct core_window *)tmp); - } - tmp = tmp->next_open; + while (tmp != NULL) { + assert(tmp->is_open); + if (tmp->redraw && + (!atari_treeview_is_iconified((struct core_window *)tmp))) { + /* Content redraw only for iconified windows + * because otherwise the icon draw function + * would have to deal with plot canvas coords + */ + atari_treeview_redraw((struct core_window *)tmp); } + tmp = tmp->next_open; } -} +} diff --git a/frontends/atari/treeview.h b/frontends/atari/treeview.h index d10129eaa..fe267b122 100644 --- a/frontends/atari/treeview.h +++ b/frontends/atari/treeview.h @@ -68,7 +68,7 @@ struct atari_treeview_callbacks { /** * Initalize an window to be an treeview window. * -*/ + */ struct core_window *atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, void * user_data, uint32_t flags); /** diff --git a/frontends/atari/verify_ssl.c b/frontends/atari/verify_ssl.c index 33136eebd..b099fe488 100644 --- a/frontends/atari/verify_ssl.c +++ b/frontends/atari/verify_ssl.c @@ -80,7 +80,9 @@ static void __CDECL cert_info_draw( WINDOW * win, short buf[8], void * data) if( line == NULL ) return; - LOG("Cert info draw, win: %p, data: %p, scrollx: %d", win, data, dp->scrollx ); + NSLOG(netsurf, INFO, + "Cert info draw, win: %p, data: %p, scrollx: %d", win, data, + dp->scrollx); WindGet( win, WF_WORKXYWH, &x, &y, &w, &h ); /*using static values here, as RsrcUserDraw has mem leaks & a very small stack */ @@ -158,7 +160,7 @@ static void do_popup( WINDOW *win, int index, int mode, void *data) char * items[dp->num_certs]; short x, y; unsigned int i; - LOG("do_popup: num certs: %d", dp->num_certs); + NSLOG(netsurf, INFO, "do_popup: num certs: %d", dp->num_certs); for( i = 0; i<dp->num_certs; i++) { items[i] = malloc( 48 ); strncpy(items[i], (char*)&dp->cert_infos_n[i].issuer, 46 ); @@ -246,7 +248,7 @@ verify_ssl_form_do(const char * url, break; case VERIFY_BT_SCROLL_R: - LOG("scroll r!"); + NSLOG(netsurf, INFO, "scroll r!"); cont = true; dp.scrollx += 1; if( dp.scrollx > (dp.cols - (272 / 8 )) ) |