mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-26 14:07:05 +03:00
Toolbar is now finished, started work on browser redraw/scrolling.
This commit is contained in:
parent
67d4da38ad
commit
ea025e6008
@ -581,12 +581,12 @@ bool browser_redraw_required( struct gui_window * gw)
|
||||
/* coords are relative to the framebuffer */
|
||||
void browser_schedule_redraw_rect(struct gui_window * gw, short x, short y, short w, short h)
|
||||
{
|
||||
if( x < 0 ){
|
||||
if(x < 0){
|
||||
w += x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if( y < 0 ) {
|
||||
if(y < 0) {
|
||||
h += y;
|
||||
y = 0;
|
||||
}
|
||||
@ -612,7 +612,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
|
||||
if( y0 > work.g_h )
|
||||
return;
|
||||
|
||||
redraw_slot_schedule( &b->redraw, x0, y0, x1, y1 );
|
||||
redraw_slot_schedule(&b->redraw, x0, y0, x1, y1, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -150,8 +150,8 @@ void __CDECL global_evnt_keybd(WINDOW * win, short buff[8], void * data)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!done)
|
||||
deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
|
||||
//if(!done)
|
||||
// deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
|
||||
}
|
||||
|
||||
|
||||
|
20
atari/gui.c
20
atari/gui.c
@ -173,9 +173,7 @@ void gui_poll(bool active)
|
||||
}
|
||||
|
||||
if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
|
||||
printf("key: %d, %d\n", aes_event_out.emo_kreturn,
|
||||
aes_event_out.emo_kmeta);
|
||||
nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
|
||||
uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
|
||||
(short)aes_event_out.emo_kreturn);
|
||||
deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
|
||||
aes_event_out.emo_kmeta, nkc);
|
||||
@ -215,7 +213,6 @@ gui_create_browser_window(struct browser_window *bw,
|
||||
window_set_active_gui_window(gw->root, gw);
|
||||
window_open(gw->root, pos );
|
||||
/* Recalculate windows browser area now */
|
||||
toolbar_update_buttons(gw->root->toolbar, gw->browser->bw, -1);
|
||||
input_window = gw;
|
||||
/* TODO:... this line: placeholder to create a local history widget ... */
|
||||
}
|
||||
@ -427,10 +424,14 @@ 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,
|
||||
content_get_width(gw->browser->bw->current_content),
|
||||
content_get_height(gw->browser->bw->current_content)
|
||||
);
|
||||
// TODO: store content size!
|
||||
if(window_get_active_gui_window(gw->root) == gw){
|
||||
window_set_content_size( gw->root,
|
||||
content_get_width(gw->browser->bw->current_content),
|
||||
content_get_height(gw->browser->bw->current_content)
|
||||
);
|
||||
window_update_back_forward(gw->root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -586,9 +587,6 @@ void gui_window_stop_throbber(struct gui_window *w)
|
||||
|
||||
toolbar_set_throbber_state(w->root->toolbar, false);
|
||||
|
||||
/* refresh toolbar buttons: */
|
||||
toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1);
|
||||
|
||||
rendering = false;
|
||||
}
|
||||
|
||||
|
@ -52,45 +52,48 @@ static inline bool rect_intersect( struct rect * box1, struct rect * box2 )
|
||||
}
|
||||
|
||||
|
||||
void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area)
|
||||
void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area,
|
||||
bool force)
|
||||
{
|
||||
redraw_slot_schedule(slots, area->g_x, area->g_y,
|
||||
area->g_x + area->g_w, area->g_y + area->g_h);
|
||||
area->g_x + area->g_w, area->g_y + area->g_h, force);
|
||||
}
|
||||
|
||||
/*
|
||||
schedule redraw coords.
|
||||
*/
|
||||
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0,
|
||||
short x1, short y1)
|
||||
short x1, short y1, bool force)
|
||||
{
|
||||
int i;
|
||||
int i = 0;
|
||||
struct rect area;
|
||||
|
||||
area.x0 = x0;
|
||||
area.y0 = y0;
|
||||
area.x1 = x1;
|
||||
area.y1 = y1;
|
||||
|
||||
for( i=0; i<slots->areas_used; i++) {
|
||||
if( slots->areas[i].x0 <= x0
|
||||
&& slots->areas[i].x1 >= x1
|
||||
&& slots->areas[i].y0 <= y0
|
||||
&& slots->areas[i].y1 >= y1 ){
|
||||
/* the area is already queued for redraw */
|
||||
return;
|
||||
} else {
|
||||
if( rect_intersect(&slots->areas[i], &area ) ){
|
||||
slots->areas[i].x0 = MIN(slots->areas[i].x0, x0);
|
||||
slots->areas[i].y0 = MIN(slots->areas[i].y0, y0);
|
||||
slots->areas[i].x1 = MAX(slots->areas[i].x1, x1);
|
||||
slots->areas[i].y1 = MAX(slots->areas[i].y1, y1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (force == false) {
|
||||
for (i=0; i<slots->areas_used; i++) {
|
||||
if (slots->areas[i].x0 <= x0
|
||||
&& slots->areas[i].x1 >= x1
|
||||
&& slots->areas[i].y0 <= y0
|
||||
&& slots->areas[i].y1 >= y1) {
|
||||
/* the area is already queued for redraw */
|
||||
return;
|
||||
} else {
|
||||
if (rect_intersect(&slots->areas[i], &area )) {
|
||||
slots->areas[i].x0 = MIN(slots->areas[i].x0, x0);
|
||||
slots->areas[i].y0 = MIN(slots->areas[i].y0, y0);
|
||||
slots->areas[i].x1 = MAX(slots->areas[i].x1, x1);
|
||||
slots->areas[i].y1 = MAX(slots->areas[i].y1, y1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( slots->areas_used < slots->size ) {
|
||||
if (slots->areas_used < slots->size) {
|
||||
slots->areas[slots->areas_used].x0 = x0;
|
||||
slots->areas[slots->areas_used].x1 = x1;
|
||||
slots->areas[slots->areas_used].y0 = y0;
|
||||
|
@ -40,13 +40,14 @@ struct s_redrw_slots
|
||||
{
|
||||
struct rect areas[MAX_REDRW_SLOTS];
|
||||
short size;
|
||||
short areas_used;
|
||||
short volatile areas_used;
|
||||
};
|
||||
|
||||
void redraw_slots_init(struct s_redrw_slots * slots, short size);
|
||||
void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0,
|
||||
short x1, short y1);
|
||||
void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area);
|
||||
short x1, short y1, bool force);
|
||||
void redraw_slot_schedule_grect(struct s_redrw_slots * slots, GRECT *area,
|
||||
bool force);
|
||||
void redraw_slots_remove_area(struct s_redrw_slots * slots, int i);
|
||||
void redraw_slots_free(struct s_redrw_slots * slots);
|
||||
|
||||
|
365
atari/rootwin.c
365
atari/rootwin.c
@ -69,9 +69,11 @@ struct rootwin_data_s {
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Static module methods: */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void redraw(GUIWIN *win, short msg[8]);
|
||||
static void resized(GUIWIN *win);
|
||||
static void file_dropped(GUIWIN *win, short msg[8]);
|
||||
static void redraw(ROOTWIN *rootwin, short msg[8]);
|
||||
static void resized(ROOTWIN *rootwin);
|
||||
static void file_dropped(ROOTWIN *rootwin, short msg[8]);
|
||||
static short key_input(ROOTWIN * rootwin, unsigned short kcode,
|
||||
unsigned short kstate, unsigned short nkc);
|
||||
|
||||
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 );
|
||||
@ -79,14 +81,22 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data
|
||||
#define FIND_NS_GUI_WINDOW(w) \
|
||||
find_guiwin_by_aes_handle(guiwin_get_handle(w));
|
||||
|
||||
static bool redraw_active = false;
|
||||
|
||||
static const struct redraw_context rootwin_rdrw_ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &atari_plotters
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Module public functions: */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
{
|
||||
struct gui_window * gw;
|
||||
|
||||
short retval = 0;
|
||||
struct rootwin_data_s * data = guiwin_get_user_data(win);
|
||||
|
||||
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
|
||||
@ -95,18 +105,18 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
switch (msg[0]) {
|
||||
|
||||
case WM_REDRAW:
|
||||
redraw(win, msg);
|
||||
redraw(data->rootwin, msg);
|
||||
break;
|
||||
|
||||
case WM_REPOSED:
|
||||
case WM_SIZED:
|
||||
case WM_MOVED:
|
||||
case WM_FULLED:
|
||||
resized(win);
|
||||
resized(data->rootwin);
|
||||
break;
|
||||
|
||||
case WM_ICONIFY:
|
||||
data = guiwin_get_user_data(win);
|
||||
|
||||
if( input_window->root == data->rootwin) {
|
||||
input_window = NULL;
|
||||
}
|
||||
@ -115,27 +125,26 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
case WM_TOPPED:
|
||||
case WM_NEWTOP:
|
||||
case WM_UNICONIFY:
|
||||
data = guiwin_get_user_data(win);
|
||||
input_window = data->rootwin->active_gui_window;
|
||||
break;
|
||||
|
||||
case WM_CLOSED:
|
||||
// TODO: this needs to iterate through all gui windows and
|
||||
// check if the rootwin is this window...
|
||||
data = guiwin_get_user_data(win);
|
||||
gw = data->rootwin->active_gui_window;
|
||||
if( gw != NULL ) {
|
||||
browser_window_destroy(gw->browser->bw);
|
||||
if (data->rootwin->active_gui_window != NULL) {
|
||||
browser_window_destroy(
|
||||
data->rootwin->active_gui_window->browser->bw);
|
||||
}
|
||||
break;
|
||||
|
||||
case AP_DRAGDROP:
|
||||
file_dropped(win, msg);
|
||||
file_dropped(data->rootwin, msg);
|
||||
break;
|
||||
|
||||
case WM_TOOLBAR:
|
||||
printf("toolbar click at %d,%d (obj: %d)!\n", ev_out->emo_mouse.p_x,
|
||||
ev_out->emo_mouse.p_y, msg[4]);
|
||||
toolbar_mouse_input(data->rootwin->toolbar, msg[4]);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -143,8 +152,13 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
}
|
||||
}
|
||||
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
|
||||
printf("root win keybd\n");
|
||||
|
||||
// handle key
|
||||
uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
|
||||
(short)ev_out->emo_kreturn);
|
||||
retval = key_input(data->rootwin, ev_out->emo_kreturn,
|
||||
ev_out->emo_kmeta, nkc);
|
||||
|
||||
}
|
||||
if( (ev_out->emo_events & MU_TIMER) != 0 ) {
|
||||
// handle_timer();
|
||||
@ -157,7 +171,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
//handle_mbutton(gw, ev_out);
|
||||
}
|
||||
|
||||
return(0);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
||||
@ -205,6 +219,9 @@ int window_create(struct gui_window * gw,
|
||||
struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
|
||||
data->rootwin = gw->root;
|
||||
guiwin_set_user_data(gw->root->win, (void*)data);
|
||||
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(gw->root->win);
|
||||
slid->y_unit_px = 16;
|
||||
slid->x_unit_px = 16;
|
||||
|
||||
/* create toolbar component: */
|
||||
guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
|
||||
@ -303,6 +320,8 @@ void window_open(ROOTWIN *rootwin, GRECT pos)
|
||||
{
|
||||
GRECT br, g;
|
||||
|
||||
assert(rootwin->active_gui_window != NULL);
|
||||
|
||||
short aes_handle = guiwin_get_handle(rootwin->win);
|
||||
wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
|
||||
wind_set_str(aes_handle, WF_NAME, (char *)"");
|
||||
@ -312,7 +331,9 @@ void window_open(ROOTWIN *rootwin, GRECT pos)
|
||||
sb_attach(rootwin->statusbar, rootwin->active_gui_window);
|
||||
}
|
||||
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &g);
|
||||
toolbar_set_attached(rootwin->toolbar, true);
|
||||
toolbar_set_dimensions(rootwin->toolbar, &g);
|
||||
window_update_back_forward(rootwin);
|
||||
/*TBD: get already present content and set size? */
|
||||
input_window = rootwin->active_gui_window;
|
||||
window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
|
||||
@ -347,6 +368,17 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
|
||||
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
|
||||
}
|
||||
|
||||
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
|
||||
{
|
||||
GRECT area;
|
||||
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(rootwin->win);
|
||||
|
||||
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &area);
|
||||
slid->x_units = (width/slid->x_unit_px);
|
||||
slid->y_units = (height/slid->y_unit_px);
|
||||
guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
|
||||
}
|
||||
|
||||
/* set focus to an arbitary element */
|
||||
void window_set_focus(struct s_gui_win_root *rootwin,
|
||||
enum focus_element_type type, void * element)
|
||||
@ -381,6 +413,7 @@ void window_set_focus(struct s_gui_win_root *rootwin,
|
||||
bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
|
||||
{
|
||||
assert(rootwin != NULL);
|
||||
|
||||
if (rootwin->focus.type == URL_WIDGET) {
|
||||
return true;
|
||||
}
|
||||
@ -419,6 +452,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
|
||||
}
|
||||
}
|
||||
rootwin->active_gui_window = gw;
|
||||
|
||||
window_set_icon(rootwin, gw->icon);
|
||||
window_set_stauts(rootwin, gw->status);
|
||||
window_set_title(rootwin, gw->title);
|
||||
@ -474,34 +508,92 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Schedule an redraw area, redraw requests during redraw are
|
||||
* not optimized (merged) into other areas, so that the redraw
|
||||
* functions can spot the change.
|
||||
*
|
||||
*/
|
||||
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
|
||||
{
|
||||
GRECT work;
|
||||
|
||||
|
||||
//dbg_grect("window_schedule_redraw_grect input ", area);
|
||||
|
||||
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
|
||||
rc_intersect(area, &work);
|
||||
redraw_slot_schedule_grect(&rootwin->redraw_slots, &work);
|
||||
|
||||
dbg_grect("window_schedule_redraw_grect intersection ", &work);
|
||||
|
||||
redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
|
||||
}
|
||||
|
||||
/*
|
||||
bool window_requires_redraw(ROOTWIN * rootwin)
|
||||
static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
|
||||
GRECT *clip,
|
||||
struct guiwin_scroll_info_s * slid,
|
||||
struct browser_window *bw)
|
||||
{
|
||||
if (rootwin->redraw_slots.areas_used > 0)
|
||||
return(true);
|
||||
|
||||
return(false);
|
||||
struct rect redraw_area;
|
||||
GRECT content_area_rel;
|
||||
|
||||
if(bw->window->browser->reformat_pending){
|
||||
browser_window_reformat(bw, true, content_area->g_w,
|
||||
content_area->g_h);
|
||||
bw->window->browser->reformat_pending = false;
|
||||
//return;
|
||||
}
|
||||
|
||||
//dbg_grect("browser redraw, content area", content_area);
|
||||
//dbg_grect("browser redraw, content clip", clip);
|
||||
|
||||
plot_set_dimensions(content_area->g_x, content_area->g_y,
|
||||
content_area->g_w, content_area->g_h);
|
||||
|
||||
|
||||
/* first, we make the coords relative to the content area: */
|
||||
content_area_rel.g_x = clip->g_x - content_area->g_x;
|
||||
content_area_rel.g_y = clip->g_y - content_area->g_y;
|
||||
content_area_rel.g_w = clip->g_w;
|
||||
content_area_rel.g_h = clip->g_h;
|
||||
|
||||
if (content_area_rel.g_x < 0) {
|
||||
content_area_rel.g_w += content_area_rel.g_x;
|
||||
content_area_rel.g_x = 0;
|
||||
}
|
||||
|
||||
if (content_area_rel.g_y < 0) {
|
||||
content_area_rel.g_h += content_area_rel.g_y;
|
||||
content_area_rel.g_y = 0;
|
||||
}
|
||||
|
||||
dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
|
||||
|
||||
redraw_area.x0 = content_area_rel.g_x;
|
||||
redraw_area.y0 = content_area_rel.g_y;
|
||||
redraw_area.x1 = content_area_rel.g_x + content_area_rel.g_w;
|
||||
redraw_area.y1 = content_area_rel.g_y + content_area_rel.g_h;
|
||||
|
||||
plot_clip(&redraw_area);
|
||||
|
||||
browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
|
||||
-(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx );
|
||||
}
|
||||
*/
|
||||
|
||||
void window_process_redraws(ROOTWIN * rootwin)
|
||||
{
|
||||
GRECT work, visible_ro, tb_area = {0,0,0,0};
|
||||
GRECT work, visible_ro, tb_area, content_area;
|
||||
short aes_handle, i;
|
||||
bool toolbar_rdrw_required;
|
||||
struct guiwin_scroll_info_s *slid =NULL;
|
||||
|
||||
redraw_active = true;
|
||||
|
||||
aes_handle = guiwin_get_handle(rootwin->win);
|
||||
|
||||
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
|
||||
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
|
||||
|
||||
while(plot_lock() == false);
|
||||
|
||||
@ -513,24 +605,34 @@ void window_process_redraws(ROOTWIN * rootwin)
|
||||
// that way we don't have to loop over again...
|
||||
for(i=0; i<rootwin->redraw_slots.areas_used; i++){
|
||||
|
||||
GRECT rdrw_area = {
|
||||
GRECT rdrw_area_ro = {
|
||||
rootwin->redraw_slots.areas[i].x0,
|
||||
rootwin->redraw_slots.areas[i].y0,
|
||||
rootwin->redraw_slots.areas[i].x1 +
|
||||
rootwin->redraw_slots.areas[i].x0,
|
||||
rootwin->redraw_slots.areas[i].y1 +
|
||||
rootwin->redraw_slots.areas[i].y0
|
||||
rootwin->redraw_slots.areas[i].x1 -
|
||||
rootwin->redraw_slots.areas[i].x0,
|
||||
rootwin->redraw_slots.areas[i].y1 -
|
||||
rootwin->redraw_slots.areas[i].y0
|
||||
};
|
||||
GRECT visible = visible_ro;
|
||||
rc_intersect(&visible_ro, &rdrw_area_ro);
|
||||
GRECT rdrw_area = rdrw_area_ro;
|
||||
|
||||
rc_intersect(&rdrw_area, &visible);
|
||||
if (rc_intersect(&tb_area, &visible)) {
|
||||
toolbar_redraw(rootwin->toolbar, &visible);
|
||||
if (rc_intersect(&tb_area, &rdrw_area)) {
|
||||
toolbar_redraw(rootwin->toolbar, &rdrw_area);
|
||||
}
|
||||
|
||||
rdrw_area = rdrw_area_ro;
|
||||
if (rc_intersect(&content_area, &rdrw_area)) {
|
||||
if(slid == NULL)
|
||||
slid = guiwin_get_scroll_info(rootwin->win);
|
||||
window_redraw_content(rootwin, &content_area, &rdrw_area, slid,
|
||||
rootwin->active_gui_window->browser->bw);
|
||||
}
|
||||
|
||||
}
|
||||
wind_get_grect(aes_handle, WF_NEXTXYWH, &visible_ro);
|
||||
}
|
||||
rootwin->redraw_slots.areas_used = 0;
|
||||
redraw_active = false;
|
||||
|
||||
plot_unlock();
|
||||
}
|
||||
@ -569,101 +671,46 @@ static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
|
||||
browser_scroll( gw, buff[4], value, abs );
|
||||
}
|
||||
|
||||
//
|
||||
//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];
|
||||
// char name[DD_NAMEMAX];
|
||||
// char *buff=NULL;
|
||||
// int dd_hdl;
|
||||
// int dd_msg; /* pipe-handle */
|
||||
// long size;
|
||||
// char ext[32];
|
||||
// short mx,my,bmstat,mkstat;
|
||||
// graf_mkstate(&mx, &my, &bmstat, &mkstat);
|
||||
//
|
||||
// if( gw == NULL )
|
||||
// return;
|
||||
// if( (win->status & WS_ICONIFY))
|
||||
// return;
|
||||
//
|
||||
// dd_hdl = ddopen( wbuff[7], DD_OK);
|
||||
// if( dd_hdl<0)
|
||||
// return; /* pipe not open */
|
||||
// memset( ext, 0, 32);
|
||||
// strcpy( ext, "ARGS");
|
||||
// dd_msg = ddsexts( dd_hdl, ext);
|
||||
// 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 )
|
||||
// goto error;
|
||||
// if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
|
||||
// ddreply(dd_hdl, DD_OK);
|
||||
// buff = (char*)malloc(sizeof(char)*(size+1));
|
||||
// if (buff != NULL) {
|
||||
// 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
|
||||
// ));
|
||||
// {
|
||||
// LGRECT bwrect;
|
||||
// struct browser_window * bw = gw->browser->bw;
|
||||
// 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) )
|
||||
// return;
|
||||
//
|
||||
// utf8_convert_ret ret;
|
||||
// char *utf8_fn;
|
||||
//
|
||||
// ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
|
||||
// if (ret != UTF8_CONVERT_OK) {
|
||||
// free(buff);
|
||||
// /* A bad encoding should never happen */
|
||||
// LOG(("utf8_from_local_encoding failed"));
|
||||
// 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 );
|
||||
// free(utf8_fn);
|
||||
// free(buff);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//error:
|
||||
// ddclose( dd_hdl);
|
||||
//}
|
||||
|
||||
static short key_input(ROOTWIN *rootwin, unsigned short kcode, unsigned short kstate,
|
||||
unsigned short nkc)
|
||||
{
|
||||
bool done = false;
|
||||
struct gui_window * gw = window_get_active_gui_window(rootwin);
|
||||
struct gui_window * gw_tmp;
|
||||
|
||||
if( gw == NULL )
|
||||
return(false);
|
||||
|
||||
if( kstate & (K_LSHIFT|K_RSHIFT))
|
||||
kstate |= K_LSHIFT|K_RSHIFT;
|
||||
|
||||
if(window_url_widget_has_focus((void*)gw->root)) {
|
||||
/* make sure we report for the root window and report...: */
|
||||
done = toolbar_key_input(gw->root->toolbar, nkc);
|
||||
} else {
|
||||
gw_tmp = window_list;
|
||||
/* search for active browser component: */
|
||||
while( gw_tmp != NULL && done == false ) {
|
||||
/* todo: only handle when input_window == ontop */
|
||||
if( window_widget_has_focus(input_window->root, BROWSER,
|
||||
(void*)gw_tmp->browser)) {
|
||||
done = browser_input(gw_tmp, nkc);
|
||||
break;
|
||||
} else {
|
||||
gw_tmp = gw_tmp->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
return((done==true) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
|
||||
{
|
||||
LOG(("%s\n", __FUNCTION__ ));
|
||||
}
|
||||
|
||||
//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data )
|
||||
//{
|
||||
// struct gui_window * gw = (struct gui_window *) data ;
|
||||
// if( gw != NULL ) {
|
||||
// browser_window_destroy( gw->browser->bw );
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//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 ));
|
||||
// assert( input_window != NULL );
|
||||
//}
|
||||
|
||||
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
|
||||
{
|
||||
@ -691,46 +738,35 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
|
||||
browser_scroll( gw, WA_LFPAGE, abs(dx), false );
|
||||
}
|
||||
|
||||
static void redraw(GUIWIN *win, short msg[8])
|
||||
static void redraw(ROOTWIN *rootwin, short msg[8])
|
||||
{
|
||||
short handle;
|
||||
struct rootwin_data_s *data = guiwin_get_user_data(win);
|
||||
ROOTWIN *rootwin = data->rootwin;
|
||||
|
||||
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
|
||||
|
||||
if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
|
||||
if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
|
||||
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
|
||||
window_redraw_favicon(rootwin, &clip);
|
||||
} else {
|
||||
window_schedule_redraw_grect(rootwin, &clip);
|
||||
|
||||
// TODO: remove this call when browser redraw is implemented:
|
||||
guiwin_clear(win);
|
||||
}
|
||||
}
|
||||
|
||||
static void resized(GUIWIN *win)
|
||||
static void resized(ROOTWIN *rootwin)
|
||||
{
|
||||
GRECT g;
|
||||
short handle;
|
||||
struct gui_window *gw;
|
||||
struct rootwin_data_s *data = guiwin_get_user_data(win);
|
||||
ROOTWIN *rootwin = data->rootwin;
|
||||
|
||||
printf("resized win: %p\n", win);
|
||||
handle = guiwin_get_handle(rootwin->win);
|
||||
gw = window_get_active_gui_window(rootwin);
|
||||
|
||||
handle = guiwin_get_handle(win);
|
||||
|
||||
printf("resized handle: %d\n", handle);
|
||||
gw = data->rootwin->active_gui_window;
|
||||
//printf("resized...\n");
|
||||
|
||||
assert(gw != NULL);
|
||||
|
||||
printf("resized gw: %p\n", gw);
|
||||
|
||||
if(gw == NULL)
|
||||
return;
|
||||
//assert( gw != NULL );
|
||||
|
||||
wind_get_grect(handle, WF_CURRXYWH, &g);
|
||||
|
||||
@ -739,6 +775,7 @@ static void resized(GUIWIN *win)
|
||||
/* Reformat will happen when redraw is processed: */
|
||||
// TODO: call reformat directly, this was introduced because
|
||||
// of bad AES knowledge, it's ok to call it directly here...
|
||||
//printf("reformat......\n");
|
||||
rootwin->active_gui_window->browser->reformat_pending = true;
|
||||
}
|
||||
}
|
||||
@ -747,11 +784,11 @@ static void resized(GUIWIN *win)
|
||||
// }
|
||||
|
||||
rootwin->loc = g;
|
||||
guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &g);
|
||||
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &g);
|
||||
toolbar_set_dimensions(rootwin->toolbar, &g);
|
||||
}
|
||||
|
||||
static void __CDECL file_dropped(GUIWIN *win, short msg[8])
|
||||
static void __CDECL file_dropped(ROOTWIN *rootwin, short msg[8])
|
||||
{
|
||||
char file[DD_NAMEMAX];
|
||||
char name[DD_NAMEMAX];
|
||||
@ -765,12 +802,12 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
|
||||
|
||||
graf_mkstate(&mx, &my, &bmstat, &mkstat);
|
||||
|
||||
gw = FIND_NS_GUI_WINDOW(win);
|
||||
gw = window_get_active_gui_window(rootwin);
|
||||
|
||||
if( gw == NULL )
|
||||
return;
|
||||
|
||||
if(guiwin_get_state(win) & GW_STATUS_ICONIFIED)
|
||||
if(guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED)
|
||||
return;
|
||||
|
||||
dd_hdl = ddopen( msg[7], DD_OK);
|
||||
@ -797,7 +834,7 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
|
||||
{
|
||||
GRECT bwrect;
|
||||
struct browser_window * bw = gw->browser->bw;
|
||||
browser_get_rect( gw, BR_CONTENT, &bwrect );
|
||||
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) )
|
||||
@ -828,41 +865,3 @@ error:
|
||||
ddclose( dd_hdl);
|
||||
}
|
||||
|
||||
///* 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;
|
||||
//
|
||||
// wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
|
||||
// gw = (struct gui_window *)data;
|
||||
//
|
||||
// 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 );
|
||||
// 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 );
|
||||
// }
|
||||
// } else {
|
||||
// if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
|
||||
// mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
|
||||
// browser_update_rects( gw );
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -65,14 +65,17 @@ bool window_widget_has_focus(struct s_gui_win_root * rootwin,
|
||||
bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
|
||||
void window_set_url(struct s_gui_win_root * rootwin, const char * text);
|
||||
void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
|
||||
void window_set_title(struct s_gui_win_root * rootwin, char * text);
|
||||
void window_set_title(struct s_gui_win_root * rootwin, char * text);
|
||||
void window_set_content_size(struct s_gui_win_root * rootwin, int w, int h);
|
||||
void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
|
||||
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
|
||||
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
|
||||
void window_process_redraws(ROOTWIN * rootwin);
|
||||
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
|
||||
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
|
||||
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
|
||||
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
|
||||
bool window_key_input(unsigned short kcode, unsigned short kstate,
|
||||
unsigned short nkc);
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
327
atari/toolbar.c
327
atari/toolbar.c
@ -81,7 +81,7 @@ struct s_tb_button
|
||||
void (*cb_click)(struct s_toolbar *tb);
|
||||
hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
|
||||
struct s_toolbar *owner;
|
||||
short state;
|
||||
enum e_toolbar_button_states state;
|
||||
short index;
|
||||
GRECT area;
|
||||
};
|
||||
@ -92,6 +92,7 @@ extern void * h_gem_rsrc;
|
||||
extern struct gui_window * input_window;
|
||||
extern long atari_plot_flags;
|
||||
extern int atari_plot_vdi_handle;
|
||||
extern EVMULT_OUT aes_event_out;
|
||||
|
||||
static OBJECT * aes_toolbar = NULL;
|
||||
static OBJECT * throbber_form = NULL;
|
||||
@ -185,6 +186,21 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
|
||||
static nserror toolbar_icon_callback( hlcache_handle *handle,
|
||||
const hlcache_event *event, void *pw );
|
||||
|
||||
/**
|
||||
* Find a button for a specific resource ID
|
||||
*/
|
||||
static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < tb->btcnt) {
|
||||
if (tb->buttons[i].rsc_id == rsc_id) {
|
||||
return(&tb->buttons[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for textarea redraw
|
||||
*/
|
||||
@ -194,14 +210,16 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
|
||||
GRECT area;
|
||||
struct s_toolbar * tb = (struct s_toolbar *)data;
|
||||
|
||||
if (tb->attached == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
|
||||
area.g_x += x;
|
||||
area.g_y += y;
|
||||
area.g_w = w;
|
||||
area.g_h = h;
|
||||
|
||||
dbg_grect("toolbar redraw request", &area);
|
||||
|
||||
dbg_grect("tb_txt_request_redraw", &area);
|
||||
window_schedule_redraw_grect(tb->owner, &area);
|
||||
return;
|
||||
}
|
||||
@ -354,6 +372,7 @@ void toolbar_destroy(struct s_toolbar *tb)
|
||||
|
||||
static void toolbar_reflow(struct s_toolbar *tb)
|
||||
{
|
||||
int i;
|
||||
|
||||
// position toolbar areas:
|
||||
aes_toolbar->ob_x = tb->area.g_x;
|
||||
@ -382,14 +401,27 @@ static void toolbar_reflow(struct s_toolbar *tb)
|
||||
((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_height
|
||||
- throbber_form[tb->throbber.index].ob_height) >> 1);
|
||||
|
||||
|
||||
// set button states:
|
||||
for (i=0; i < tb->btcnt; i++ ) {
|
||||
if (tb->buttons[i].state == button_off) {
|
||||
aes_toolbar[tb->buttons[i].rsc_id].ob_state |= OS_DISABLED;
|
||||
}
|
||||
else if (tb->buttons[i].state == button_on) {
|
||||
aes_toolbar[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
|
||||
}
|
||||
}
|
||||
tb->reflow = false;
|
||||
// TODO: iterate through all other toolbars and set reflow = true
|
||||
}
|
||||
|
||||
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
|
||||
{
|
||||
GRECT area;
|
||||
|
||||
if (tb->attached == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(tb->reflow == true)
|
||||
toolbar_reflow(tb);
|
||||
|
||||
@ -414,9 +446,6 @@ void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
|
||||
r.x1 = r.x0 + area.g_w;
|
||||
plot_set_dimensions(url_area.g_x, url_area.g_y, url_area.g_w,
|
||||
url_area.g_h);
|
||||
textarea_set_dimensions(tb->url.textarea,
|
||||
aes_toolbar[TOOLBAR_URL_AREA].ob_width,
|
||||
20);
|
||||
textarea_redraw(tb->url.textarea, 0, 0, &r, &toolbar_rdrw_ctx);
|
||||
}
|
||||
}
|
||||
@ -426,12 +455,89 @@ void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
|
||||
short button)
|
||||
{
|
||||
LOG((""));
|
||||
|
||||
struct s_tb_button * bt;
|
||||
bool enable = false;
|
||||
GRECT area;
|
||||
|
||||
assert(bw != NULL);
|
||||
|
||||
if (button == TOOLBAR_BT_BACK || button <= 0 ) {
|
||||
bt = find_button(tb, TOOLBAR_BT_BACK);
|
||||
enable = browser_window_back_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
if (button == TOOLBAR_BT_HOME || button <= 0 ){
|
||||
|
||||
}
|
||||
|
||||
if( button == TOOLBAR_BT_FORWARD || button <= 0 ){
|
||||
bt = find_button(tb, TOOLBAR_BT_FORWARD);
|
||||
enable = browser_window_forward_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
if( button == TOOLBAR_BT_RELOAD || button <= 0 ){
|
||||
bt = find_button(tb, TOOLBAR_BT_RELOAD);
|
||||
enable = browser_window_reload_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
if (button == TOOLBAR_BT_STOP || button <= 0) {
|
||||
bt = find_button(tb, TOOLBAR_BT_STOP);
|
||||
enable = browser_window_stop_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
if (tb->attached) {
|
||||
if (button > 0) {
|
||||
toolbar_get_grect(tb, button, &area);
|
||||
window_schedule_redraw_grect(tb->owner, &area);
|
||||
}
|
||||
else {
|
||||
toolbar_get_grect(tb, TOOLBAR_NAVIGATION_AREA, &area);
|
||||
window_schedule_redraw_grect(tb->owner, &area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area)
|
||||
{
|
||||
tb->area = *area;
|
||||
|
||||
|
||||
if (area->g_w != tb->area.g_w || area->g_h != tb->area.g_h) {
|
||||
tb->area = *area;
|
||||
/* reflow now, just for url input calucation: */
|
||||
toolbar_reflow(tb);
|
||||
/* this will request an textarea redraw: */
|
||||
textarea_set_dimensions(tb->url.textarea,
|
||||
aes_toolbar[TOOLBAR_URL_AREA].ob_width,
|
||||
20);
|
||||
}
|
||||
else {
|
||||
tb->area = *area;
|
||||
}
|
||||
/* reflow for next redraw: */
|
||||
/* TODO: that's only required because we do not reset others toolbars reflow
|
||||
state on reflow */
|
||||
tb->reflow = true;
|
||||
}
|
||||
|
||||
@ -441,10 +547,14 @@ void toolbar_set_url(struct s_toolbar *tb, const char * text)
|
||||
LOG((""));
|
||||
textarea_set_text(tb->url.textarea, text);
|
||||
|
||||
GRECT area;
|
||||
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
|
||||
|
||||
window_schedule_redraw_grect(tb->owner, &area);
|
||||
if (tb->attached) {
|
||||
GRECT area;
|
||||
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area);
|
||||
window_schedule_redraw_grect(tb->owner, &area);
|
||||
struct gui_window * gw = window_get_active_gui_window(tb->owner);
|
||||
assert(gw != NULL);
|
||||
toolbar_update_buttons(tb, gw->browser->bw , 0);
|
||||
}
|
||||
}
|
||||
|
||||
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
|
||||
@ -463,6 +573,12 @@ void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
|
||||
window_schedule_redraw_grect(tb->owner, &throbber_area);
|
||||
}
|
||||
|
||||
void toolbar_set_attached(struct s_toolbar *tb, bool attached)
|
||||
{
|
||||
tb->attached = attached;
|
||||
|
||||
}
|
||||
|
||||
void toolbar_throbber_progress(struct s_toolbar *tb)
|
||||
{
|
||||
GRECT throbber_area;
|
||||
@ -492,17 +608,145 @@ bool toolbar_text_input(struct s_toolbar *tb, char *text)
|
||||
|
||||
bool toolbar_key_input(struct s_toolbar *tb, short nkc)
|
||||
{
|
||||
bool handled = true;
|
||||
|
||||
LOG((""));
|
||||
assert(tb!=NULL);
|
||||
GRECT work;
|
||||
bool ret = false;
|
||||
|
||||
return(handled);
|
||||
struct gui_window *gw = window_get_active_gui_window(tb->owner);
|
||||
|
||||
assert( gw != NULL );
|
||||
|
||||
long ucs4;
|
||||
long ik = nkc_to_input_key(nkc, &ucs4);
|
||||
|
||||
if (ik == 0) {
|
||||
if ((nkc&0xFF) >= 9) {
|
||||
ret = textarea_keypress(tb->url.textarea, ucs4);
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_CR || ik == KEY_NL) {
|
||||
char tmp_url[PATH_MAX];
|
||||
if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
|
||||
window_set_focus(tb->owner, BROWSER, gw->browser);
|
||||
browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_COPY_SELECTION) {
|
||||
// copy whole text
|
||||
char * text;
|
||||
int len;
|
||||
len = textarea_get_text( tb->url.textarea, NULL, 0 );
|
||||
text = malloc( len+1 );
|
||||
if (text){
|
||||
textarea_get_text( tb->url.textarea, text, len+1 );
|
||||
scrap_txt_write( &app, text );
|
||||
free( text );
|
||||
}
|
||||
}
|
||||
else if ( ik == KEY_PASTE) {
|
||||
char * clip = scrap_txt_read( &app );
|
||||
if ( clip != NULL ){
|
||||
int clip_length = strlen( clip );
|
||||
if ( clip_length > 0 ) {
|
||||
char *utf8;
|
||||
utf8_convert_ret res;
|
||||
/* Clipboard is in local encoding so
|
||||
* convert to UTF8 */
|
||||
res = utf8_from_local_encoding( clip, clip_length, &utf8 );
|
||||
if ( res == UTF8_CONVERT_OK ) {
|
||||
toolbar_set_url(tb, utf8);
|
||||
free(utf8);
|
||||
ret = true;
|
||||
}
|
||||
free( clip );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_ESCAPE) {
|
||||
textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
|
||||
textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
|
||||
}
|
||||
else {
|
||||
ret = textarea_keypress( tb->url.textarea, ik );
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my)
|
||||
void toolbar_mouse_input(struct s_toolbar *tb, short obj)
|
||||
{
|
||||
LOG((""));
|
||||
GRECT work;
|
||||
short mx, my, mb, kstat;
|
||||
int old;
|
||||
|
||||
if (obj==TOOLBAR_URL_AREA){
|
||||
|
||||
graf_mkstate( &mx, &my, &mb, &kstat );
|
||||
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &work);
|
||||
mx -= work.g_x;
|
||||
my -= work.g_y;
|
||||
|
||||
/* TODO: reset mouse state of browser window? */
|
||||
/* select whole text when newly focused, otherwise set caret to
|
||||
end of text */
|
||||
if (!window_url_widget_has_focus(tb->owner)) {
|
||||
window_set_focus(tb->owner, URL_WIDGET, (void*)&tb->url );
|
||||
}
|
||||
/* url widget has focus and mouse button is still pressed... */
|
||||
else if (mb & 1) {
|
||||
|
||||
textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
|
||||
mx, my );
|
||||
short prev_x = mx;
|
||||
short prev_y = my;
|
||||
do {
|
||||
if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
|
||||
textarea_mouse_action( tb->url.textarea,
|
||||
BROWSER_MOUSE_HOLDING_1, mx, my );
|
||||
prev_x = mx;
|
||||
prev_y = my;
|
||||
window_schedule_redraw_grect(tb->owner, &work);
|
||||
window_process_redraws(tb->owner);
|
||||
}
|
||||
graf_mkstate( &mx, &my, &mb, &kstat );
|
||||
mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
|
||||
my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
|
||||
} while (mb & 1);
|
||||
|
||||
textarea_drag_end( tb->url.textarea, 0, mx, my );
|
||||
}
|
||||
else {
|
||||
/* when execution reaches here, mouse input is a click or dclick */
|
||||
/* TODO: recognize click + shitoolbar_update_buttonsft key */
|
||||
int mstate = BROWSER_MOUSE_PRESS_1;
|
||||
if( (kstat & (K_LSHIFT|K_RSHIFT)) != 0 ){
|
||||
mstate = BROWSER_MOUSE_MOD_1;
|
||||
}
|
||||
if( aes_event_out.emo_mclicks == 2 ){
|
||||
textarea_mouse_action( tb->url.textarea,
|
||||
BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
|
||||
my);
|
||||
toolbar_get_grect(tb, TOOLBAR_URL_AREA, &work);
|
||||
window_schedule_redraw_grect(tb->owner, &work);
|
||||
} else {
|
||||
textarea_mouse_action(tb->url.textarea,
|
||||
BROWSER_MOUSE_PRESS_1, mx, my );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
struct s_tb_button *bt = find_button(tb, obj);
|
||||
if (bt != NULL && bt->state != button_off) {
|
||||
bt->cb_click(tb);
|
||||
struct gui_window * gw = window_get_active_gui_window(tb->owner);
|
||||
toolbar_update_buttons(tb, gw->browser->bw,
|
||||
0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -540,43 +784,68 @@ struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
|
||||
/* public event handler */
|
||||
void toolbar_back_click(struct s_toolbar *tb)
|
||||
{
|
||||
assert(input_window != NULL);
|
||||
|
||||
struct browser_window *bw = input_window->browser->bw;
|
||||
|
||||
if( history_back_available(bw->history) )
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
||||
gw = window_get_active_gui_window(tb->owner);
|
||||
assert(gw != NULL);
|
||||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
if( history_back_available(bw->history) )
|
||||
history_back(bw, bw->history);
|
||||
}
|
||||
|
||||
void toolbar_reload_click(struct s_toolbar *tb)
|
||||
{
|
||||
assert(input_window != NULL);
|
||||
browser_window_reload(input_window->browser->bw, true);
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
||||
gw = window_get_active_gui_window(tb->owner);
|
||||
assert(gw != NULL);
|
||||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
browser_window_reload(bw, true);
|
||||
}
|
||||
|
||||
void toolbar_forward_click(struct s_toolbar *tb)
|
||||
{
|
||||
assert(input_window != NULL);
|
||||
struct browser_window *bw = input_window->browser->bw;
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
||||
gw = window_get_active_gui_window(tb->owner);
|
||||
assert(gw != NULL);
|
||||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
if (history_forward_available(bw->history))
|
||||
history_forward(bw, bw->history);
|
||||
}
|
||||
|
||||
void toolbar_home_click(struct s_toolbar *tb)
|
||||
{
|
||||
assert(input_window != NULL);
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
||||
gw = window_get_active_gui_window(tb->owner);
|
||||
assert(gw != NULL);
|
||||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
browser_window_go(bw, option_homepage_url, 0, true);
|
||||
}
|
||||
|
||||
|
||||
void toolbar_stop_click(struct s_toolbar *tb)
|
||||
{
|
||||
assert(input_window != NULL);
|
||||
browser_window_stop(input_window->browser->bw);
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
||||
gw = window_get_active_gui_window(tb->owner);
|
||||
assert(gw != NULL);
|
||||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
browser_window_stop(bw);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ struct s_toolbar
|
||||
GRECT area;
|
||||
/* size & location of buttons: */
|
||||
struct s_tb_button * buttons;
|
||||
bool hidden;
|
||||
bool attached;
|
||||
int btcnt;
|
||||
int style;
|
||||
bool redraw;
|
||||
@ -55,13 +55,14 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area);
|
||||
void toolbar_set_url(struct s_toolbar *tb, const char *text);
|
||||
bool toolbar_text_input(struct s_toolbar *tb, char *text);
|
||||
bool toolbar_key_input(struct s_toolbar *tb, short nkc);
|
||||
void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my);
|
||||
void toolbar_mouse_input(struct s_toolbar *tb, short obj);
|
||||
void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
|
||||
short idx);
|
||||
void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *g);
|
||||
struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
|
||||
enum toolbar_textarea which);
|
||||
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active);
|
||||
void toolbar_set_attached(struct s_toolbar *tb, bool attached);
|
||||
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip);
|
||||
void toolbar_throbber_progress(struct s_toolbar *tb);
|
||||
/* public events handlers: */
|
||||
|
@ -95,18 +95,11 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||
}
|
||||
}
|
||||
if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
|
||||
printf("Treeview keybd\n");
|
||||
on_keybd_event(tv, ev_out, msg);
|
||||
// handle key
|
||||
}
|
||||
if( (ev_out->emo_events & MU_TIMER) != 0 ) {
|
||||
// handle_timer();
|
||||
}
|
||||
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));
|
||||
printf("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
|
||||
ev_out->emo_mouse.p_y);
|
||||
on_mbutton_event(tv, ev_out, msg);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user