From c6a5109a95c1206ccf63d99316fa12b8c43bb7cf Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Tue, 18 Dec 2012 01:10:20 +0100 Subject: Preparing for merge... --- atari/gemtk/gemtk.h | 3 +- atari/gemtk/guiwin.c | 45 +++++++++++------ atari/gemtk/redrawslots.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++ atari/gemtk/redrawslots.h | 28 +++++++++++ 4 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 atari/gemtk/redrawslots.c create mode 100644 atari/gemtk/redrawslots.h (limited to 'atari/gemtk') diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h index ad9253c63..1225a0ccd 100644 --- a/atari/gemtk/gemtk.h +++ b/atari/gemtk/gemtk.h @@ -112,13 +112,14 @@ void *guiwin_get_user_data(GUIWIN *win); struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win); bool guiwin_update_slider(GUIWIN *win, short mode); void guiwin_scroll(GUIWIN *gw, short orientation, int units, bool refresh); +void guiwin_send_msg(GUIWIN *win, short msgtype, short a, short b, short c, + short d); void guiwin_send_redraw(GUIWIN *win, GRECT *area); VdiHdl guiwin_get_vdi_handle(GUIWIN *win); bool guiwin_has_intersection(GUIWIN *win, GRECT *work); void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip); void guiwin_clear(GUIWIN *win); - /* * AES Scroller Object */ diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c index c3042bcff..e587b97d1 100644 --- a/atari/gemtk/guiwin.c +++ b/atari/gemtk/guiwin.c @@ -282,12 +282,11 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) } } else { - short info[4]; - wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]); + short h_aes; + h_aes = wind_find(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); + if(h_aes > 0 && (ev_out->emo_events != MU_TIMER)) { - if(info[0] != 0 && info[1] == gl_apid) { - - dest = guiwin_find(info[0]); + dest = guiwin_find(h_aes); if(dest == NULL || dest->handler_func == NULL) return(0); @@ -309,16 +308,20 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]) dest->toolbar_idx, 8, ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); + DEBUG_PRINT(("Toolbar index: %d\n", obj_idx)); short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle, obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0 }; - if (((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) - && (obj_idx > 0) - && (dest->toolbar[obj_idx].ob_flags & OF_SELECTABLE) != 0) { - dest->toolbar[obj_idx].ob_state |= OS_SELECTED; - // TODO: optimize redraw by setting the object clip: - guiwin_toolbar_redraw(dest, NULL); - } + if (obj_idx > 0) { + if ((dest->toolbar[obj_idx].ob_flags & OF_SELECTABLE)!=0 + && ((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) + && ((dest->flags & GW_FLAG_TOOLBAR_REDRAW) == 0)) { + dest->toolbar[obj_idx].ob_state |= OS_SELECTED; + // TODO: optimize redraw by setting the object clip: + guiwin_toolbar_redraw(dest, NULL); + } + } + short oldevents = ev_out->emo_events; ev_out->emo_events = MU_MESAG; // notify the window about toolbar click: @@ -378,6 +381,8 @@ GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb) win->prev = tmp; win->next = NULL; } + + DEBUG_PRINT(("Added guiwin: %p, tb: %p\n", win, win->toolbar)); return(win); } @@ -429,6 +434,9 @@ short guiwin_remove(GUIWIN *win) void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest) { + + assert(win != NULL); + wind_get_grect(win->handle, WF_WORKXYWH, dest); if (mode == GUIWIN_AREA_CONTENT) { GRECT tb_area; @@ -680,8 +688,16 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area) }; EVMULT_OUT event_out; - if(area == NULL) { + if (area == NULL) { guiwin_get_grect(win, GUIWIN_AREA_WORK, &work); + if (work.g_w < 1 || work.g_h < 1) { + if (win->toolbar != NULL) { + guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &work); + if (work.g_w < 1 || work.g_h < 1) { + return; + } + } + } area = &work; } @@ -786,6 +802,3 @@ void guiwin_clear(GUIWIN *win) wind_get_grect(win->handle, WF_NEXTXYWH, &g); } } - - - diff --git a/atari/gemtk/redrawslots.c b/atari/gemtk/redrawslots.c new file mode 100644 index 000000000..ee5627daf --- /dev/null +++ b/atari/gemtk/redrawslots.c @@ -0,0 +1,123 @@ +/* + * Copyright 2011 Ole Loots + * + * 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 . + */ + +#include +#define WITH_RECT +#include "gemtk.h" +#undef WITH_RECT + +void redraw_slots_init(struct s_redrw_slots * slots, short size) +{ + // TODO: allocate slots dynamically! + slots->size = MIN( MAX_REDRW_SLOTS , size); + slots->areas_used = 0; +} + +void redraw_slots_free(struct s_redrw_slots * slots) +{ + // TOOD: free areas... +} + + +static inline bool rect_intersect( struct rect * box1, struct rect * box2 ) +{ + if (box2->x1 < box1->x0) + return false; + + if (box2->y1 < box1->y0) + return false; + + if (box2->x0 > box1->x1) + return false; + + if (box2->y0 > box1->y1) + return false; + + return true; +} + + +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, force); +} + +/* + schedule redraw coords. +*/ +void redraw_slot_schedule(struct s_redrw_slots * slots, short x0, short y0, + short x1, short y1, bool force) +{ + int i = 0; + struct rect area; + + area.x0 = x0; + area.y0 = y0; + area.x1 = x1; + area.y1 = y1; + + if (force == false) { + for (i=0; iareas_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) { + slots->areas[slots->areas_used].x0 = x0; + slots->areas[slots->areas_used].x1 = x1; + slots->areas[slots->areas_used].y0 = y0; + slots->areas[slots->areas_used].y1 = y1; + slots->areas_used++; + } else { + /* + we are out of available slots, merge box with last slot + this is dumb... but also a very rare case. + */ + slots->areas[slots->size-1].x0 = MIN(slots->areas[i].x0, x0); + slots->areas[slots->size-1].y0 = MIN(slots->areas[i].y0, y0); + slots->areas[slots->size-1].x1 = MAX(slots->areas[i].x1, x1); + slots->areas[slots->size-1].y1 = MAX(slots->areas[i].y1, y1); + } +done: + return; +} + +void redraw_slots_remove_area(struct s_redrw_slots * slots, int i) +{ + int x; + for(x = i+1; iareas_used; x++){ + slots->areas[x-1] = slots->areas[x]; + } + slots->areas_used--; +} diff --git a/atari/gemtk/redrawslots.h b/atari/gemtk/redrawslots.h new file mode 100644 index 000000000..d045b3965 --- /dev/null +++ b/atari/gemtk/redrawslots.h @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Ole Loots + * + * 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 . + */ + + +#ifndef ATARI_REDRAW_SLOTS_H +#define ATARI_REDRAW_SLOTS_H + +#include +#include "utils/types.h" + + + +#endif -- cgit v1.2.3