From adcbbbe88033e245732b73bd6319c0cb9b4da9b3 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Fri, 11 Jan 2013 02:12:30 +0100 Subject: Started to move the search form into the browser window. --- atari/ctxmenu.c | 67 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'atari/ctxmenu.c') diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c index bb52ef5a5..a82824eb3 100644 --- a/atari/ctxmenu.c +++ b/atari/ctxmenu.c @@ -48,7 +48,6 @@ #define CNT_INVALID 0 -#define CNT_URLINPUT 32 #define CNT_BROWSER 64 #define CNT_HREF 128 #define CNT_SELECTION 256 @@ -66,49 +65,51 @@ struct s_context_info ctxinfo; static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my ) { hlcache_handle *h; - GRECT bwrect; + GRECT area; struct contextual_content ccdata; struct browser_window * bw = gw->browser->bw; int sx, sy; h = bw->current_content; - ctxinfo.flags = 0; - - guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &bwrect); - mx -= bwrect.g_x; - my -= bwrect.g_y; - if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) ){ - // TODO: check for urlinput location - // and set CNT_URLINPUT - return(&ctxinfo); - } - - if (!bw->current_content || content_get_type(h) != CONTENT_HTML){ - return(&ctxinfo); - } + ctxinfo.flags = 0; + + window_get_grect(gw->root, BROWSER_AREA_CONTENT, &area); + if (POINT_WITHIN(mx, my, area)) { + + mx -= area.g_x; + my -= area.g_y; + + if (!bw->current_content || content_get_type(h) != CONTENT_HTML){ + return(&ctxinfo); + } - ctxinfo.flags |= CNT_BROWSER; + ctxinfo.flags |= CNT_BROWSER; - memset( &ctxinfo.ccdata, sizeof(struct contextual_content), 0 ); + memset( &ctxinfo.ccdata, sizeof(struct contextual_content), 0 ); - gui_window_get_scroll(gw, &sx, &sy); + gui_window_get_scroll(gw, &sx, &sy); - browser_window_get_contextual_content( gw->browser->bw, mx+sx, my+sy, - (struct contextual_content*)&ctxinfo.ccdata); + browser_window_get_contextual_content( gw->browser->bw, mx+sx, my+sy, + (struct contextual_content*)&ctxinfo.ccdata); - if( ctxinfo.ccdata.link_url ){ - ctxinfo.flags |= CNT_HREF; - } - if( ctxinfo.ccdata.object) { - if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){ - ctxinfo.flags |= CNT_IMG; + if( ctxinfo.ccdata.link_url ){ + ctxinfo.flags |= CNT_HREF; } - } - if ( ctxinfo.ccdata.form_features == CTX_FORM_TEXT ) - ctxinfo.flags |= (CNT_INTERACTIVE | CNT_SELECTION); - return( &ctxinfo ); -} + if( ctxinfo.ccdata.object) { + if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){ + ctxinfo.flags |= CNT_IMG; + } + } + if ( ctxinfo.ccdata.form_features == CTX_FORM_TEXT ) + ctxinfo.flags |= (CNT_INTERACTIVE | CNT_SELECTION); + } + + return(&ctxinfo); + +} + +//TODO: do not open popup for gui_window, but for a rootwin? void context_popup(struct gui_window * gw, short x, short y) { @@ -147,7 +148,7 @@ void context_popup(struct gui_window * gw, short x, short y) SET_BIT(pop[ POP_CTX_SELECT_ALL ].ob_state, OS_DISABLED, 0); SET_BIT(pop[ POP_CTX_COPY_SEL ].ob_state, OS_DISABLED, 0); SET_BIT(pop[ POP_CTX_VIEW_SOURCE ].ob_state, OS_DISABLED, 0); - } + } if( ctx->flags & CNT_HREF ){ SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, OS_DISABLED, 0); -- cgit v1.2.3