summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
Diffstat (limited to 'atari')
-rw-r--r--atari/gemtk/guiwin.c33
-rwxr-xr-xatari/gui.c44
-rwxr-xr-xatari/misc.c4
-rwxr-xr-xatari/rootwin.c115
-rw-r--r--atari/toolbar.c2
5 files changed, 126 insertions, 72 deletions
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 54d043e0d..1f962320d 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -471,8 +471,12 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_h/slid->y_unit_px;
newpos = slid->y_pos = MIN(slid->y_units-vis_units,
MAX(0, slid->y_pos+units));
+ if(newpos < 0){
+ newpos = slid->y_pos = 0;
+ }
if(oldpos == newpos)
return;
+
if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
// send complete redraw
redraw = &g_ro;
@@ -502,6 +506,11 @@ void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh)
vis_units = g.g_w/slid->x_unit_px;
newpos = slid->x_pos = MIN(slid->x_units-vis_units,
MAX(0, slid->x_pos+units));
+
+ if(newpos < 0){
+ newpos = slid->x_pos = 0;
+ }
+
if(oldpos == newpos)
return;
if (units>=vis_units || guiwin_has_intersection(gw, &g_ro)) {
@@ -635,11 +644,30 @@ struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) {
return(&win->scroll_info);
}
+void guiwin_request_redraw(GUIWIN *win, GRECT *area)
+{
+
+}
+
void guiwin_send_redraw(GUIWIN *win, GRECT *area)
{
short msg[8];
GRECT work;
+ EVMULT_IN event_in = {
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_bclicks = 258,
+ .emi_bmask = 3,
+ .emi_bstate = 0,
+ .emi_m1leave = MO_ENTER,
+ .emi_m1 = {0,0,0,0},
+ .emi_m2leave = 0,
+ .emi_m2 = {0,0,0,0},
+ .emi_tlow = 0,
+ .emi_thigh = 0
+ };
+ EVMULT_OUT event_out;
+
if(area == NULL) {
guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
area = &work;
@@ -654,7 +682,10 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
msg[6] = area->g_w;
msg[7] = area->g_h;
- appl_write(gl_apid, 16, &msg);
+ event_out.emo_events = MU_MESAG;
+ win->handler_func(win, &event_out, msg);
+
+ //appl_write(gl_apid, 16, &msg);
}
diff --git a/atari/gui.c b/atari/gui.c
index d930b0c14..80e98c253 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -363,22 +363,36 @@ void gui_window_redraw_window(struct gui_window *gw)
if (gw == NULL)
return;
b = gw->browser;
- browser_get_rect(gw, BR_CONTENT, &rect);
- browser_schedule_redraw(gw, 0, 0, rect.g_w, rect.g_h );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &rect);
+ window_schedule_redraw_grect(gw->root, &rect);
}
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
- CMP_BROWSER b;
+ GRECT area;
+ struct guiwin_scroll_info_s *slid;
+
if (gw == NULL)
return;
- b = gw->browser;
+
+ slid = guiwin_get_scroll_info(gw->root->win);
+
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
+
+ area.g_x += rect->x0 - slid->x_pos * slid->x_unit_px;
+ area.g_y += rect->y0 - slid->y_pos * slid->y_unit_px;
+ area.g_w = rect->x1 - rect->x0;
+ area.g_h = rect->y1 - rect->y0;
+ window_schedule_redraw_grect(gw->root, &area);
+/*
int x0 = rect->x0 - b->scroll.current.x;
int y0 = rect->y0 - b->scroll.current.y;
int w,h;
- w = rect->x1 - rect->x0;
- h = rect->y1 - rect->y0;
- browser_schedule_redraw_rect( gw, x0, y0, w, h );
+ */
+ //w = rect->x1 - rect->x0;
+ //h = rect->y1 - rect->y0;
+
+ //browser_schedule_redraw_rect( gw, x0, y0, w, h );
}
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
@@ -387,7 +401,8 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
if (w == NULL)
return false;
- window_get_scroll(w->root, &x, &y);
+ window_get_scroll(w->root, sx, sy);
+
return( true );
}
@@ -399,7 +414,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
|| (w->browser->bw->current_content == NULL))
return;
- printf("scroll %d, %d\n", sx, sy);
+ //printf("scroll %d, %d\n", sx, sy);
window_scroll_by(w->root, sx, sy);
return;
@@ -647,12 +662,11 @@ gui_window_set_search_ico(hlcache_handle *ico)
void gui_window_new_content(struct gui_window *w)
{
- w->browser->scroll.current.x = 0;
- w->browser->scroll.current.y = 0;
- w->browser->scroll.requested.x = 0;
- w->browser->scroll.requested.y = 0;
- w->browser->scroll.required = true;
- gui_window_redraw_window( w );
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(w->root->win);
+ slid->x_pos = 0;
+ slid->y_pos = 0;
+ guiwin_update_slider(w->root->win, GUIWIN_VH_SLIDER);
+ gui_window_redraw_window(w);
}
bool gui_window_scroll_start(struct gui_window *w)
diff --git a/atari/misc.c b/atari/misc.c
index f12556b63..60678dc59 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -504,8 +504,8 @@ void dbg_lgrect( char * str, LGRECT * r )
void dbg_grect(const char * str, GRECT * r)
{
- printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
- r->g_x, r->g_y, r->g_w, r->g_h );
+ printf("%s: x: %d, y: %d, w: %d, h: %d (x2: %d, y2: %d)\n", str,
+ r->g_x, r->g_y, r->g_w, r->g_h, r->g_x + r->g_w, r->g_y + r->g_h);
}
void dbg_pxy(const char * str, short * pxy )
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 980685223..056a85d75 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -96,7 +96,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
- printf("root win msg: %d\n", msg[0]);
+ //printf("root win msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
@@ -161,8 +161,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
}
if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
- printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
}
return(retval);
@@ -364,33 +364,22 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
void window_scroll_by(ROOTWIN *root, int sx, int sy)
{
- int units;
- GRECT content_area;
- struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
-
- if (sx != 0) {
- units = sx / slid->x_unit_px;
- if (units == 0) {
- units = 1;
- if(units < 0)
- units = -units;
- }
- guiwin_scroll(root->win, GUIWIN_HSLIDER, units, true);
- }
-
- guiwin_get_grect(root->win, GUIWIN_AREA_CONTENT, &content_area);
- if (sy != 0) {
- units = sy / slid->y_unit_px;
- if( sx < 0 ) {
- // units = -units;
- }
- if(units == 0){
- units = 1;
- if(units < 0)
- units = -units;
- }
- guiwin_scroll(root->win, GUIWIN_VSLIDER, units, true);
+ int units;
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
+
+ if(sx < 0) {
+ sx = 0;
}
+ if(sy<0) {
+ sy = 0;
+ }
+ int xunits = sx / slid->x_unit_px;
+ int yunits = sy / slid->y_unit_px;
+
+ guiwin_scroll(root->win, GUIWIN_VSLIDER, yunits - slid->y_pos, false);
+ guiwin_scroll(root->win, GUIWIN_HSLIDER, xunits - slid->x_pos, false);
+ guiwin_update_slider(root->win, GUIWIN_VH_SLIDER);
}
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
@@ -401,6 +390,10 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
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);
+ if(slid->x_units < slid->x_pos)
+ slid->x_pos = 0;
+ if(slid->y_units < slid->y_pos)
+ slid->y_pos = 0;
guiwin_update_slider(rootwin->win, GUIWIN_VH_SLIDER);
// TODO: reset slider to 0
}
@@ -493,12 +486,12 @@ struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
{
- struct guiwin_scroll_info_s *slid;
+ struct guiwin_scroll_info_s *slid;
- slid = guiwin_get_scroll_info(rootwin->win);
+ slid = guiwin_get_scroll_info(rootwin->win);
- *x = slid->x_pos * slid->x_unit_px;
- *y = slid->y_pos * slid->y_unit_px;
+ *x = slid->x_pos * slid->x_unit_px;
+ *y = slid->y_pos * slid->y_unit_px;
}
@@ -559,7 +552,7 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
rc_intersect(area, &work);
- dbg_grect("window_schedule_redraw_grect intersection ", &work);
+ //dbg_grect("window_schedule_redraw_grect intersection ", &work);
redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
}
@@ -603,7 +596,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
content_area_rel.g_y = 0;
}
- dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
+ //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;
@@ -612,6 +605,8 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
plot_clip(&redraw_area);
+ //dbg_rect("rdrw area", &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 );
}
@@ -630,6 +625,8 @@ void window_process_redraws(ROOTWIN * rootwin)
guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, &tb_area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, &content_area);
+ //dbg_grect("content area", &content_area);
+
short pxy_clip[4];
pxy_clip[0] = tb_area.g_x;
@@ -696,7 +693,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
gw = window_get_active_gui_window(rootwin);
if( input_window != gw ) {
- input_window = gw;
+ gui_set_input_gui_window(gw);
}
window_set_focus(gw->root, BROWSER, (void*)gw->browser );
@@ -705,6 +702,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* convert screen coords to component coords: */
mx = aes_event_out.emo_mouse.p_x - cwork.g_x;
my = aes_event_out.emo_mouse.p_y - cwork.g_y;
+ //printf("content click at %d,%d\n", mx, my);
/* Translate GEM key state to netsurf mouse modifier */
if ( aes_event_out.emo_kmeta & (K_RSHIFT | K_LSHIFT)) {
@@ -725,8 +723,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* convert component coords to scrolled content coords: */
slid = guiwin_get_scroll_info(rootwin->win);
- int sx_origin = (mx + slid->x_pos * slid->x_unit_px);
- int sy_origin = (my + slid->y_pos * slid->y_unit_px);
+ int sx_origin = mx;
+ int sy_origin = my;
short rel_cur_x, rel_cur_y;
short prev_x=sx_origin, prev_y=sy_origin;
@@ -736,39 +734,48 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
/* Mouse still pressed, report drag */
- rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
- rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ rel_cur_x = (rel_cur_x - cwork.g_x);
+ rel_cur_y = (rel_cur_y - cwork.g_y);
browser_window_mouse_click( gw->browser->bw,
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
- sx_origin, sy_origin);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
do {
+ printf("rel click coords: %d,%d\n", rel_cur_x, rel_cur_y);
// only consider movements of 5px or more as drag...:
if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
browser_window_mouse_track( gw->browser->bw,
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
- rel_cur_x, rel_cur_y);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
prev_x = rel_cur_x;
prev_y = rel_cur_y;
dragmode = true;
+ printf("now dragmode is true...\n");
} else {
if( dragmode == false ) {
+ printf("dragmode = false\n");
browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
- rel_cur_x, rel_cur_y);
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
}
}
// we may need to process scrolling:
// TODO: this doesn't work, because gemtk schedules redraw via
// AES window messages but we do not process them right here...
- if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+ evnt_timer(150);
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
- rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
- rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
+ rel_cur_x = (rel_cur_x - cwork.g_x);
+ rel_cur_y = (rel_cur_y - cwork.g_y);
} while( mbut & 1 );
- browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
+ browser_window_mouse_track(gw->browser->bw, 0,
+ rel_cur_x + slid->x_pos * slid->x_unit_px,
+ rel_cur_y + slid->y_pos * slid->y_unit_px);
} else {
/* Right button pressed? */
if ((aes_event_out.emo_mbutton & 2 ) ) {
@@ -777,15 +784,17 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
} else {
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_PRESS_1,
- sx_origin,sy_origin);
+ sx_origin + slid->x_pos * slid->x_unit_px,
+ sy_origin + slid->y_pos * slid->y_unit_px);
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_CLICK_1,
- sx_origin,sy_origin);
+ sx_origin + slid->x_pos * slid->x_unit_px,
+ sy_origin + slid->y_pos * slid->y_unit_px);
}
}
if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ window_process_redraws(rootwin);
+ }
}
/*
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 4b049117f..40cee808f 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -218,7 +218,7 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
area.g_y += y;
area.g_w = w;
area.g_h = h;
- dbg_grect("tb_txt_request_redraw", &area);
+ //dbg_grect("tb_txt_request_redraw", &area);
window_schedule_redraw_grect(tb->owner, &area);
return;
}