mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 06:51:26 +03:00
Added context menu,
Allow to set bitmap for iconified window. ( altough it's usesless right now because favicon support has been dropped) svn path=/trunk/netsurf/; revision=12821
This commit is contained in:
parent
60f641bc44
commit
0f2871e418
@ -1,13 +1,13 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# Atari target setup
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
$(eval $(call feature_enabled,MNG,-DWITH_MNG,-lmng,PNG/MNG/JNG (libmng)))
|
||||
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) ))
|
||||
|
||||
CFLAGS += -DATARI_USE_FREETYPE $(shell freetype-config --cflags)
|
||||
LDFLAGS += -lcflib -lfreetype
|
||||
|
||||
|
||||
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
|
||||
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
|
||||
NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
|
||||
@ -17,7 +17,7 @@ NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
|
||||
#LDFLAGS += -lnsbmp -lnsgif
|
||||
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP))
|
||||
$(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
|
||||
|
||||
|
||||
CFLAGS += -U__STRICT_ANSI__ -std=c99 -I. -Dsmall $(WARNFLAGS) -Dnsatari \
|
||||
-D_BSD_SOURCE \
|
||||
-D_XOPEN_SOURCE=600 \
|
||||
@ -25,11 +25,11 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -I. -Dsmall $(WARNFLAGS) -Dnsatari \
|
||||
$(shell $(PKG_CONFIG) --cflags libhubbub libcss openssl) \
|
||||
$(shell xml2-config --cflags) \
|
||||
$(shell curl-config --cflags)
|
||||
|
||||
LDFLAGS += -lcurl
|
||||
LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet
|
||||
|
||||
LDFLAGS += -lcurl
|
||||
LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet
|
||||
LDFLAGS += -lssl -lcrypto
|
||||
LDFLAGS += -lxml2 -lz -liconv -lHermes -lwindom -lgem -lm
|
||||
LDFLAGS += -lxml2 -lz -liconv -lHermes -lwindom -lgem -lm
|
||||
|
||||
|
||||
# S_ATARI are sources purely for the Atari FreeMiNT build
|
||||
@ -39,7 +39,8 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
|
||||
plot.c plot/plotter.c plot/plotter_vdi.c plot/eddi.s \
|
||||
plot/font_vdi.c plot/font_freetype.c plot/font_internal.c \
|
||||
browser_win.c toolbar.c statusbar.c browser.c \
|
||||
global_evnt.c osspec.c dragdrop.c system_colour.c
|
||||
global_evnt.c osspec.c dragdrop.c system_colour.c \
|
||||
ctxmenu.c
|
||||
S_ATARI := $(addprefix atari/,$(S_ATARI))
|
||||
|
||||
# This is the final source build list
|
||||
|
180
atari/browser.c
180
atari/browser.c
@ -27,9 +27,15 @@
|
||||
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "css/css.h"
|
||||
#include "render/box.h"
|
||||
#include "render/form.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
@ -37,12 +43,12 @@
|
||||
#include "atari/browser_win.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/global_evnt.h"
|
||||
#include "atari/browser_win.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
#include "atari/browser.h"
|
||||
#include "atari/plot/plotter.h"
|
||||
#include "atari/plot.h"
|
||||
#include "atari/font.h"
|
||||
#include "atari/font.h"
|
||||
#include "atari/ctxmenu.h"
|
||||
#include "cflib.h"
|
||||
|
||||
extern browser_mouse_state bmstate;
|
||||
@ -67,7 +73,7 @@ struct s_browser * browser_create
|
||||
struct gui_window * gw,
|
||||
struct browser_window *bw,
|
||||
struct browser_window * clone,
|
||||
int lt, int w, int flex
|
||||
int lt, int w, int flex
|
||||
)
|
||||
{
|
||||
LGRECT cwork;
|
||||
@ -93,31 +99,31 @@ struct s_browser * browser_create
|
||||
bnew->compwin->w_u = 1;
|
||||
bnew->compwin->h_u = 1;
|
||||
/* needs to be adjusted when content width is known: */
|
||||
bnew->compwin->ypos_max = w;
|
||||
bnew->compwin->ypos_max = w;
|
||||
bnew->compwin->xpos_max = w;
|
||||
mt_WindSlider( &app, bnew->compwin, HSLIDER|VSLIDER);
|
||||
bnew->comp = (COMPONENT*)comp_widget_create( (void*)&app, (WINDOW*)bnew->compwin, 1, 1 );
|
||||
bnew->comp = (COMPONENT*)comp_widget_create( (void*)&app, (WINDOW*)bnew->compwin, 1, 1 );
|
||||
if( bnew->comp == NULL ) {
|
||||
free(bnew);
|
||||
return(NULL);
|
||||
}
|
||||
mt_EvntDataAdd( &app, bnew->compwin, WM_XBUTTON,
|
||||
mt_EvntDataAdd( &app, bnew->compwin, WM_XBUTTON,
|
||||
browser_evnt_mbutton, (void*)gw, EV_BOT );
|
||||
mt_CompEvntDataAttach( &app, bnew->comp, WM_REDRAW,
|
||||
mt_CompEvntDataAttach( &app, bnew->comp, WM_REDRAW,
|
||||
browser_evnt_redraw, (void*)gw );
|
||||
mt_EvntDataAttach( &app, bnew->compwin , WM_REDRAW, browser_evnt_redraw_x, NULL );
|
||||
mt_EvntDataAttach( &app, bnew->compwin, WM_SLIDEXY,
|
||||
mt_EvntDataAttach( &app, bnew->compwin, WM_SLIDEXY,
|
||||
browser_evnt_slider, gw );
|
||||
mt_EvntDataAttach( &app, bnew->compwin, WM_ARROWED,
|
||||
browser_evnt_arrowed, gw );
|
||||
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
|
||||
mt_EvntDataAttach( &app, bnew->compwin, WM_ARROWED,
|
||||
browser_evnt_arrowed, gw );
|
||||
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
|
||||
browser_evnt_destroy, (void*)bnew );
|
||||
/* just stub, as an reminder: */
|
||||
mt_EvntDataAttach( &app, bnew->compwin, WM_DESTROY,
|
||||
mt_EvntDataAttach( &app, bnew->compwin, WM_DESTROY,
|
||||
browser_evnt_wdestroy, (void*)bnew );
|
||||
|
||||
mt_CompDataAttach( &app, bnew->comp, CDT_OWNER, gw );
|
||||
bnew->scroll.requested.y = 0;
|
||||
mt_CompDataAttach( &app, bnew->comp, CDT_OWNER, gw );
|
||||
bnew->scroll.requested.y = 0;
|
||||
bnew->scroll.requested.x = 0;
|
||||
bnew->scroll.current.x = 0;
|
||||
bnew->scroll.current.y = 0;
|
||||
@ -144,7 +150,7 @@ bool browser_destroy( struct s_browser * b )
|
||||
/* listRemove( (LINKABLE*) oldwin ); */
|
||||
/* listRemove( (LINKABLE*) old ); */
|
||||
WindDelete( oldwin );
|
||||
mt_CompDelete(&app, old );
|
||||
mt_CompDelete(&app, old );
|
||||
}
|
||||
return( true );
|
||||
}
|
||||
@ -166,7 +172,7 @@ void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT *
|
||||
out->g_y = work.g_y;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LGRECT cur;
|
||||
mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
|
||||
if( type == BR_HSLIDER ){
|
||||
@ -195,7 +201,7 @@ void browser_update_rects(struct gui_window * gw )
|
||||
buff[1] = _AESapid;
|
||||
buff[2] = 0;
|
||||
EvntExec(gw->root->handle, buff);
|
||||
}
|
||||
}
|
||||
|
||||
void browser_set_content_size(struct gui_window * gw, int w, int h)
|
||||
{
|
||||
@ -236,7 +242,7 @@ static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * da
|
||||
}
|
||||
|
||||
|
||||
static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * data)
|
||||
static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * data)
|
||||
{
|
||||
bool abs = false;
|
||||
int value = BROWSER_SCROLL_SVAL;
|
||||
@ -259,7 +265,7 @@ static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * dat
|
||||
value = cwork.g_w;
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
browser_scroll( gw, buff[4], value, abs );
|
||||
@ -292,9 +298,8 @@ void __CDECL browser_evnt_slider( WINDOW *win, short buff[8], void * data)
|
||||
}
|
||||
|
||||
static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data)
|
||||
{
|
||||
{
|
||||
long lbuff[8];
|
||||
short i;
|
||||
short mx, my, dummy, mbut;
|
||||
uint32_t tnow = clock()*1000 / CLOCKS_PER_SEC;
|
||||
LGRECT cwork;
|
||||
@ -302,9 +307,10 @@ static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data
|
||||
if( input_window != gw ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window_set_focus( gw, BROWSER, (void*)gw->browser );
|
||||
browser_get_rect( gw, BR_CONTENT, &cwork );
|
||||
mx = evnt.mx - cwork.g_x;
|
||||
mx = evnt.mx - cwork.g_x;
|
||||
my = evnt.my - cwork.g_y;
|
||||
LOG(("mevent (%d) within %s at %d / %d\n", evnt.nb_click, gw->browser->bw->name, mx, my ));
|
||||
|
||||
@ -327,61 +333,41 @@ static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data
|
||||
int sy = (my + gw->browser->scroll.current.y);
|
||||
|
||||
graf_mkstate(&dummy, &dummy, &mbut, &dummy);
|
||||
/* todo: if we need right button click, increase loop count */
|
||||
for( i = 1; i<2; i++) {
|
||||
if( (mbut & i) ) {
|
||||
if( mouse_hold_start[i-1] == 0 ) {
|
||||
mouse_hold_start[i-1] = tnow;
|
||||
LOG(("Drag %d starts at %d,%d\n", i, sx, sy));
|
||||
if( i == 1 ) {
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
|
||||
bmstate |= BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
if( i == 2 ) {
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_2,sx,sy);
|
||||
bmstate |= BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
} else {
|
||||
if( i == 1 ) {
|
||||
bmstate |= BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
if( i == 2 ) {
|
||||
bmstate |= BROWSER_MOUSE_DRAG_2 | BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
}
|
||||
|
||||
if( i != 0 ){
|
||||
if( (abs(mx-last_drag_x)>5) || (abs(mx-last_drag_y)>5) ){
|
||||
browser_window_mouse_track(
|
||||
gw->browser->bw,
|
||||
bmstate,
|
||||
sx, sy
|
||||
);
|
||||
last_drag_x = mx;
|
||||
last_drag_y = my;
|
||||
}
|
||||
}
|
||||
|
||||
if( (mbut & 1) && (evnt.mbut & 1) ) {
|
||||
if( mouse_hold_start[0] == 0 ) {
|
||||
mouse_hold_start[0] = tnow;
|
||||
LOG(("Drag starts at %d,%d\n", sx, sy));
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
|
||||
bmstate |= BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
|
||||
} else {
|
||||
mouse_click_time[i-1] = tnow; /* clock in ms */
|
||||
/* check if this event was during an drag op: */
|
||||
if( mouse_hold_start[i-1] == 0 ) {
|
||||
if( i == 1) {
|
||||
LOG(("Click within %s at %d / %d\n", gw->browser->bw->name, sx, sy ));
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_CLICK_1,sx,sy);
|
||||
bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_CLICK_1);
|
||||
}
|
||||
if( i == 2 ) {
|
||||
LOG(("Click within %s at %d / %d", gw->browser->bw->name, mx, my ));
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_CLICK_2,sx,sy);
|
||||
bmstate &= ~( BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_2 | BROWSER_MOUSE_CLICK_2);
|
||||
}
|
||||
}
|
||||
mouse_hold_start[i-1] = 0;
|
||||
bmstate |= BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
if( (abs(mx-last_drag_x)>5) || (abs(mx-last_drag_y)>5) ){
|
||||
browser_window_mouse_track(
|
||||
gw->browser->bw,
|
||||
bmstate,
|
||||
sx, sy
|
||||
);
|
||||
last_drag_x = mx;
|
||||
last_drag_y = my;
|
||||
}
|
||||
|
||||
} else if( (evnt.mbut & 1) ) {
|
||||
mouse_click_time[0] = tnow; /* clock in ms */
|
||||
/* check if this event was during an drag op, only handle if it wasn't: */
|
||||
if( mouse_hold_start[0] == 0 ) {
|
||||
LOG(("Click within %s at %d / %d\n", gw->browser->bw->name, sx, sy ));
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
|
||||
browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_CLICK_1,sx,sy);
|
||||
bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_CLICK_1);
|
||||
}
|
||||
}
|
||||
mouse_hold_start[0] = 0;
|
||||
}
|
||||
|
||||
if( (evnt.mbut & 2 ) ) {
|
||||
context_popup( gw, evnt.mx, evnt.my );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
|
||||
@ -406,12 +392,12 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
|
||||
switch( mode ) {
|
||||
|
||||
case WA_UPPAGE:
|
||||
case WA_UPLINE:
|
||||
case WA_UPLINE:
|
||||
if( max_y_scroll < 1 )
|
||||
return;
|
||||
if( abs == false )
|
||||
b->scroll.requested.y -= value;
|
||||
else
|
||||
else
|
||||
b->scroll.requested.y = value - b->scroll.current.y;
|
||||
break;
|
||||
|
||||
@ -426,7 +412,7 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
|
||||
break;
|
||||
|
||||
case WA_LFPAGE:
|
||||
case WA_LFLINE:
|
||||
case WA_LFLINE:
|
||||
if( max_x_scroll < 1 )
|
||||
return;
|
||||
if( abs == false )
|
||||
@ -445,7 +431,7 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
|
||||
b->scroll.requested.x = value - b->scroll.current.x;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if( b->scroll.current.y + b->scroll.requested.y < 0 ) {
|
||||
@ -474,7 +460,7 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
|
||||
perform the requested scrolling.
|
||||
gw -> the browser window to act upon.
|
||||
bwrect -> the dimensions of the browser, so that this function
|
||||
doesn't need to get it.
|
||||
doesn't need to get it.
|
||||
*/
|
||||
static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
|
||||
{
|
||||
@ -487,7 +473,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
|
||||
return;
|
||||
|
||||
h = (short) abs( b->scroll.requested.y );
|
||||
w = (short) abs( b->scroll.requested.x );
|
||||
w = (short) abs( b->scroll.requested.x );
|
||||
|
||||
/* if the request exceeds the browser size, redraw the whole area */
|
||||
if ( b->scroll.requested.y > bwrect.g_h || b->scroll.requested.y < -bwrect.g_h ||
|
||||
@ -511,11 +497,11 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
|
||||
dst.g_h = src.g_h;
|
||||
plotter->copy_rect( plotter, src, dst );
|
||||
b->scroll.current.y += b->scroll.requested.y;
|
||||
browser_schedule_redraw( gw, 0, 0, bwrect.g_w, h ) ;
|
||||
browser_schedule_redraw( gw, 0, 0, bwrect.g_w, h ) ;
|
||||
}
|
||||
|
||||
if( b->scroll.requested.y > 0 ) {
|
||||
/* scroll down */
|
||||
/* scroll down */
|
||||
src.g_x = 0;
|
||||
src.g_y = h;
|
||||
src.g_w = bwrect.g_w;
|
||||
@ -527,7 +513,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
|
||||
plotter->copy_rect( plotter, src, dst );
|
||||
b->scroll.current.y += b->scroll.requested.y;
|
||||
browser_schedule_redraw( gw, 0, bwrect.g_h - h, bwrect.g_w, bwrect.g_h );
|
||||
}
|
||||
}
|
||||
|
||||
if( b->scroll.requested.x < 0 ) {
|
||||
/* scroll to the left */
|
||||
@ -557,7 +543,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
|
||||
plotter->copy_rect( plotter, src, dst );
|
||||
b->scroll.current.x += b->scroll.requested.x;
|
||||
browser_schedule_redraw( gw, bwrect.g_w - w, 0, bwrect.g_w, bwrect.g_h );
|
||||
}
|
||||
}
|
||||
b->scroll.requested.y = 0;
|
||||
b->scroll.requested.x = 0;
|
||||
gw->browser->compwin->xpos = b->scroll.current.x;
|
||||
@ -567,7 +553,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
|
||||
}
|
||||
|
||||
|
||||
bool browser_input( struct gui_window * gw, unsigned short nkc )
|
||||
bool browser_input( struct gui_window * gw, unsigned short nkc )
|
||||
{
|
||||
LGRECT work;
|
||||
bool r = false;
|
||||
@ -601,7 +587,7 @@ bool browser_input( struct gui_window * gw, unsigned short nkc )
|
||||
switch( ascii ) {
|
||||
|
||||
case NK_TAB:
|
||||
r = browser_window_key_press(gw->browser->bw, KEY_SHIFT_TAB);
|
||||
r = browser_window_key_press(gw->browser->bw, KEY_SHIFT_TAB);
|
||||
break;
|
||||
|
||||
case NK_LEFT:
|
||||
@ -660,7 +646,7 @@ bool browser_input( struct gui_window * gw, unsigned short nkc )
|
||||
break;
|
||||
|
||||
case NK_ESC:
|
||||
r = browser_window_key_press(gw->browser->bw, KEY_ESCAPE);
|
||||
r = browser_window_key_press(gw->browser->bw, KEY_ESCAPE);
|
||||
break;
|
||||
|
||||
case NK_CLRHOME:
|
||||
@ -672,7 +658,7 @@ bool browser_input( struct gui_window * gw, unsigned short nkc )
|
||||
browser_scroll( gw, WA_RTLINE, 16, false );
|
||||
r = true;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case NK_LEFT:
|
||||
if (browser_window_key_press(gw->browser->bw, KEY_LEFT) == false) {
|
||||
@ -702,7 +688,7 @@ bool browser_input( struct gui_window * gw, unsigned short nkc )
|
||||
}
|
||||
break;
|
||||
|
||||
case NK_M_PGDOWN:
|
||||
case NK_M_PGDOWN:
|
||||
if (browser_window_key_press(gw->browser->bw, KEY_PAGE_DOWN) == false) {
|
||||
browser_scroll( gw, WA_DNPAGE, work.g_h, false );
|
||||
r = true;
|
||||
@ -820,7 +806,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( b->redraw.areas_used < MAX_REDRW_SLOTS ) {
|
||||
b->redraw.areas[b->redraw.areas_used].x0 = x0;
|
||||
@ -882,7 +868,7 @@ void browser_redraw_caret( struct gui_window * gw, GRECT * area )
|
||||
plot_get_clip( &old_clip );
|
||||
/* clip to cursor: */
|
||||
plot_clip( &clip );
|
||||
plot_rectangle( caret.g_x, caret.g_y,
|
||||
plot_rectangle( caret.g_x, caret.g_y,
|
||||
caret.g_x+caret.g_w, caret.g_y+caret.g_h,
|
||||
plot_style_caret );
|
||||
/* restore old clip area: */
|
||||
@ -890,11 +876,11 @@ void browser_redraw_caret( struct gui_window * gw, GRECT * area )
|
||||
b->caret.current.g_x = caret.g_x + gw->browser->scroll.current.x;
|
||||
b->caret.current.g_y = caret.g_y + gw->browser->scroll.current.y;
|
||||
b->caret.current.g_w = caret.g_w;
|
||||
b->caret.current.g_h = caret.g_h;
|
||||
b->caret.current.g_h = caret.g_h;
|
||||
}
|
||||
}
|
||||
|
||||
void browser_redraw( struct gui_window * gw )
|
||||
void browser_redraw( struct gui_window * gw )
|
||||
{
|
||||
LGRECT bwrect;
|
||||
struct s_browser * b = gw->browser;
|
||||
@ -954,7 +940,7 @@ void browser_redraw( struct gui_window * gw )
|
||||
area.g_x = b->redraw.areas[i].x0;
|
||||
area.g_y = b->redraw.areas[i].y0;
|
||||
area.g_w = b->redraw.areas[i].x1 - b->redraw.areas[i].x0;
|
||||
area.g_h = b->redraw.areas[i].y1 - b->redraw.areas[i].y0;
|
||||
area.g_h = b->redraw.areas[i].y1 - b->redraw.areas[i].y0;
|
||||
if (rc_intersect((GRECT *)&fbwork,(GRECT *)&area)) {
|
||||
b->redraw.area.x0 = area.g_x;
|
||||
b->redraw.area.y0 = area.g_y;
|
||||
|
@ -55,8 +55,8 @@
|
||||
#include "atari/plot/plotter.h"
|
||||
#include "atari/dragdrop.h"
|
||||
#include "atari/search.h"
|
||||
#include "atari/osspec.h"
|
||||
|
||||
#include "atari/osspec.h"
|
||||
|
||||
extern void * h_gem_rsrc;
|
||||
extern struct gui_window *input_window;
|
||||
extern GEM_PLOTTER plotter;
|
||||
@ -266,7 +266,7 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
|
||||
int err = 0;
|
||||
bool tb, sb;
|
||||
tb = (inflags & WIDGET_TOOLBAR );
|
||||
sb = (inflags & WIDGET_STATUSBAR);
|
||||
sb = (inflags & WIDGET_STATUSBAR);
|
||||
short w,h, wx, wy, wh, ww;
|
||||
int flags = CLOSER | MOVER | NAME | FULLER | SMALLER ;
|
||||
|
||||
@ -341,6 +341,8 @@ int window_destroy( struct gui_window * gw)
|
||||
search_destroy( gw );
|
||||
if( input_window == gw )
|
||||
input_window = NULL;
|
||||
|
||||
window_set_icon( gw, NULL );
|
||||
|
||||
if( gw->root ) {
|
||||
if( gw->root->toolbar )
|
||||
@ -365,7 +367,7 @@ int window_destroy( struct gui_window * gw)
|
||||
if( gw->root ) {
|
||||
/* TODO: check if no other browser is bound to this root window! */
|
||||
if( gw->root->title )
|
||||
free( gw->root->title );
|
||||
free( gw->root->title );
|
||||
if( gw->root->cmproot )
|
||||
mt_CompDelete( &app, gw->root->cmproot );
|
||||
ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
|
||||
@ -401,35 +403,16 @@ void window_open( struct gui_window * gw)
|
||||
snd_rdw( gw->root->handle );
|
||||
}
|
||||
|
||||
/*
|
||||
TODO
|
||||
void window_set_icon(struct gui_window * gw, void * data, bool is_rsc )
|
||||
|
||||
void window_set_icon(struct gui_window * gw, struct bitmap * bmp )
|
||||
{
|
||||
#define CDT_ICON_TYPE_OBJECT 1UL
|
||||
#define CDT_ICON_TYPE_BITMAP 2UL
|
||||
void * prev_type;
|
||||
void * ico = DataSearch(&app, gw->root->handle, CDT_ICON );
|
||||
if(ico != NULL) {
|
||||
prev_type = DataSearch(&app, gw->root->handle, CDT_ICON_TYPE );
|
||||
if( prev_type == (void*)CDT_ICON_TYPE_OBJECT ){
|
||||
mt_ObjcFree( &app, (OBJECT*)ico );
|
||||
}
|
||||
if( prev_type == (void*)CDT_ICON_TYPE_BITMAP ){
|
||||
bitmap_destroy(ico);
|
||||
}
|
||||
}
|
||||
if( data != NULL ) {
|
||||
DataAttach( &app, gw->root->handle, CDT_ICON, data);
|
||||
if(is_rsc) {
|
||||
DataAttach( &app, gw->root->handle, CDT_ICON_TYPE, CDT_ICON_TYPE_OBJECT);
|
||||
} else {
|
||||
DataAttach( &app, gw->root->handle, CDT_ICON_TYPE, CDT_ICON_TYPE_BITMAP);
|
||||
}
|
||||
}
|
||||
#undef CDT_ICON_TYPE_OBJECT
|
||||
#undef CDT_ICON_TYPE_BITMAP
|
||||
if( gw->icon != NULL ){
|
||||
bitmap_destroy( gw->icon );
|
||||
gw->icon = NULL;
|
||||
}
|
||||
gw->icon = bmp;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* update back forward buttons (see tb_update_buttons (bug) ) */
|
||||
@ -455,7 +438,7 @@ static void window_redraw_controls(struct gui_window *gw, uint32_t flags)
|
||||
mt_CompGetLGrect(&app, gw->root->toolbar->comp, WF_WORKXYWH, &rect);
|
||||
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
|
||||
rect.g_x, rect.g_y, rect.g_w, rect.g_h );
|
||||
mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &rect);
|
||||
mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &rect);
|
||||
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
|
||||
rect.g_x, rect.g_y, rect.g_w, rect.g_h );
|
||||
}
|
||||
@ -509,7 +492,7 @@ bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t,
|
||||
return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
|
||||
}
|
||||
|
||||
static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
|
||||
static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
|
||||
{
|
||||
struct gui_window * gw = (struct gui_window *)data;
|
||||
char file[DD_NAMEMAX];
|
||||
@ -533,7 +516,7 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
|
||||
memset( ext, 0, 32);
|
||||
strcpy( ext, "ARGS");
|
||||
dd_msg = ddsexts( dd_hdl, ext);
|
||||
if( dd_msg<0)
|
||||
if( dd_msg<0)
|
||||
goto error;
|
||||
dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
|
||||
if( size+1 >= PATH_MAX )
|
||||
@ -544,13 +527,13 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
|
||||
buff = (char*)alloca(sizeof(char)*(size+1));
|
||||
if( buff != NULL )
|
||||
{
|
||||
if( Fread(dd_hdl, size, buff ) == size)
|
||||
if( Fread(dd_hdl, size, buff ) == size)
|
||||
{
|
||||
buff[size] = 0;
|
||||
}
|
||||
LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
|
||||
(char*)buff, (char*)&ext,
|
||||
size, mx, my
|
||||
LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
|
||||
(char*)buff, (char*)&ext,
|
||||
size, mx, my
|
||||
));
|
||||
{
|
||||
int posx, posy;
|
||||
@ -572,13 +555,13 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
|
||||
box_x = box->margin[LEFT];
|
||||
box_y = box->margin[TOP];
|
||||
|
||||
while ((box = box_at_point(box, mx+gw->browser->scroll.current.x, my+gw->browser->scroll.current.y, &box_x, &box_y, &h)))
|
||||
while ((box = box_at_point(box, mx+gw->browser->scroll.current.x, my+gw->browser->scroll.current.y, &box_x, &box_y, &h)))
|
||||
{
|
||||
if (box->style && css_computed_visibility(box->style) == CSS_VISIBILITY_HIDDEN)
|
||||
continue;
|
||||
if (box->gadget)
|
||||
if (box->gadget)
|
||||
{
|
||||
switch (box->gadget->type)
|
||||
switch (box->gadget->type)
|
||||
{
|
||||
case GADGET_FILE:
|
||||
file_box = box;
|
||||
@ -615,8 +598,8 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
|
||||
file_box->gadget->value = utf8_fn;
|
||||
/* Redraw box. */
|
||||
box_coords(file_box, &posx, &posy);
|
||||
browser_schedule_redraw(bw->window,
|
||||
posx - gw->browser->scroll.current.x,
|
||||
browser_schedule_redraw(bw->window,
|
||||
posx - gw->browser->scroll.current.x,
|
||||
posy - gw->browser->scroll.current.y,
|
||||
posx - gw->browser->scroll.current.x + file_box->width,
|
||||
posy - gw->browser->scroll.current.y + file_box->height);
|
||||
@ -668,12 +651,12 @@ 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;
|
||||
bool has_favicon = false;
|
||||
|
||||
LOG((""));
|
||||
|
||||
WindClear( win);
|
||||
WindClear( win);
|
||||
WindGet( win, WF_WORKXYWH, &x, &y, &w, &h);
|
||||
|
||||
if( has_favicon == false ) {
|
||||
if( gw->icon == NULL ) {
|
||||
OBJECT * tree;
|
||||
RsrcGaddr( h_gem_rsrc, R_TREE, ICONIFY , &tree );
|
||||
tree->ob_x = x;
|
||||
@ -681,6 +664,12 @@ 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( plotter, gw->icon, 0, 0, 0xffffff, BITMAPF_NONE );
|
||||
}
|
||||
}
|
||||
|
||||
@ -693,7 +682,7 @@ static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data )
|
||||
if( option_atari_realtime_move ) {
|
||||
std_mvd( win, buff, &app );
|
||||
evnt_window_rt_resize( win, buff, data );
|
||||
} else {
|
||||
} 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;
|
||||
|
@ -43,7 +43,7 @@ void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short
|
||||
/* Update Shade / Unshade state of the fwd/back buttons*/
|
||||
void window_update_back_forward(struct gui_window * gw);
|
||||
/* set root browser component: */
|
||||
void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
|
||||
void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
|
||||
|
||||
/* set focus element */
|
||||
void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
|
||||
@ -55,7 +55,7 @@ bool window_url_widget_has_focus( struct gui_window * gw );
|
||||
void window_set_url( struct gui_window * gw, const char * text);
|
||||
void window_set_stauts( struct gui_window * gw , char * text );
|
||||
void window_center(struct gui_window * gw);
|
||||
//void window_set_icon(struct gui_window * gw, void * data, bool is_rsc );
|
||||
void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
221
atari/ctxmenu.c
Normal file
221
atari/ctxmenu.c
Normal file
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright 2010 Ole Loots <ole@monochrom.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <windom.h>
|
||||
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "css/css.h"
|
||||
#include "render/box.h"
|
||||
#include "render/form.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
#include "atari/gui.h"
|
||||
#include "atari/browser.h"
|
||||
#include "atari/browser_win.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/clipboard.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
#include "atari/ctxmenu.h"
|
||||
|
||||
|
||||
#define CNT_INVALID 0
|
||||
#define CNT_URLINPUT 32
|
||||
#define CNT_BROWSER 64
|
||||
#define CNT_HREF 128
|
||||
#define CNT_SELECTION 256
|
||||
#define CNT_INTERACTIVE 512
|
||||
#define CNT_IMG 1024
|
||||
|
||||
|
||||
struct s_context_info {
|
||||
unsigned long flags;
|
||||
struct contextual_content ccdata;
|
||||
};
|
||||
|
||||
struct s_context_info ctxinfo;
|
||||
|
||||
static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
|
||||
{
|
||||
int posx, posy;
|
||||
struct box *box;
|
||||
struct box *file_box = 0;
|
||||
hlcache_handle *h;
|
||||
int box_x, box_y;
|
||||
LGRECT bwrect;
|
||||
struct contextual_content ccdata;
|
||||
struct browser_window * bw = gw->browser->bw;
|
||||
h = bw->current_content;
|
||||
|
||||
ctxinfo.flags = 0;
|
||||
|
||||
browser_get_rect( gw, BR_CONTENT, &bwrect );
|
||||
mx = mx - bwrect.g_x;
|
||||
my = 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 |= CNT_BROWSER;
|
||||
browser_window_get_contextual_content(
|
||||
gw->browser->bw, mx, my,
|
||||
(struct contextual_content*)&ctxinfo.ccdata
|
||||
);
|
||||
if( ctxinfo.ccdata.link_url ){
|
||||
ctxinfo.flags |= CNT_HREF;
|
||||
}
|
||||
if( ctxinfo.ccdata.object && (content_get_type(ccdata.object) == CONTENT_IMAGE)) {
|
||||
ctxinfo.flags |= CNT_IMG;
|
||||
}
|
||||
|
||||
|
||||
box = html_get_box_tree(h);
|
||||
box_x = box->margin[LEFT];
|
||||
box_y = box->margin[TOP];
|
||||
|
||||
while ((box = box_at_point(box, mx+gw->browser->scroll.current.x, my+gw->browser->scroll.current.y, &box_x, &box_y, &h)))
|
||||
{
|
||||
if (box->style && css_computed_visibility(box->style) == CSS_VISIBILITY_HIDDEN)
|
||||
continue;
|
||||
if (box->gadget)
|
||||
{
|
||||
switch (box->gadget->type)
|
||||
{
|
||||
case GADGET_TEXTBOX:
|
||||
case GADGET_TEXTAREA:
|
||||
case GADGET_PASSWORD:
|
||||
// TODO: check if there is really an selection, but it
|
||||
// doesn't hurt for now...:
|
||||
ctxinfo.flags |= (CNT_INTERACTIVE | CNT_SELECTION);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return( &ctxinfo );
|
||||
}
|
||||
|
||||
void context_popup( struct gui_window * gw, short x, short y )
|
||||
{
|
||||
#define POP_FIRST_ITEM POP_CTX_CUT_SEL
|
||||
#define POP_LAST_ITEM POP_CTX_VIEW_SOURCE
|
||||
OBJECT * pop;
|
||||
int choice;
|
||||
struct s_context_info * ctx;
|
||||
|
||||
pop = get_tree( POP_CTX );
|
||||
if( pop == NULL )
|
||||
return;
|
||||
ctx = get_context_info( gw, x, y );
|
||||
|
||||
/*
|
||||
Disable all items by default:
|
||||
*/
|
||||
for( choice = POP_FIRST_ITEM; choice<=POP_LAST_ITEM; choice++ ){
|
||||
SET_BIT(pop[ choice ].ob_state, DISABLED, 1);
|
||||
}
|
||||
|
||||
if( ctx->flags & CNT_INTERACTIVE ){
|
||||
SET_BIT(pop[ POP_CTX_PASTE_SEL ].ob_state, DISABLED, 0);
|
||||
}
|
||||
|
||||
if( (ctx->flags & CNT_BROWSER) ){
|
||||
SET_BIT(pop[ POP_CTX_SELECT_ALL ].ob_state, DISABLED, 0);
|
||||
SET_BIT(pop[ POP_CTX_COPY_SEL ].ob_state, DISABLED, 0);
|
||||
SET_BIT(pop[ POP_CTX_VIEW_SOURCE ].ob_state, DISABLED, 0);
|
||||
}
|
||||
|
||||
if( ctx->flags & CNT_HREF ){
|
||||
SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, DISABLED, 0);
|
||||
SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, DISABLED, 0);
|
||||
SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, DISABLED, 0);
|
||||
}
|
||||
|
||||
if( ctx->flags & CNT_IMG ){
|
||||
SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, DISABLED, 0);
|
||||
SET_BIT(pop[ POP_CTX_COPY_URL ].ob_state, DISABLED, 0);
|
||||
SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, DISABLED, 0);
|
||||
}
|
||||
|
||||
choice = MenuPopUp(
|
||||
pop, x, y,
|
||||
-1, -1, -1,
|
||||
P_WNDW + P_CHCK
|
||||
);
|
||||
|
||||
switch( choice ){
|
||||
case POP_CTX_COPY_SEL:
|
||||
browser_window_key_press( gw->browser->bw, KEY_COPY_SELECTION );
|
||||
break;
|
||||
|
||||
case POP_CTX_CUT_SEL:
|
||||
browser_window_key_press( gw->browser->bw, KEY_CUT_SELECTION );
|
||||
break;
|
||||
|
||||
case POP_CTX_PASTE_SEL:
|
||||
gui_paste_from_clipboard(gw, x, y);
|
||||
break;
|
||||
|
||||
case POP_CTX_SELECT_ALL:
|
||||
browser_window_key_press( gw->browser->bw, KEY_SELECT_ALL );
|
||||
break;
|
||||
|
||||
case POP_CTX_COPY_LINK:
|
||||
if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL ){
|
||||
scrap_txt_write(&app, (char*)ctx->ccdata.link_url);
|
||||
}
|
||||
break;
|
||||
|
||||
case POP_CTX_OPEN_NEW:
|
||||
if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url){
|
||||
browser_window_create(
|
||||
ctx->ccdata.link_url,
|
||||
gw->browser->bw,
|
||||
content_get_url(gw->browser->bw->current_content),
|
||||
true, false
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
#undef POP_FIRST_ITEM
|
||||
#undef POP_LAST_ITEM
|
||||
}
|
6
atari/ctxmenu.h
Normal file
6
atari/ctxmenu.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef CTXMENU_H_INCLUDED
|
||||
#define CTXMENU_H_INCLUDED
|
||||
|
||||
void context_popup( struct gui_window * gw, short x, short y );
|
||||
|
||||
#endif // CTXMENU_H_INCLUDED
|
@ -223,7 +223,9 @@ static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
|
||||
|
||||
static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
|
||||
{
|
||||
LOG(("%s", __FUNCTION__));
|
||||
LOG(("%s", __FUNCTION__));
|
||||
if( input_window == NULL )
|
||||
return;
|
||||
}
|
||||
|
||||
static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
|
||||
@ -320,7 +322,7 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
|
||||
return;
|
||||
kstate = evnt.mkstate;
|
||||
kcode = evnt.keybd;
|
||||
nkc= gem_to_norm( (short)kstate, (short)kcode );
|
||||
nkc= gem_to_norm( (short)kstate, (short)kcode );
|
||||
nks = (nkc & 0xFF00);
|
||||
if( kstate & (K_LSHIFT|K_RSHIFT))
|
||||
kstate |= K_LSHIFT|K_RSHIFT;
|
||||
@ -354,11 +356,11 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
|
||||
} else {
|
||||
/* the accel code hides in the keycode: */
|
||||
if( menu_evnt_tbl[i].accel.keycode != 0) {
|
||||
if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
|
||||
kstate == menu_evnt_tbl[i].accel.mod &&
|
||||
if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
|
||||
kstate == menu_evnt_tbl[i].accel.mod &&
|
||||
menu_evnt_tbl[i].menu_func != NULL) {
|
||||
menu_evnt_tbl[i].menu_func( NULL,
|
||||
menu_evnt_tbl[i].rid,
|
||||
menu_evnt_tbl[i].menu_func( NULL,
|
||||
menu_evnt_tbl[i].rid,
|
||||
MAINMENU, buff
|
||||
);
|
||||
done = true;
|
||||
@ -372,7 +374,7 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
|
||||
}
|
||||
|
||||
/*
|
||||
mode = 0 -> return string ptr
|
||||
mode = 0 -> return string ptr
|
||||
(build from accel definition in s_accelerator accel)
|
||||
mode = 1 -> return ptr to (untranslated) NS accel string, if any
|
||||
*/
|
||||
@ -572,10 +574,10 @@ void bind_global_events( void )
|
||||
spare[1]=' ';
|
||||
if( u != NULL && t != NULL ) {
|
||||
LOG(("Menu Item %s: found NS accelerator, ascii: %c, scancode: %x, mod: %x",
|
||||
m,
|
||||
menu_evnt_tbl[i].accel.ascii,
|
||||
menu_evnt_tbl[i].accel.keycode,
|
||||
menu_evnt_tbl[i].accel.mod
|
||||
m,
|
||||
menu_evnt_tbl[i].accel.ascii,
|
||||
menu_evnt_tbl[i].accel.keycode,
|
||||
menu_evnt_tbl[i].accel.mod
|
||||
));
|
||||
/* Accelerator is defined in menu string: */
|
||||
memcpy((char*)&spare[2], m, u-m-1);
|
||||
@ -583,10 +585,10 @@ void bind_global_events( void )
|
||||
}
|
||||
else if( t != NULL && u == NULL) {
|
||||
LOG(("Menu Item %s: found RSC accelerator, ascii: %c, scancode: %x, mod: %x",
|
||||
m,
|
||||
menu_evnt_tbl[i].accel.ascii,
|
||||
menu_evnt_tbl[i].accel.keycode,
|
||||
menu_evnt_tbl[i].accel.mod
|
||||
m,
|
||||
menu_evnt_tbl[i].accel.ascii,
|
||||
menu_evnt_tbl[i].accel.keycode,
|
||||
menu_evnt_tbl[i].accel.mod
|
||||
));
|
||||
/* Accelerator is defined in struct: */
|
||||
memcpy( (char*)&spare[2], m, strlen(m) );
|
||||
|
69
atari/gui.c
69
atari/gui.c
@ -121,7 +121,7 @@ void gui_poll(bool active)
|
||||
short mx, my, dummy;
|
||||
short aestop;
|
||||
|
||||
evnt.timer = schedule_run();
|
||||
evnt.timer = schedule_run();
|
||||
|
||||
wind_get( 0, WF_TOP, &aestop, &winloc[1], &winloc[2], &winloc[3]);
|
||||
if( winloc[1] != _AESapid ){
|
||||
@ -185,7 +185,7 @@ void gui_poll(bool active)
|
||||
}
|
||||
}
|
||||
if( evnt.timer != 0 && !active ){
|
||||
/* this suits for stuff with lower priority */
|
||||
/* this suits for stuff with lower priority */
|
||||
hotlist_redraw();
|
||||
}
|
||||
}
|
||||
@ -198,7 +198,7 @@ gui_create_browser_window(struct browser_window *bw,
|
||||
struct gui_window *gw=NULL;
|
||||
struct gui_window * gwroot ;
|
||||
short winloc[4];
|
||||
LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
|
||||
LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
|
||||
(int)new_tab
|
||||
));
|
||||
|
||||
@ -363,7 +363,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
|
||||
browser_scroll(w, WA_DNLINE, abs(sy), true );
|
||||
}
|
||||
}
|
||||
return;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ void gui_window_update_extent(struct gui_window *gw)
|
||||
oldx = gw->browser->scroll.current.x;
|
||||
oldy = gw->browser->scroll.current.y;
|
||||
if( gw->browser->bw->current_content != NULL ) {
|
||||
browser_set_content_size( gw,
|
||||
browser_set_content_size( gw,
|
||||
content_get_width(gw->browser->bw->current_content),
|
||||
content_get_height(gw->browser->bw->current_content)
|
||||
);
|
||||
@ -395,7 +395,7 @@ void gui_window_update_extent(struct gui_window *gw)
|
||||
|
||||
void gui_clear_selection(struct gui_window *g)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -540,21 +540,21 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
|
||||
if (w == NULL)
|
||||
return;
|
||||
CMP_BROWSER b = w->browser;
|
||||
if( w->browser->caret.current.g_w > 0 )
|
||||
if( w->browser->caret.current.g_w > 0 )
|
||||
gui_window_remove_caret( w );
|
||||
|
||||
|
||||
w->browser->caret.requested.g_x = x;
|
||||
w->browser->caret.requested.g_y = y;
|
||||
w->browser->caret.requested.g_w = 2;
|
||||
w->browser->caret.requested.g_h = height;
|
||||
w->browser->caret.redraw = true;
|
||||
browser_schedule_redraw_rect(
|
||||
w,
|
||||
x - b->scroll.current.x,
|
||||
y - b->scroll.current.y,
|
||||
w->browser->caret.requested.g_w,
|
||||
w->browser->caret.requested.g_h
|
||||
);
|
||||
browser_schedule_redraw_rect(
|
||||
w,
|
||||
x - b->scroll.current.x,
|
||||
y - b->scroll.current.y,
|
||||
w->browser->caret.requested.g_w,
|
||||
w->browser->caret.requested.g_h
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -580,8 +580,17 @@ gui_window_remove_caret(struct gui_window *w)
|
||||
|
||||
void
|
||||
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
|
||||
{
|
||||
TODO();
|
||||
{
|
||||
/* Untestet, favicon support has been dropped, so this is dead code. */
|
||||
|
||||
/*
|
||||
struct bitmap *icon_bitmap;
|
||||
icon_bitmap = (icon != NULL) ? content_get_bitmap(icon) : NULL;
|
||||
if (icon_bitmap != NULL) {
|
||||
window_set_icon( g, icon_bitmap );
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -702,7 +711,7 @@ bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space)
|
||||
size_t newlen = 0;
|
||||
char * text = NULL;
|
||||
char * text2 = NULL;
|
||||
bool retval;
|
||||
bool retval;
|
||||
int length = 0;
|
||||
if( length_utf8 > 0 && text_utf8 != NULL ) {
|
||||
utf8_to_local_encoding(text_utf8,length_utf8,&text);
|
||||
@ -719,7 +728,7 @@ bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space)
|
||||
text = malloc(length + 2);
|
||||
if( text == NULL ) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
text2 = text;
|
||||
text[length+1] = 0;
|
||||
memset(text, ' ', length+1);
|
||||
@ -727,7 +736,7 @@ bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space)
|
||||
length = strlen(text);
|
||||
if( tmp_clipboard != NULL ) {
|
||||
oldlen = strlen( tmp_clipboard );
|
||||
}
|
||||
}
|
||||
newlen = oldlen + length + 1;
|
||||
if( tmp_clipboard == NULL){
|
||||
tmp_clipboard = malloc(newlen);
|
||||
@ -753,7 +762,7 @@ success:
|
||||
retval = true;
|
||||
|
||||
fin:
|
||||
if( text2 != NULL )
|
||||
if( text2 != NULL )
|
||||
free( text2 );
|
||||
return(retval);
|
||||
|
||||
@ -762,7 +771,7 @@ fin:
|
||||
bool gui_commit_clipboard(void)
|
||||
{
|
||||
int r = scrap_txt_write(&app, tmp_clipboard);
|
||||
return( (r>0)?true:false );
|
||||
return( (r>0)?true:false );
|
||||
}
|
||||
|
||||
|
||||
@ -796,8 +805,8 @@ bool gui_copy_to_clipboard(struct selection *s)
|
||||
if(selection_traverse(s, gui_selection_traverse_handler, NULL)){
|
||||
ret = gui_commit_clipboard();
|
||||
}
|
||||
}
|
||||
gui_empty_clipboard();
|
||||
}
|
||||
gui_empty_clipboard();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -839,7 +848,7 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
|
||||
nserror (*cb)(bool proceed, void *pw), void *cbpw)
|
||||
{
|
||||
LOG((""));
|
||||
|
||||
|
||||
bool bres;
|
||||
/*bres = verify_ssl_form_do(url, certs, num);
|
||||
if( bres )
|
||||
@ -876,7 +885,7 @@ void gui_quit(void)
|
||||
/* send WM_DESTROY to windows purely managed by windom: */
|
||||
|
||||
urldb_save_cookies(option_cookie_file);
|
||||
urldb_save(option_url_file);
|
||||
urldb_save(option_url_file);
|
||||
|
||||
RsrcXtype( 0, rsc_trindex, rsc_ntree);
|
||||
unbind_global_events();
|
||||
@ -957,7 +966,7 @@ char* gui_get_resource_url(const char *filename)
|
||||
char buf[PATH_MAX];
|
||||
int len;
|
||||
char * ret;
|
||||
atari_find_resource((char*)&buf, filename, filename);
|
||||
atari_find_resource((char*)&buf, filename, filename);
|
||||
/* TODO: handle failure? */
|
||||
len = strlen( (char*)&buf ) + 1;
|
||||
return( path_to_url((char*)&buf) );
|
||||
@ -1016,12 +1025,12 @@ static void gui_init(int argc, char** argv)
|
||||
atari_find_resource(buf, "quirks.css", "./res/quirks.css");
|
||||
quirks_stylesheet_url = path_to_url(buf);
|
||||
|
||||
if( strlen(option_url_file) ){
|
||||
if( strlen(option_url_file) ){
|
||||
urldb_load(option_url_file);
|
||||
}
|
||||
if( strlen(option_cookie_file) ){
|
||||
urldb_load_cookies(option_cookie_file);
|
||||
LOG(("Loading cookies from: %s", option_cookie_file ));
|
||||
LOG(("Loading cookies from: %s", option_cookie_file ));
|
||||
}
|
||||
|
||||
if (process_cmdline(argc,argv) != true)
|
||||
@ -1085,7 +1094,7 @@ int main(int argc, char** argv)
|
||||
|
||||
LOG(("ApplExit"));
|
||||
ApplExit();
|
||||
#ifdef WITH_DBG_LOGFILE
|
||||
#ifdef WITH_DBG_LOGFILE
|
||||
fclose(stdout);
|
||||
fclose(stderr);
|
||||
#endif
|
||||
|
13
atari/gui.h
13
atari/gui.h
@ -82,10 +82,13 @@ struct s_focus_info
|
||||
};
|
||||
|
||||
/* defines for data attached to components: */
|
||||
#define CDT_OBJECT 0x004f424aUL
|
||||
#define CDT_OWNER 0x03UL
|
||||
#define CDT_ICON 0x04UL
|
||||
#define CDT_ICON_TYPE 0x05UL
|
||||
#define CDT_OBJECT 0x004f424aUL
|
||||
#define CDT_OWNER 0x03UL
|
||||
#define CDT_ICON 0x04UL
|
||||
#define CDT_ICON_TYPE 0x05UL
|
||||
#define CDT_ICON_TYPE_NONE 0x00UL
|
||||
#define CDT_ICON_TYPE_OBJECT 0x01UL
|
||||
#define CDT_ICON_TYPE_BITMAP 0x02UL
|
||||
|
||||
|
||||
struct gui_window;
|
||||
@ -125,6 +128,8 @@ struct s_gui_win_root
|
||||
struct gui_window {
|
||||
struct s_gui_win_root * root;
|
||||
CMP_BROWSER browser;
|
||||
/* icon to be drawn when iconified, or NULL for default resource. */
|
||||
struct bitmap * icon;
|
||||
struct gui_window *next, *prev;
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,7 @@ void nsatari_search_set_hourglass(bool active, void *p)
|
||||
{
|
||||
SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
|
||||
LOG((""));
|
||||
if( active && current != NULL )
|
||||
if( active && current != NULL )
|
||||
gui_window_set_pointer(s->bw->window, GUI_POINTER_PROGRESS);
|
||||
else
|
||||
gui_window_set_pointer(s->bw->window, GUI_POINTER_DEFAULT);
|
||||
@ -140,8 +140,8 @@ static int apply_form( WINDOW * win, struct s_search_form_state * s )
|
||||
}
|
||||
return ( 0 );
|
||||
|
||||
error:
|
||||
s->flags = SEARCH_FLAG_FORWARDS;
|
||||
error:
|
||||
s->flags = SEARCH_FLAG_FORWARDS;
|
||||
/* s->forward = true; */
|
||||
strncpy((char*)&s->text[0], "", 31 );
|
||||
return( 1 );
|
||||
@ -159,7 +159,7 @@ static bool form_changed( WINDOW * w )
|
||||
assert( s != NULL && obj != NULL );
|
||||
uint32_t flags_old = s->state.flags;
|
||||
apply_form(w, &cur);
|
||||
|
||||
|
||||
/* adjust the forward flag, it should not init an new search */
|
||||
flags_old |= SEARCH_FLAG_FORWARDS;
|
||||
cur.flags |= SEARCH_FLAG_FORWARDS;
|
||||
@ -173,12 +173,12 @@ static bool form_changed( WINDOW * w )
|
||||
return ( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
||||
static void __CDECL evnt_bt_srch_click( WINDOW *win, int index, int unused, void *unused2)
|
||||
static void __CDECL evnt_bt_srch_click( WINDOW *win, int index, int unused, void *unused2)
|
||||
{
|
||||
|
||||
bool fwd;
|
||||
@ -186,7 +186,7 @@ static void __CDECL evnt_bt_srch_click( WINDOW *win, int index, int unused, void
|
||||
OBJECT * obj = ObjcTree(OC_FORM, s->formwind );
|
||||
search_flags_t flags = 0;
|
||||
|
||||
ObjcChange( OC_FORM, win, index, ~SELECTED , TRUE);
|
||||
ObjcChange(OC_FORM, win, index, ~SELECTED , TRUE);
|
||||
if( form_changed(win) ){
|
||||
browser_window_search_destroy_context(s->bw);
|
||||
apply_form( win, &s->state );
|
||||
@ -194,32 +194,32 @@ static void __CDECL evnt_bt_srch_click( WINDOW *win, int index, int unused, void
|
||||
/* get search direction manually: */
|
||||
if( (obj[SEARCH_CB_FWD].ob_state & SELECTED) != 0 )
|
||||
s->state.flags |= SEARCH_FLAG_FORWARDS;
|
||||
else
|
||||
else
|
||||
s->state.flags &= (~SEARCH_FLAG_FORWARDS);
|
||||
}
|
||||
if( browser_window_search_verify_new(s->bw, &nsatari_search_callbacks, s) ){
|
||||
browser_window_search_step(s->bw, s->state.flags, ObjcString( obj, SEARCH_TB_SRCH, NULL ) );
|
||||
browser_window_search_step(s->bw, s->state.flags, ObjcString( obj, SEARCH_TB_SRCH, NULL ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void __CDECL evnt_cb_click( WINDOW *win, int index, int unused, void *unused2)
|
||||
static void __CDECL evnt_cb_click( WINDOW *win, int index, int unused, void *unused2)
|
||||
{
|
||||
|
||||
short newstate;
|
||||
OBJECT * obj = ObjcTree(OC_FORM, get_search_session(win)->formwind );
|
||||
}
|
||||
|
||||
static void __CDECL evnt_close( WINDOW *win, short buff[8])
|
||||
static void __CDECL evnt_close( WINDOW *win, short buff[8])
|
||||
{
|
||||
/* Free Search Contexts */
|
||||
/* todo: destroy search context, if any? */
|
||||
SEARCH_FORM_SESSION s = get_search_session(win);
|
||||
if( s != NULL ){
|
||||
if( s != NULL ){
|
||||
destroy_search_session( s );
|
||||
}
|
||||
current = NULL;
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0,0,0,0 );
|
||||
ApplWrite( _AESapid, WM_DESTROY, win->handle, 0,0,0,0 );
|
||||
}
|
||||
|
||||
void search_destroy( struct gui_window * gw )
|
||||
@ -242,7 +242,7 @@ SEARCH_FORM_SESSION open_browser_search( struct gui_window * gw )
|
||||
OBJECT * tree = get_tree(SEARCH);
|
||||
if( tree == NULL ){
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
sfs = calloc(1, sizeof(struct s_search_form_session));
|
||||
if( sfs == NULL )
|
||||
return( NULL );
|
||||
@ -254,7 +254,7 @@ SEARCH_FORM_SESSION open_browser_search( struct gui_window * gw )
|
||||
current = sfs;
|
||||
sfs->bw = gw->browser->bw;
|
||||
sfs->formwind = mt_FormCreate( &app, tree, WAT_FORM,
|
||||
NULL, title,
|
||||
NULL, title,
|
||||
NULL, true, false);
|
||||
|
||||
ObjcAttachFormFunc( sfs->formwind, SEARCH_BT_SEARCH, evnt_bt_srch_click, NULL);
|
||||
@ -266,5 +266,5 @@ SEARCH_FORM_SESSION open_browser_search( struct gui_window * gw )
|
||||
strncpy( ObjcString( tree, SEARCH_TB_SRCH, NULL ), "", SEARCH_MAX_SLEN);
|
||||
|
||||
return( current );
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user