From dfcfe1258098caf9f6b0f18ae0707dbfb95da7e3 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Wed, 21 Dec 2011 21:13:13 +0000 Subject: Add event listeners to WM_MOVED, WM_RESIZED, WM_FULLED instead of overwriting the default handlers. Removed option atari_realtime_move. svn path=/trunk/netsurf/; revision=13311 --- atari/browser_win.c | 310 ++++++++++++++++++++++------------------------------ atari/gui.h | 2 - atari/options.h | 3 - 3 files changed, 133 insertions(+), 182 deletions(-) (limited to 'atari') diff --git a/atari/browser_win.c b/atari/browser_win.c index 3b201a77f..8004ae21a 100755 --- a/atari/browser_win.c +++ b/atari/browser_win.c @@ -55,17 +55,17 @@ #include "atari/plot/plotter.h" #include "atari/dragdrop.h" #include "atari/search.h" -#include "atari/osspec.h" -#include "atari/encoding.h" -#include "atari/toolbar.h" - +#include "atari/osspec.h" +#include "atari/encoding.h" +#include "atari/toolbar.h" + extern void * h_gem_rsrc; extern struct gui_window *input_window; extern GEM_PLOTTER plotter; void __CDECL std_szd( WINDOW * win, short buff[8], void * ); -void __CDECL std_mvd( WINDOW * win, short buff[8], void * ); - +void __CDECL std_mvd( WINDOW * win, short buff[8], void * ); + /* -------------------------------------------------------------------------- */ /* Static module methods follow here: */ @@ -78,9 +78,9 @@ static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * da static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data ); static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ; static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data ); -static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data); -static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data ); -static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data ); +static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data); +static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data ); +static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data ); static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data ); /* -------------------------------------------------------------------------- */ @@ -88,23 +88,23 @@ static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data /* -------------------------------------------------------------------------- */ -int window_create( struct gui_window * gw, - struct browser_window * bw, +int window_create( struct gui_window * gw, + struct browser_window * bw, unsigned long inflags ) { int err = 0; - bool tb, sb; - int flags; + bool tb, sb; + int flags; tb = (inflags & WIDGET_TOOLBAR ); - sb = (inflags & WIDGET_STATUSBAR ); + sb = (inflags & WIDGET_STATUSBAR ); flags = CLOSER | MOVER | NAME | FULLER | SMALLER; - if( inflags & WIDGET_SCROLL ){ - flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE); - } - if( inflags & WIDGET_RESIZE ){ - flags |= ( SIZER ); + if( inflags & WIDGET_SCROLL ){ + flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE); + } + if( inflags & WIDGET_RESIZE ){ + flags |= ( SIZER ); } gw->root = malloc( sizeof(struct s_gui_win_root) ); @@ -117,16 +117,16 @@ int window_create( struct gui_window * gw, free( gw->root->title ); free( gw->root ); return( -1 ); - } - - /* set scroll / content granularity ( 1 unit ) */ + } + + /* set scroll / content granularity ( 1 unit ) */ gw->root->handle->w_u = 1; - gw->root->handle->h_u = 1; - + gw->root->handle->h_u = 1; + /* Create Root component: */ gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1); WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL); - + /* create toolbar component: */ if( tb ) { gw->root->toolbar = tb_create( gw ); @@ -136,11 +136,11 @@ int window_create( struct gui_window * gw, } else { gw->root->toolbar = NULL; } - + /* create browser component: */ gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 ); mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp ); - + /* create statusbar component: */ if( sb ) { gw->root->statusbar = sb_create( gw ); @@ -154,38 +154,34 @@ int window_create( struct gui_window * gw, /* Event Handlers: */ EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw ); /* capture resize/move events so we can handle that manually */ - EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw ); - if( !option_atari_realtime_move ) { - EvntDataAttach( gw->root->handle, WM_MOVED, evnt_window_move, gw ); - } else { - EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT ); - } - EvntDataAttach( gw->root->handle, WM_FORCE_MOVE, evnt_window_rt_resize, gw ); - EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw ); + EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT ); + EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT ); + EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT ); EvntDataAdd( gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP ); EvntDataAdd( gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP ); EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT); - EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT); - EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT); + EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT); + EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT); EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT); + EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw ); EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw); - EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw ); + EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw ); /* TODO: check if window is openend as "foreground" window... */ - window_set_focus( gw, BROWSER, gw->browser); - + window_set_focus( gw, BROWSER, gw->browser); + return (err); } int window_destroy( struct gui_window * gw) { int err = 0; - + search_destroy( gw ); if( input_window == gw ) input_window = NULL; - - if( gw->root ) { + + if( gw->root ) { if( gw->root->toolbar ) tb_destroy( gw->root->toolbar ); @@ -200,7 +196,7 @@ int window_destroy( struct gui_window * gw) /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */ if( gw->root ) { - /* TODO: check if no other browser is bound to this root window! */ + /* TODO: check if no other browser is bound to this root window! */ /* only needed for tabs */ if( gw->root->title ) free( gw->root->title ); @@ -219,18 +215,18 @@ int window_destroy( struct gui_window * gw) void window_open( struct gui_window * gw, GRECT pos ) { - LGRECT br; + LGRECT br; - WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h ); + WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h ); WindClear( gw->root->handle ); - WindSetStr( gw->root->handle, WF_NAME, (char *)"" ); + WindSetStr( gw->root->handle, WF_NAME, (char *)"" ); /* apply focus to the root frame: */ long lfbuff[8] = { CM_GETFOCUS }; mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff ); - + /* recompute the nested component sizes and positions: */ - browser_update_rects( gw ); + browser_update_rects( gw ); mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc); browser_get_rect( gw, BR_CONTENT, &br ); plotter->move( plotter, br.g_x, br.g_y ); @@ -238,11 +234,11 @@ void window_open( struct gui_window * gw, GRECT pos ) gw->browser->attached = true; if( gw->root->statusbar != NULL ){ gw->root->statusbar->attached = true; - } - tb_adjust_size( gw ); - /*TBD: get already present content and set size? */ - input_window = gw; - window_set_focus( gw, BROWSER, gw->browser ); + } + tb_adjust_size( gw ); + /*TBD: get already present content and set size? */ + input_window = gw; + window_set_focus( gw, BROWSER, gw->browser ); } @@ -272,18 +268,18 @@ void window_set_focus( struct gui_window * gw, enum focus_element_type type, voi if( gw->root->focus.type != type || gw->root->focus.element != element ) { LOG(("Set focus: %p (%d)\n", element, type)); gw->root->focus.type = type; - gw->root->focus.element = element; - if( element != NULL ){ - switch( type ){ - - case URL_WIDGET: - textarea_keypress(((struct s_url_widget*)(element))->textarea, - KEY_SELECT_ALL ); - break; - - default: break; - - } + gw->root->focus.element = element; + if( element != NULL ){ + switch( type ){ + + case URL_WIDGET: + textarea_keypress(((struct s_url_widget*)(element))->textarea, + KEY_SELECT_ALL ); + break; + + default: break; + + } } } } @@ -312,22 +308,22 @@ bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, } assert( gw->root != NULL ); return( ( element == gw->root->focus.element && t == gw->root->focus.type) ); -} - - +} + + /* -------------------------------------------------------------------------- */ /* Event Handlers: */ -/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data ) { bool abs = false; - LGRECT cwork; + LGRECT cwork; struct gui_window * gw = data; - int value = BROWSER_SCROLL_SVAL; - + int value = BROWSER_SCROLL_SVAL; + assert( gw != NULL ); - + browser_get_rect( gw, BR_CONTENT, &cwork ); switch( buff[4] ) { @@ -346,7 +342,7 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data break; } browser_scroll( gw, buff[4], value, abs ); -} +} static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) @@ -397,12 +393,12 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) struct browser_window * bw = gw->browser->bw; browser_get_rect( gw, BR_CONTENT, &bwrect ); mx = mx - bwrect.g_x; - my = my - bwrect.g_y; + my = my - bwrect.g_y; if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) ) - return; - + return; + utf8_convert_ret ret; - char *utf8_fn; + char *utf8_fn; ret = utf8_from_local_encoding( buff, 0, &utf8_fn); if (ret != UTF8_CONVERT_OK) { @@ -411,19 +407,19 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) assert(ret != UTF8_CONVERT_BADENC); /* no memory */ return; - } - browser_window_drop_file_at_point( gw->browser->bw, - mx+gw->browser->scroll.current.x, - my+gw->browser->scroll.current.y, - utf8_fn ); + } + browser_window_drop_file_at_point( gw->browser->bw, + mx+gw->browser->scroll.current.x, + my+gw->browser->scroll.current.y, + utf8_fn ); free( utf8_fn ); } } } error: ddclose( dd_hdl); -} - +} + static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data ) { LOG(("%s\n", __FUNCTION__ )); @@ -439,26 +435,26 @@ 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 ) -{ - input_window = (struct gui_window *) data; - window_set_focus( input_window, BROWSER, input_window->browser ); - LOG(("newtop gui window: %p, WINDOW: %p", input_window, win )); +{ + input_window = (struct gui_window *) data; + window_set_focus( input_window, BROWSER, input_window->browser ); + LOG(("newtop gui window: %p, WINDOW: %p", input_window, win )); assert( input_window != NULL ); } -static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data) -{ +static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data) +{ int dx = buff[4]; int dy = buff[5]; struct gui_window * gw = data; - + if (!dx && !dy) return; if( input_window == NULL || input_window != gw ) { return; } - /* update the sliders _before_ we call redraw + /* update the sliders _before_ we call redraw (which might depend on the slider possitions) */ WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) ); @@ -469,23 +465,23 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data if( dx > 0 ) browser_scroll( gw, WA_RTPAGE, abs(dx), false ); else if( dx < 0 ) - browser_scroll( gw, WA_LFPAGE, abs(dx), false ); -} - + browser_scroll( gw, WA_LFPAGE, abs(dx), false ); +} + static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data ) -{ - struct gui_window * gw = (struct gui_window *)data; - - input_window = gw; - WindTop( gw->root->handle ); +{ + struct gui_window * gw = (struct gui_window *)data; + + input_window = gw; + WindTop( gw->root->handle ); window_set_focus( gw, BROWSER, gw->browser ); -} - +} + static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data ) -{ +{ struct gui_window * gw = (struct gui_window *)data; - if( input_window == gw){ - input_window = NULL; + if( input_window == gw){ + input_window = NULL; } } @@ -493,8 +489,8 @@ static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void * dat { short x,y,w,h; struct gui_window * gw = (struct gui_window*)data; - - WindClear( win); + + WindClear( win); WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); if( gw->icon == NULL ) { OBJECT * tree; @@ -504,90 +500,50 @@ static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void * dat tree->ob_width = w; tree->ob_height = h; mt_objc_draw( tree, 0, 8, buff[4], buff[5], buff[6], buff[7], app.aes_global ); - } else { - struct rect clip = { 0,0,w,h }; - plotter->move( plotter, x, y ); - plotter->resize( plotter, w, h ); - plotter->clip(plotter, &clip ); - plotter->bitmap_resize( plotter, gw->icon, w, h ); - plotter->bitmap( - plotter, - ( gw->icon->resized ) ? gw->icon->resized : gw->icon, - 0, 0, 0xffffff, BITMAPF_NONE - ); - } -} - -static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data ) -{ - short wx, wy, wh, ww, nx, ny; - if( option_atari_realtime_move ) { - std_mvd( win, buff, &app ); - evnt_window_rt_resize( win, buff, data ); } else { - wind_get( win->handle, WF_CURRXYWH, &wx, &wy, &ww, &wh ); - if( graf_dragbox( ww, wh, wx, wy, app.x-ww, app.y, app.w+ww, app.h+wh, &nx, &ny )){ - buff[4] = nx; - buff[5] = ny; - buff[6] = ww; - buff[7] = wh; - std_mvd( win, buff, &app ); - evnt_window_rt_resize( win, buff, data ); - } + struct rect clip = { 0,0,w,h }; + plotter->move( plotter, x, y ); + plotter->resize( plotter, w, h ); + plotter->clip(plotter, &clip ); + plotter->bitmap_resize( plotter, gw->icon, w, h ); + plotter->bitmap( + plotter, + ( gw->icon->resized ) ? gw->icon->resized : gw->icon, + 0, 0, 0xffffff, BITMAPF_NONE + ); } } -void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data ) -{ - short wx, wy, wh, ww, nw, nh; - short r; - wind_get( win->handle, WF_CURRXYWH, &wx, &wy, &ww, &wh ); - r = graf_rubberbox(wx, wy, 20, 20, &nw, &nh); - if( nw < 40 && nw < 40 ) - return; - buff[4] = wx; - buff[5] = wy; - buff[6] = nw; - buff[7] = nh; - std_szd( win, buff, &app ); - evnt_window_rt_resize( win, buff, data ); -} - /* perform the actual resize */ static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * data ) { short x,y,w,h; - struct gui_window * gw; - - if(buff[0] == WM_FORCE_MOVE ) { - std_mvd(win, buff, &app); - std_szd(win, buff, &app); - } + struct gui_window * gw; wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h ); gw = (struct gui_window *)data; - assert( gw != NULL ); + assert( gw != NULL ); if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){ /* report resize to component interface: */ - browser_update_rects( gw ); + browser_update_rects( gw ); tb_adjust_size( gw ); - if( gw->browser->bw->current_content != NULL ){ - /* Reformat will happen when next redraw message arrives: */ - gw->browser->reformat_pending = true; - if( sys_XAAES() ){ - if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){ - ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle, - gw->root->loc.g_x, gw->root->loc.g_y, - gw->root->loc.g_w, gw->root->loc.g_h ); - } - } - mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, - (GRECT*)&gw->root->loc); - } - else { - WindClear( gw->root->handle ); + if( gw->browser->bw->current_content != NULL ){ + /* Reformat will happen when next redraw message arrives: */ + gw->browser->reformat_pending = true; + if( sys_XAAES() ){ + if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ){ + ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle, + gw->root->loc.g_x, gw->root->loc.g_y, + gw->root->loc.g_w, gw->root->loc.g_h ); + } + } + mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, + (GRECT*)&gw->root->loc); + } + else { + WindClear( gw->root->handle ); } } else { if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){ diff --git a/atari/gui.h b/atari/gui.h index 14b4ca463..ee84d9215 100755 --- a/atari/gui.h +++ b/atari/gui.h @@ -21,8 +21,6 @@ #include -#define WM_FORCE_MOVE 1024 + 3 - struct point_s { int x; int y; diff --git a/atari/options.h b/atari/options.h index a6eacf304..e2bfc35f8 100755 --- a/atari/options.h +++ b/atari/options.h @@ -25,7 +25,6 @@ extern char * option_atari_font_driver; extern int option_atari_font_monochrom; extern int option_atari_dither; extern int option_atari_transparency; -extern int option_atari_realtime_move; extern char *option_atari_face_sans_serif; /* default sans face */ extern char *option_atari_face_sans_serif_bold; /* bold sans face */ extern char *option_atari_face_sans_serif_italic; /* bold sans face */ @@ -49,7 +48,6 @@ char * option_atari_font_driver = (char*)"vdi";\ int option_atari_font_monochrom = 0;\ int option_atari_dither = 1;\ int option_atari_transparency = 1;\ -int option_atari_realtime_move = 0; \ char *option_atari_face_sans_serif;\ char *option_atari_face_sans_serif_bold;\ char *option_atari_face_sans_serif_italic;\ @@ -72,7 +70,6 @@ char *option_tree_icons_path = (char*)"./res/icons"; { "atari_font_monochrom", OPTION_INTEGER, &option_atari_font_monochrom },\ { "atari_transparency", OPTION_INTEGER, &option_atari_transparency },\ { "atari_dither", OPTION_INTEGER, &option_atari_dither },\ - { "atari_realtime_move", OPTION_INTEGER, &option_atari_realtime_move },\ { "atari_editor", OPTION_STRING, &option_atari_editor },\ { "font_face_sans_serif", OPTION_STRING, &option_atari_face_sans_serif },\ { "font_face_sans_serif_bold", OPTION_STRING, &option_atari_face_sans_serif_bold },\ -- cgit v1.2.3