2012-11-19 02:22:43 +04:00
|
|
|
/*
|
|
|
|
* 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/>.
|
2016-07-01 16:27:04 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Implements the NetSurf Browser window, or passed functionality to
|
2013-01-02 01:08:19 +04:00
|
|
|
* the appropriate widget's.
|
|
|
|
*
|
2012-11-19 02:22:43 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <osbind.h>
|
|
|
|
|
2013-01-07 23:04:44 +04:00
|
|
|
#include <mt_gem.h>
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "utils/log.h"
|
2016-06-08 17:30:25 +03:00
|
|
|
#include "utils/nsurl.h"
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2016-05-30 14:07:16 +03:00
|
|
|
#include "netsurf/mouse.h"
|
2016-05-30 23:05:57 +03:00
|
|
|
#include "netsurf/plotters.h"
|
2016-07-01 16:27:04 +03:00
|
|
|
#include "netsurf/keypress.h"
|
2013-01-03 04:22:38 +04:00
|
|
|
|
|
|
|
#include "atari/res/netsurf.rsh"
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/gemtk/gemtk.h"
|
2013-01-03 04:22:38 +04:00
|
|
|
#include "atari/ctxmenu.h"
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/gui.h"
|
|
|
|
#include "atari/rootwin.h"
|
|
|
|
#include "atari/misc.h"
|
|
|
|
#include "atari/plot/plot.h"
|
|
|
|
#include "atari/toolbar.h"
|
|
|
|
#include "atari/statusbar.h"
|
|
|
|
#include "atari/search.h"
|
|
|
|
#include "atari/osspec.h"
|
|
|
|
#include "atari/encoding.h"
|
2012-11-29 00:30:24 +04:00
|
|
|
#include "atari/redrawslots.h"
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/toolbar.h"
|
2013-11-25 03:09:09 +04:00
|
|
|
#include "atari/findfile.h"
|
2015-04-20 00:58:13 +03:00
|
|
|
#include "atari/bitmap.h"
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
extern struct gui_window *input_window;
|
2012-12-03 03:07:47 +04:00
|
|
|
extern EVMULT_OUT aes_event_out;
|
2013-01-07 23:04:44 +04:00
|
|
|
extern GRECT desk_area;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
struct rootwin_data_s {
|
|
|
|
struct s_gui_win_root *rootwin;
|
|
|
|
};
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
/* -------------------------------------------------------------------------- */
|
2012-12-06 03:26:00 +04:00
|
|
|
/* Static module event handlers */
|
2012-11-19 02:22:43 +04:00
|
|
|
/* -------------------------------------------------------------------------- */
|
2012-12-03 03:07:47 +04:00
|
|
|
static void on_redraw(ROOTWIN *rootwin, short msg[8]);
|
|
|
|
static void on_resized(ROOTWIN *rootwin);
|
|
|
|
static void on_file_dropped(ROOTWIN *rootwin, short msg[8]);
|
|
|
|
static short on_window_key_input(ROOTWIN * rootwin, unsigned short nkc);
|
2014-09-16 01:27:15 +04:00
|
|
|
static void on_content_mouse_click(ROOTWIN *rootwin);
|
|
|
|
static void on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area);
|
2013-01-15 04:31:35 +04:00
|
|
|
static void toolbar_redraw_cb(GUIWIN *win, uint16_t msg, GRECT *clip);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2014-01-13 05:08:15 +04:00
|
|
|
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
static bool redraw_active = false;
|
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
static const struct redraw_context rootwin_rdrw_ctx = {
|
|
|
|
.interactive = true,
|
|
|
|
.background_images = true,
|
|
|
|
.plot = &atari_plotters
|
|
|
|
};
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
|
|
|
{
|
2012-11-30 06:20:52 +04:00
|
|
|
short retval = 0;
|
2013-01-31 22:22:35 +04:00
|
|
|
GRECT area;
|
2012-12-06 03:26:00 +04:00
|
|
|
static bool prev_url = false;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct rootwin_data_s * data = gemtk_wm_get_user_data(win);
|
2013-01-17 05:44:13 +04:00
|
|
|
struct gui_window *tmp;
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2012-12-06 03:26:00 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
if ((ev_out->emo_events & MU_MESAG) != 0) {
|
2012-11-19 02:22:43 +04:00
|
|
|
// handle message
|
2012-12-04 04:32:43 +04:00
|
|
|
//printf("root win msg: %d\n", msg[0]);
|
2012-11-19 02:22:43 +04:00
|
|
|
switch (msg[0]) {
|
|
|
|
|
|
|
|
case WM_REDRAW:
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("WM_REDRAW");
|
2012-12-03 03:07:47 +04:00
|
|
|
on_redraw(data->rootwin, msg);
|
2012-12-01 19:18:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_REPOSED:
|
|
|
|
case WM_SIZED:
|
|
|
|
case WM_MOVED:
|
|
|
|
case WM_FULLED:
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("WM_SIZED");
|
2012-12-03 03:07:47 +04:00
|
|
|
on_resized(data->rootwin);
|
2012-12-01 19:18:02 +04:00
|
|
|
break;
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
case WM_ICONIFY:
|
|
|
|
// TODO: find next active gui window and schedule redraw for that.
|
2013-01-17 05:44:13 +04:00
|
|
|
tmp = window_list;
|
|
|
|
while(tmp != NULL){
|
|
|
|
if(tmp->root != data->rootwin){
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_send_msg(tmp->root->win, WM_TOPPED, 0, 0, 0, 0);
|
2013-01-17 05:44:13 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
2013-01-14 04:01:22 +04:00
|
|
|
break;
|
2013-01-11 00:10:07 +04:00
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
case WM_TOPPED:
|
|
|
|
case WM_NEWTOP:
|
|
|
|
case WM_UNICONIFY:
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("WM_TOPPED");
|
2013-01-17 04:18:27 +04:00
|
|
|
gui_set_input_gui_window(data->rootwin->active_gui_window);
|
2013-01-23 01:28:20 +04:00
|
|
|
//window_restore_active_gui_window(data->rootwin);
|
2013-01-14 04:01:22 +04:00
|
|
|
// TODO: use something like "restore_active_gui_window_state()"
|
2013-01-17 04:18:27 +04:00
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CLOSED:
|
|
|
|
// TODO: this needs to iterate through all gui windows and
|
|
|
|
// check if the rootwin is this window...
|
|
|
|
if (data->rootwin->active_gui_window != NULL) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("WM_CLOSED initiated destroy for bw %p", data->rootwin->active_gui_window->browser->bw);
|
2012-12-01 19:18:02 +04:00
|
|
|
browser_window_destroy(
|
|
|
|
data->rootwin->active_gui_window->browser->bw);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AP_DRAGDROP:
|
2012-12-03 03:07:47 +04:00
|
|
|
on_file_dropped(data->rootwin, msg);
|
2012-11-19 02:22:43 +04:00
|
|
|
break;
|
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
case WM_TOOLBAR:
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_mouse_input(data->rootwin->toolbar, msg[4], msg[7]);
|
2012-12-01 19:18:02 +04:00
|
|
|
break;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-12-03 03:07:47 +04:00
|
|
|
if ((ev_out->emo_events & MU_KEYBD) != 0) {
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
// handle key
|
2012-11-30 06:20:52 +04:00
|
|
|
uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
|
2012-12-01 19:18:02 +04:00
|
|
|
(short)ev_out->emo_kreturn);
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("rootwin MU_KEYBD input, nkc: %x\n", nkc);
|
2012-12-03 03:07:47 +04:00
|
|
|
retval = on_window_key_input(data->rootwin, nkc);
|
2013-04-09 02:40:21 +04:00
|
|
|
// printf("on_window_key_input: %d\n", retval);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2012-12-03 03:07:47 +04:00
|
|
|
if ((ev_out->emo_events & MU_BUTTON) != 0) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("rootwin MU_BUTTON input, x: %d, y: %d\n", ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_x);
|
2013-01-11 00:19:05 +04:00
|
|
|
window_get_grect(data->rootwin, BROWSER_AREA_CONTENT,
|
2013-01-31 22:22:35 +04:00
|
|
|
&area);
|
2012-12-06 03:26:00 +04:00
|
|
|
if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
|
2013-01-31 22:22:35 +04:00
|
|
|
area)) {
|
2012-12-03 03:07:47 +04:00
|
|
|
on_content_mouse_click(data->rootwin);
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2012-12-06 03:26:00 +04:00
|
|
|
if ((ev_out->emo_events & (MU_M1)) != 0) {
|
|
|
|
|
|
|
|
short ghandle = wind_find(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y);
|
|
|
|
|
2012-12-21 03:56:50 +04:00
|
|
|
if (data->rootwin->aes_handle==ghandle) {
|
2012-12-06 03:26:00 +04:00
|
|
|
// The window found at x,y is an gui_window
|
|
|
|
// and it's the input window.
|
|
|
|
window_get_grect(data->rootwin, BROWSER_AREA_CONTENT,
|
2013-01-31 22:22:35 +04:00
|
|
|
&area);
|
2012-12-06 03:26:00 +04:00
|
|
|
if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
|
2013-01-31 22:22:35 +04:00
|
|
|
area)) {
|
|
|
|
on_content_mouse_move(data->rootwin, &area);
|
2012-12-06 03:26:00 +04:00
|
|
|
} else {
|
|
|
|
GRECT tb_area;
|
|
|
|
window_get_grect(data->rootwin, BROWSER_AREA_URL_INPUT, &tb_area);
|
|
|
|
if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
|
|
|
|
tb_area)) {
|
2013-01-02 01:08:19 +04:00
|
|
|
gem_set_cursor(&gem_cursors.ibeam);
|
|
|
|
prev_url = true;
|
|
|
|
} else {
|
|
|
|
if(prev_url) {
|
|
|
|
struct gui_window *gw;
|
|
|
|
gw = window_get_active_gui_window(data->rootwin);
|
|
|
|
gem_set_cursor(gw->cursor);
|
|
|
|
prev_url = false;
|
|
|
|
}
|
2012-12-06 03:26:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-03 04:27:33 +04:00
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
return(retval);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* Module public functions: */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-20 03:29:20 +04:00
|
|
|
int window_create(struct gui_window * gw,
|
2012-12-01 19:18:02 +04:00
|
|
|
struct browser_window * bw,
|
2014-02-09 17:07:39 +04:00
|
|
|
struct gui_window * existing,
|
2012-12-01 19:18:02 +04:00
|
|
|
unsigned long inflags)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
bool tb, sb;
|
|
|
|
int flags;
|
2013-01-15 04:31:35 +04:00
|
|
|
struct rootwin_data_s *data;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
tb = (inflags & WIDGET_TOOLBAR);
|
|
|
|
sb = (inflags & WIDGET_STATUSBAR);
|
|
|
|
|
|
|
|
flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
|
|
|
|
if( inflags & WIDGET_SCROLL ) {
|
|
|
|
flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
|
|
|
|
}
|
|
|
|
if( inflags & WIDGET_RESIZE ) {
|
|
|
|
flags |= ( SIZER );
|
|
|
|
}
|
|
|
|
if( inflags & WIDGET_STATUSBAR ) {
|
|
|
|
flags |= ( INFO );
|
|
|
|
}
|
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
gw->root = malloc(sizeof(struct s_gui_win_root));
|
|
|
|
if (gw->root == NULL)
|
|
|
|
return(-1);
|
|
|
|
memset(gw->root, 0, sizeof(struct s_gui_win_root) );
|
2012-11-19 02:22:43 +04:00
|
|
|
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
|
2012-11-29 00:30:24 +04:00
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
redraw_slots_init(&gw->root->redraw_slots, 8);
|
|
|
|
|
2013-01-07 23:04:44 +04:00
|
|
|
gw->root->aes_handle = wind_create(flags, 40, 40, desk_area.g_w,
|
2013-01-14 04:01:22 +04:00
|
|
|
desk_area.g_h);
|
2012-12-21 03:56:50 +04:00
|
|
|
if(gw->root->aes_handle<0) {
|
2012-11-29 00:30:24 +04:00
|
|
|
free(gw->root->title);
|
|
|
|
free(gw->root);
|
2012-11-19 02:22:43 +04:00
|
|
|
return( -1 );
|
|
|
|
}
|
2013-01-22 05:33:27 +04:00
|
|
|
gw->root->win = gemtk_wm_add(gw->root->aes_handle,
|
|
|
|
GEMTK_WM_FLAG_PREPROC_WM | GEMTK_WM_FLAG_RECV_PREPROC_WM, handle_event);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
data = malloc(sizeof(struct rootwin_data_s));
|
2012-11-29 05:01:13 +04:00
|
|
|
data->rootwin = gw->root;
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_set_user_data(gw->root->win, (void*)data);
|
|
|
|
slid = gemtk_wm_get_scroll_info(gw->root->win);
|
2013-01-07 23:04:44 +04:00
|
|
|
slid->y_unit_px = 32;
|
|
|
|
slid->x_unit_px = 32;
|
2012-11-29 05:01:13 +04:00
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
/* create */
|
|
|
|
if(tb) {
|
2012-11-27 05:12:09 +04:00
|
|
|
gw->root->toolbar = toolbar_create(gw->root);
|
|
|
|
assert(gw->root->toolbar);
|
2013-01-23 01:28:20 +04:00
|
|
|
gemtk_wm_set_toolbar(gw->root->win, gw->root->toolbar->form, 0, 0);
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_set_toolbar_redraw_func(gw->root->win, toolbar_redraw_cb);
|
2012-11-19 02:22:43 +04:00
|
|
|
} else {
|
|
|
|
gw->root->toolbar = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create browser component: */
|
2013-01-15 04:31:35 +04:00
|
|
|
gw->browser = (struct s_browser *)malloc( sizeof(struct s_browser));
|
2013-01-03 04:22:38 +04:00
|
|
|
|
|
|
|
assert(gw->browser);
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
gw->browser->bw = bw;
|
2014-10-25 18:43:41 +04:00
|
|
|
gw->scale = browser_window_get_scale(bw);
|
2013-01-03 04:22:38 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
/* create statusbar component: */
|
2012-11-29 00:30:24 +04:00
|
|
|
if(sb) {
|
2012-11-19 02:22:43 +04:00
|
|
|
gw->root->statusbar = sb_create( gw );
|
|
|
|
} else {
|
|
|
|
gw->root->statusbar = NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-29 00:30:24 +04:00
|
|
|
// Setup some window defaults:
|
2013-01-07 23:04:44 +04:00
|
|
|
wind_set_str(gw->root->aes_handle, WF_NAME, (char*)"NetSurf");
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_set(gw->root->aes_handle, WF_OPTS, 1, WO0_FULLREDRAW, 0, 0);
|
|
|
|
wind_set(gw->root->aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0);
|
|
|
|
wind_set(gw->root->aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0);
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
if (inflags & WIN_TOP) {
|
2012-11-27 05:12:09 +04:00
|
|
|
window_set_focus(gw->root, BROWSER, gw->browser);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
|
|
|
|
{
|
|
|
|
struct gui_window *w;
|
|
|
|
input_window = NULL;
|
|
|
|
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("window: %p, gui_window: %p", rootwin, gw);
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
w = window_list;
|
|
|
|
// find the next active tab:
|
|
|
|
while( w != NULL ) {
|
|
|
|
if(w->root == rootwin && w != gw) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("activating next tab %p", w);
|
2012-12-03 03:07:47 +04:00
|
|
|
gui_set_input_gui_window(w);
|
2012-11-27 05:12:09 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
w = w->next;
|
|
|
|
}
|
2012-12-01 19:18:02 +04:00
|
|
|
if(input_window == NULL) {
|
2012-11-27 05:12:09 +04:00
|
|
|
// the last gui window for this rootwin was removed:
|
2012-11-29 00:30:24 +04:00
|
|
|
redraw_slots_free(&rootwin->redraw_slots);
|
2012-11-27 05:12:09 +04:00
|
|
|
window_destroy(rootwin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int window_destroy(ROOTWIN *rootwin)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
|
|
|
int err = 0;
|
2012-11-27 05:12:09 +04:00
|
|
|
struct gui_window *w;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(rootwin != NULL);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("%p", rootwin);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
if (gemtk_wm_get_user_data(rootwin->win) != NULL) {
|
|
|
|
free(gemtk_wm_get_user_data(rootwin->win));
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
// make sure we do not destroy windows which have gui_windows attached:
|
|
|
|
w = window_list;
|
|
|
|
while( w != NULL ) {
|
|
|
|
if(w->root == rootwin) {
|
|
|
|
assert(rootwin == NULL);
|
|
|
|
}
|
|
|
|
w = w->next;
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
if (rootwin->toolbar)
|
2012-11-27 05:12:09 +04:00
|
|
|
toolbar_destroy(rootwin->toolbar);
|
|
|
|
|
|
|
|
if(rootwin->statusbar)
|
|
|
|
sb_destroy(rootwin->statusbar);
|
|
|
|
|
|
|
|
if(rootwin->title)
|
|
|
|
free(rootwin->title);
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_remove(rootwin->win);
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_close(rootwin->aes_handle);
|
|
|
|
wind_delete(rootwin->aes_handle);
|
2012-11-27 05:12:09 +04:00
|
|
|
free(rootwin);
|
2012-11-19 02:22:43 +04:00
|
|
|
return(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
void window_open(ROOTWIN *rootwin, struct gui_window *gw, GRECT pos)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2014-09-16 01:27:15 +04:00
|
|
|
GRECT g;
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
rootwin->active_gui_window = gw;
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
assert(rootwin->active_gui_window != NULL);
|
|
|
|
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_open(rootwin->aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
|
|
|
|
wind_set_str(rootwin->aes_handle, WF_NAME, (char *)"");
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
rootwin->active_gui_window->browser->attached = true;
|
|
|
|
if(rootwin->statusbar != NULL) {
|
|
|
|
sb_attach(rootwin->statusbar, rootwin->active_gui_window);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2013-03-11 04:16:37 +04:00
|
|
|
|
|
|
|
/* Set initial size of the toolbar region: */
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_get_grect(rootwin->win, GEMTK_WM_AREA_TOOLBAR, &g);
|
2012-11-30 06:20:52 +04:00
|
|
|
toolbar_set_attached(rootwin->toolbar, true);
|
2012-11-29 00:30:24 +04:00
|
|
|
toolbar_set_dimensions(rootwin->toolbar, &g);
|
2013-03-11 04:16:37 +04:00
|
|
|
|
|
|
|
/* initially hide the search area of the toolbar: */
|
2013-04-15 23:02:34 +04:00
|
|
|
window_close_search(rootwin);
|
2013-03-11 04:16:37 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
window_update_back_forward(rootwin);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
void window_restore_active_gui_window(ROOTWIN *rootwin)
|
|
|
|
{
|
|
|
|
GRECT tb_area;
|
|
|
|
struct gui_window *gw;
|
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
LOG("rootwin %p", rootwin);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
assert(rootwin->active_gui_window);
|
|
|
|
|
|
|
|
gw = rootwin->active_gui_window;
|
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
window_set_icon(rootwin, gw->icon);
|
|
|
|
window_set_stauts(rootwin, gw->status);
|
|
|
|
window_set_title(rootwin, gw->title);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
if (gw->search != NULL) {
|
2013-01-23 01:28:20 +04:00
|
|
|
// TODO: update search session (especially browser window)
|
2016-04-20 12:43:58 +03:00
|
|
|
}
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
toolbar_get_grect(rootwin->toolbar, 0, &tb_area);
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_set_toolbar_size(rootwin->win, tb_area.g_h);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
window_update_back_forward(rootwin);
|
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
toolbar_set_url(rootwin->toolbar, gw->url);
|
2013-01-17 04:18:27 +04:00
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
/* update back forward buttons (see tb_update_buttons (bug) ) */
|
2012-11-27 05:12:09 +04:00
|
|
|
void window_update_back_forward(struct s_gui_win_root *rootwin)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
struct gui_window * active_gw = rootwin->active_gui_window;
|
|
|
|
toolbar_update_buttons(rootwin->toolbar, active_gw->browser->bw, -1);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void window_set_stauts(struct s_gui_win_root *rootwin, char * text)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(rootwin != NULL);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
CMP_STATUSBAR sb = rootwin->statusbar;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
if( sb == NULL)
|
2012-11-19 02:22:43 +04:00
|
|
|
return;
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
if(text != NULL)
|
|
|
|
sb_set_text(sb, text);
|
|
|
|
else
|
|
|
|
sb_set_text(sb, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
void window_set_title(struct s_gui_win_root * rootwin, char *title)
|
|
|
|
{
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_set_str(rootwin->aes_handle, WF_NAME, title);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 04:27:33 +04:00
|
|
|
void window_scroll_by(ROOTWIN *root, int sx, int sy)
|
|
|
|
{
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(root->win);
|
2012-12-04 04:32:43 +04:00
|
|
|
|
2013-04-13 17:34:08 +04:00
|
|
|
if (sx < 0) {
|
2012-12-04 04:32:43 +04:00
|
|
|
sx = 0;
|
2012-12-03 04:27:33 +04:00
|
|
|
}
|
2013-04-13 17:34:08 +04:00
|
|
|
if (sy < 0) {
|
2012-12-04 04:32:43 +04:00
|
|
|
sy = 0;
|
|
|
|
}
|
|
|
|
int xunits = sx / slid->x_unit_px;
|
|
|
|
int yunits = sy / slid->y_unit_px;
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(root->win, GEMTK_WM_VSLIDER, yunits - slid->y_pos, false);
|
|
|
|
gemtk_wm_scroll(root->win, GEMTK_WM_HSLIDER, xunits - slid->x_pos, false);
|
|
|
|
gemtk_wm_update_slider(root->win, GEMTK_WM_VH_SLIDER);
|
2012-12-03 04:27:33 +04:00
|
|
|
}
|
|
|
|
|
2013-01-07 23:04:44 +04:00
|
|
|
/**
|
|
|
|
* Set the dimensions of the scrollable content.
|
|
|
|
*
|
|
|
|
*/
|
2012-11-30 06:20:52 +04:00
|
|
|
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
|
|
|
|
{
|
|
|
|
GRECT area;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(rootwin->win);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2013-01-11 00:19:05 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &area);
|
2013-01-07 23:04:44 +04:00
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
slid->x_units = (width/slid->x_unit_px);
|
|
|
|
slid->y_units = (height/slid->y_unit_px);
|
2012-12-04 04:32:43 +04:00
|
|
|
if(slid->x_units < slid->x_pos)
|
|
|
|
slid->x_pos = 0;
|
|
|
|
if(slid->y_units < slid->y_pos)
|
|
|
|
slid->y_pos = 0;
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_update_slider(rootwin->win, GEMTK_WM_VH_SLIDER);
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
/* set focus to an arbitary element */
|
2012-11-27 05:12:09 +04:00
|
|
|
void window_set_focus(struct s_gui_win_root *rootwin,
|
|
|
|
enum focus_element_type type, void * element)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(rootwin != NULL);
|
|
|
|
|
|
|
|
if (rootwin->focus.type != type || rootwin->focus.element != element) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Set focus: %p (%d)\n", element, type);
|
2012-11-27 05:12:09 +04:00
|
|
|
rootwin->focus.type = type;
|
|
|
|
rootwin->focus.element = element;
|
2013-01-23 01:28:20 +04:00
|
|
|
switch( type ) {
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
case URL_WIDGET:
|
2012-11-27 05:12:09 +04:00
|
|
|
// TODO: make something like: toolbar_text_select_all();
|
2013-01-23 01:28:20 +04:00
|
|
|
toolbar_key_input(rootwin->toolbar, (short)(NKF_CTRL | 'A') );
|
|
|
|
/*
|
|
|
|
ta = toolbar_get_textarea(rootwin->toolbar,
|
|
|
|
URL_INPUT_TEXT_AREA);
|
2015-03-27 12:36:19 +03:00
|
|
|
textarea_keypress(ta, NS_KEY_SELECT_ALL);
|
2013-01-23 01:28:20 +04:00
|
|
|
*/
|
|
|
|
break;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
case SEARCH_INPUT:
|
|
|
|
gemtk_wm_set_toolbar_edit_obj(rootwin->win, TOOLBAR_TB_SRCH, 0);
|
|
|
|
break;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if the url widget has focus */
|
2012-11-27 05:12:09 +04:00
|
|
|
bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(rootwin != NULL);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
if (rootwin->focus.type == URL_WIDGET) {
|
2012-11-19 02:22:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if an arbitary window widget / or frame has the focus */
|
2012-11-27 05:12:09 +04:00
|
|
|
bool window_widget_has_focus(struct s_gui_win_root *rootwin,
|
|
|
|
enum focus_element_type t, void * element)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(rootwin != NULL);
|
2012-11-19 02:22:43 +04:00
|
|
|
if( element == NULL ) {
|
2012-11-27 05:12:09 +04:00
|
|
|
return((rootwin->focus.type == t));
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
return((element == rootwin->focus.element && t == rootwin->focus.type));
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
rootwin->icon = bmp;
|
2012-11-19 02:22:43 +04:00
|
|
|
/* redraw window when it is iconyfied: */
|
2012-11-27 05:12:09 +04:00
|
|
|
if (rootwin->icon != NULL) {
|
2013-01-22 05:33:27 +04:00
|
|
|
if (gemtk_wm_get_state(rootwin->win) & GEMTK_WM_STATUS_ICONIFIED) {
|
2012-11-27 05:12:09 +04:00
|
|
|
window_redraw_favicon(rootwin, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
|
|
|
|
{
|
2013-01-17 04:18:27 +04:00
|
|
|
struct gui_window *old_gw = rootwin->active_gui_window;
|
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
LOG("gw %p",gw);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
if (rootwin->active_gui_window != NULL) {
|
|
|
|
if(rootwin->active_gui_window == gw) {
|
|
|
|
LOG("nothing to do...");
|
|
|
|
return;
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
// TODO: when the window isn't on top, initiate WM_TOPPED.
|
|
|
|
|
|
|
|
rootwin->active_gui_window = gw;
|
|
|
|
if (old_gw != NULL) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("restoring window...");
|
2013-01-17 04:18:27 +04:00
|
|
|
window_restore_active_gui_window(rootwin);
|
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin)
|
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
return(rootwin->active_gui_window);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 04:27:33 +04:00
|
|
|
void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
|
|
|
|
{
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid;
|
2012-12-03 04:27:33 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
slid = gemtk_wm_get_scroll_info(rootwin->win);
|
2012-12-03 04:27:33 +04:00
|
|
|
|
2012-12-04 04:32:43 +04:00
|
|
|
*x = slid->x_pos * slid->x_unit_px;
|
|
|
|
*y = slid->y_pos * slid->y_unit_px;
|
2012-12-03 04:27:33 +04:00
|
|
|
}
|
|
|
|
|
2012-12-06 03:26:00 +04:00
|
|
|
void window_get_grect(ROOTWIN *rootwin, enum browser_area_e which, GRECT *d)
|
|
|
|
{
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
d->g_x = 0;
|
|
|
|
d->g_y = 0;
|
|
|
|
d->g_w = 0;
|
|
|
|
d->g_h = 0;
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2012-12-06 03:26:00 +04:00
|
|
|
if (which == BROWSER_AREA_TOOLBAR) {
|
2013-01-22 05:33:27 +04:00
|
|
|
// gemtk_wm_get_grect(rootwin->win, GEMTK_WM_AREA_TOOLBAR, d);
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(rootwin->toolbar, 0, d);
|
2013-01-15 04:54:54 +04:00
|
|
|
|
2012-12-06 03:26:00 +04:00
|
|
|
} else if (which == BROWSER_AREA_CONTENT) {
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
GRECT tb_area;
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_get_grect(rootwin->win, GEMTK_WM_AREA_WORK, d);
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(rootwin->toolbar, 0, &tb_area);
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
d->g_y += tb_area.g_h;
|
|
|
|
d->g_h -= tb_area.g_h;
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2012-12-06 03:26:00 +04:00
|
|
|
} else if (which == BROWSER_AREA_URL_INPUT) {
|
2013-01-11 05:12:30 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(rootwin->toolbar, TOOLBAR_AREA_URL, d);
|
2012-12-06 03:26:00 +04:00
|
|
|
|
2013-01-11 05:12:30 +04:00
|
|
|
} else if (which == BROWSER_AREA_SEARCH) {
|
2013-01-14 04:01:22 +04:00
|
|
|
// todo: check if search is visible
|
|
|
|
toolbar_get_grect(rootwin->toolbar, TOOLBAR_AREA_SEARCH, d);
|
|
|
|
} else {
|
2013-01-11 05:12:30 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
// sanitize the results
|
2013-01-11 05:12:30 +04:00
|
|
|
if (d->g_h < 0) {
|
2013-01-14 04:01:22 +04:00
|
|
|
d->g_h = 0;
|
2013-01-11 05:12:30 +04:00
|
|
|
}
|
|
|
|
if (d->g_w < 0) {
|
2013-01-14 04:01:22 +04:00
|
|
|
d->g_w = 0;
|
2012-12-06 03:26:00 +04:00
|
|
|
}
|
|
|
|
|
2013-01-15 04:54:54 +04:00
|
|
|
//printf("window_get_grect %d:", which);
|
|
|
|
//dbg_grect("", d);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-12-06 03:26:00 +04:00
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
void window_open_search(ROOTWIN *rootwin, bool reformat)
|
2013-01-16 06:21:35 +04:00
|
|
|
{
|
|
|
|
struct browser_window *bw;
|
2013-01-17 04:18:27 +04:00
|
|
|
struct gui_window *gw;
|
2013-01-16 06:21:35 +04:00
|
|
|
GRECT area;
|
2013-01-17 04:18:27 +04:00
|
|
|
OBJECT *obj;
|
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
LOG("rootwin %p", rootwin);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
gw = rootwin->active_gui_window;
|
|
|
|
bw = gw->browser->bw;
|
2013-01-23 01:28:20 +04:00
|
|
|
obj = toolbar_get_form(rootwin->toolbar);
|
2013-01-16 06:21:35 +04:00
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
if (gw->search == NULL) {
|
2014-10-25 18:34:22 +04:00
|
|
|
gw->search = nsatari_search_session_create(obj, gw);
|
2013-01-17 04:18:27 +04:00
|
|
|
}
|
2013-01-16 06:21:35 +04:00
|
|
|
|
|
|
|
toolbar_set_visible(rootwin->toolbar, TOOLBAR_AREA_SEARCH, true);
|
2013-01-17 04:18:27 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_TOOLBAR, &area);
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_set_toolbar_size(rootwin->win, area.g_h);
|
2013-01-16 06:21:35 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_SEARCH, &area);
|
|
|
|
window_schedule_redraw_grect(rootwin, &area);
|
2013-01-23 01:28:20 +04:00
|
|
|
window_process_redraws(rootwin);
|
|
|
|
window_set_focus(rootwin, SEARCH_INPUT, NULL);
|
|
|
|
|
2013-01-16 06:21:35 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &area);
|
2013-01-17 04:18:27 +04:00
|
|
|
if (reformat) {
|
|
|
|
browser_window_reformat(bw, false, area.g_w, area.g_h);
|
|
|
|
}
|
2013-01-16 06:21:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void window_close_search(ROOTWIN *rootwin)
|
|
|
|
{
|
|
|
|
struct browser_window *bw;
|
2013-01-17 04:18:27 +04:00
|
|
|
struct gui_window *gw;
|
2013-01-16 06:21:35 +04:00
|
|
|
GRECT area;
|
2017-01-21 19:49:14 +03:00
|
|
|
//OBJECT *obj;
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
gw = rootwin->active_gui_window;
|
|
|
|
bw = gw->browser->bw;
|
2017-01-21 19:49:14 +03:00
|
|
|
//obj = gemtk_obj_get_tree(TOOLBAR);
|
2013-01-17 04:18:27 +04:00
|
|
|
|
|
|
|
if (gw->search != NULL) {
|
|
|
|
nsatari_search_session_destroy(gw->search);
|
|
|
|
gw->search = NULL;
|
|
|
|
}
|
2013-01-16 06:21:35 +04:00
|
|
|
|
|
|
|
toolbar_set_visible(rootwin->toolbar, TOOLBAR_AREA_SEARCH, false);
|
2013-01-17 04:18:27 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_TOOLBAR, &area);
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_set_toolbar_size(rootwin->win, area.g_h);
|
2013-01-16 06:21:35 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &area);
|
|
|
|
browser_window_reformat(bw, false, area.g_w, area.g_h);
|
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
/**
|
|
|
|
* Redraw the favicon
|
|
|
|
*/
|
2013-04-12 03:04:21 +04:00
|
|
|
void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip_ro)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2013-04-12 03:04:21 +04:00
|
|
|
GRECT work, visible, clip;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(rootwin);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-17 05:44:13 +04:00
|
|
|
//printf("window_redraw_favicon: root: %p, win: %p\n", rootwin, rootwin->win);
|
2012-12-06 04:38:49 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_clear(rootwin->win);
|
|
|
|
gemtk_wm_get_grect(rootwin->win, GEMTK_WM_AREA_WORK, &work);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-04-12 03:04:21 +04:00
|
|
|
if (clip_ro == NULL) {
|
|
|
|
clip = work;
|
2012-11-27 05:12:09 +04:00
|
|
|
} else {
|
2013-04-12 03:04:21 +04:00
|
|
|
clip = *clip_ro;
|
|
|
|
if(!rc_intersect(&work, &clip)) {
|
2012-11-27 05:12:09 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2013-04-12 03:04:21 +04:00
|
|
|
//dbg_grect("favicon redrw area", clip);
|
|
|
|
//dbg_grect("favicon work area", &work);
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
if (rootwin->icon == NULL) {
|
2013-01-17 05:44:13 +04:00
|
|
|
//printf("window_redraw_favicon OBJCTREE\n");
|
2013-04-12 03:04:21 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
OBJECT * tree = gemtk_obj_get_tree(ICONIFY);
|
2012-11-19 02:22:43 +04:00
|
|
|
tree->ob_x = work.g_x;
|
|
|
|
tree->ob_y = work.g_y;
|
|
|
|
tree->ob_width = work.g_w;
|
|
|
|
tree->ob_height = work.g_h;
|
2013-04-12 03:04:21 +04:00
|
|
|
|
|
|
|
wind_get_grect(rootwin->aes_handle, WF_FIRSTXYWH, &visible);
|
|
|
|
while (visible.g_h > 0 && visible.g_w > 0) {
|
|
|
|
|
|
|
|
if (rc_intersect(&clip, &visible)) {
|
|
|
|
//dbg_grect("redraw vis area", &visible);
|
|
|
|
objc_draw(tree, 0, 8, visible.g_x, visible.g_y, visible.g_w,
|
|
|
|
visible.g_h);
|
|
|
|
} else {
|
|
|
|
//dbg_grect("redraw vis area outside", &visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
wind_get_grect(rootwin->aes_handle, WF_NEXTXYWH, &visible);
|
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
} else {
|
2013-04-09 02:40:21 +04:00
|
|
|
//printf("window_redraw_favicon image %p\n", rootwin->icon);
|
2013-04-12 03:04:21 +04:00
|
|
|
VdiHdl plot_vdi_handle = plot_get_vdi_handle();
|
|
|
|
short pxy[4];
|
2012-11-19 02:22:43 +04:00
|
|
|
int xoff=0;
|
2013-04-12 03:04:21 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
if (work.g_w > work.g_h) {
|
|
|
|
xoff = ((work.g_w-work.g_h)/2);
|
|
|
|
work.g_w = work.g_h;
|
|
|
|
}
|
2017-02-12 21:01:46 +03:00
|
|
|
plot_set_dimensions(&rootwin_rdrw_ctx,
|
|
|
|
work.g_x+xoff,
|
|
|
|
work.g_y,
|
|
|
|
work.g_w,
|
|
|
|
work.g_h);
|
2013-04-12 03:04:21 +04:00
|
|
|
|
|
|
|
wind_get_grect(rootwin->aes_handle, WF_FIRSTXYWH, &visible);
|
|
|
|
while (visible.g_h > 0 && visible.g_w > 0) {
|
|
|
|
|
|
|
|
if (rc_intersect(&clip, &visible)) {
|
|
|
|
|
|
|
|
//dbg_grect("redraw vis area", &visible);
|
|
|
|
|
|
|
|
// Manually clip drawing region:
|
|
|
|
pxy[0] = visible.g_x;
|
|
|
|
pxy[1] = visible.g_y;
|
|
|
|
pxy[2] = pxy[0] + visible.g_w-1;
|
|
|
|
pxy[3] = pxy[1] + visible.g_h-1;
|
|
|
|
vs_clip(plot_vdi_handle, 1, (short*)&pxy);
|
|
|
|
//dbg_pxy("vdi clip", (short*)&pxy);
|
|
|
|
|
2017-02-12 21:01:46 +03:00
|
|
|
rootwin_rdrw_ctx.plot->bitmap(&rootwin_rdrw_ctx,
|
|
|
|
rootwin->icon,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
work.g_w,
|
|
|
|
work.g_h,
|
|
|
|
0xffffff,
|
|
|
|
0);
|
2013-04-12 03:04:21 +04:00
|
|
|
} else {
|
|
|
|
//dbg_grect("redraw vis area outside", &visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
wind_get_grect(rootwin->aes_handle, WF_NEXTXYWH, &visible);
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
/***
|
|
|
|
* Schedule an redraw area, redraw requests during redraw are
|
|
|
|
* not optimized (merged) into other areas, so that the redraw
|
|
|
|
* functions can spot the change.
|
|
|
|
*
|
|
|
|
*/
|
2012-11-29 00:30:24 +04:00
|
|
|
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
|
|
|
|
{
|
|
|
|
GRECT work;
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
//dbg_grect("window_schedule_redraw_grect input ", area);
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_get_grect(rootwin->win, GEMTK_WM_AREA_WORK, &work);
|
2012-12-06 04:07:11 +04:00
|
|
|
if(!rc_intersect(area, &work))
|
2013-01-02 01:08:19 +04:00
|
|
|
return;
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-12-04 04:32:43 +04:00
|
|
|
//dbg_grect("window_schedule_redraw_grect intersection ", &work);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
redraw_slot_schedule_grect(&rootwin->redraw_slots, &work, redraw_active);
|
2012-11-29 00:30:24 +04:00
|
|
|
}
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
|
|
|
|
GRECT *clip,
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s * slid,
|
2012-11-30 06:20:52 +04:00
|
|
|
struct browser_window *bw)
|
2012-11-29 00:30:24 +04:00
|
|
|
{
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
struct rect redraw_area;
|
|
|
|
GRECT content_area_rel;
|
2013-12-22 07:52:18 +04:00
|
|
|
float oldscale = 1.0;
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
//dbg_grect("browser redraw, content area", content_area);
|
|
|
|
//dbg_grect("browser redraw, content clip", clip);
|
|
|
|
|
2017-02-12 21:01:46 +03:00
|
|
|
plot_set_dimensions(&rootwin_rdrw_ctx,
|
|
|
|
content_area->g_x, content_area->g_y,
|
2012-11-30 06:20:52 +04:00
|
|
|
content_area->g_w, content_area->g_h);
|
2014-07-06 14:01:39 +04:00
|
|
|
oldscale = plot_set_scale(browser_window_get_scale(rootwin->active_gui_window->browser->bw));
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
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;
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
|
2012-12-04 04:32:43 +04:00
|
|
|
//dbg_grect("browser redraw, relative plot coords:", &content_area_rel);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
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;
|
2012-11-30 06:20:52 +04:00
|
|
|
redraw_area.y1 = content_area_rel.g_y + content_area_rel.g_h;
|
|
|
|
|
2017-02-12 21:01:46 +03:00
|
|
|
rootwin_rdrw_ctx.plot->clip(&rootwin_rdrw_ctx, &redraw_area);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2012-12-04 04:32:43 +04:00
|
|
|
//dbg_rect("rdrw area", &redraw_area);
|
|
|
|
|
2012-12-01 19:18:02 +04:00
|
|
|
browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
|
2013-01-02 01:08:19 +04:00
|
|
|
-(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx);
|
2013-12-22 07:52:18 +04:00
|
|
|
|
|
|
|
plot_set_scale(oldscale);
|
2013-01-02 01:08:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void window_place_caret(ROOTWIN *rootwin, short mode, int content_x,
|
|
|
|
int content_y, int h, GRECT *work)
|
|
|
|
{
|
|
|
|
struct s_caret *caret = &rootwin->caret;
|
2013-01-22 05:33:27 +04:00
|
|
|
VdiHdl vh = gemtk_wm_get_vdi_handle(rootwin->win);
|
2013-01-02 01:08:19 +04:00
|
|
|
short pxy[8];
|
|
|
|
GRECT mywork, caret_pos;
|
|
|
|
MFDB screen;
|
2014-05-21 00:06:00 +04:00
|
|
|
int scroll_x, scroll_y;
|
2013-01-02 01:08:19 +04:00
|
|
|
uint16_t *fd_addr;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid;
|
2013-01-07 23:04:44 +04:00
|
|
|
short colors[2] = {G_BLACK, G_WHITE};
|
2013-01-02 01:08:19 +04:00
|
|
|
bool render_required = false;
|
|
|
|
|
|
|
|
// avoid duplicate draw of the caret:
|
|
|
|
if (mode == 1 &&(caret->state&CARET_STATE_VISIBLE)!=0) {
|
|
|
|
if (caret->dimensions.g_x == content_x
|
|
|
|
&& caret->dimensions.g_y == content_y
|
|
|
|
&& caret->dimensions.g_h == h) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(work == NULL) {
|
|
|
|
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &mywork);
|
|
|
|
work = &mywork;
|
|
|
|
}
|
2013-01-22 05:33:27 +04:00
|
|
|
slid = gemtk_wm_get_scroll_info(rootwin->win);
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
scroll_x = slid->x_pos * slid->x_unit_px;
|
|
|
|
scroll_y = slid->y_pos * slid->y_unit_px;
|
|
|
|
|
|
|
|
init_mfdb(0, 1, h, 0, &screen);
|
|
|
|
|
|
|
|
// enable clipping:
|
|
|
|
pxy[0] = work->g_x;
|
|
|
|
pxy[1] = work->g_y;
|
|
|
|
pxy[2] = pxy[0] + work->g_w - 1;
|
|
|
|
pxy[3] = pxy[1] + work->g_h - 1;
|
|
|
|
vs_clip(vh, 1, pxy);
|
|
|
|
|
|
|
|
// when the caret is visible, undraw it:
|
|
|
|
if (caret->symbol.fd_addr != NULL
|
|
|
|
&& (caret->state&CARET_STATE_VISIBLE)!=0) {
|
|
|
|
|
|
|
|
caret_pos.g_x = work->g_x + (caret->dimensions.g_x - scroll_x);
|
|
|
|
caret_pos.g_y = work->g_y + (caret->dimensions.g_y - scroll_y);
|
|
|
|
caret_pos.g_w = caret->dimensions.g_w;
|
|
|
|
caret_pos.g_h = caret->dimensions.g_h;
|
|
|
|
|
|
|
|
if (rc_intersect(work, &caret_pos)) {
|
|
|
|
|
|
|
|
pxy[0] = 0;
|
|
|
|
pxy[1] = 0;
|
|
|
|
pxy[2] = caret->dimensions.g_w-1;
|
|
|
|
pxy[3] = caret->dimensions.g_h-1;
|
|
|
|
|
|
|
|
pxy[4] = caret_pos.g_x;
|
|
|
|
pxy[5] = caret_pos.g_y;
|
|
|
|
pxy[6] = pxy[4] + caret_pos.g_w-1;
|
|
|
|
pxy[7] = pxy[5] + caret_pos.g_h-1;
|
|
|
|
|
|
|
|
vrt_cpyfm(vh, MD_XOR, pxy, &caret->symbol, &screen, colors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mode == 0) {
|
|
|
|
// update state:
|
|
|
|
caret->state &= ~CARET_STATE_VISIBLE;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// when the caret isn't allocated, create it:
|
|
|
|
if (caret->symbol.fd_addr == NULL) {
|
|
|
|
caret->fd_size = init_mfdb(1, 16, h, MFDB_FLAG_ZEROMEM,
|
|
|
|
&caret->symbol);
|
|
|
|
render_required = true;
|
|
|
|
} else {
|
|
|
|
// the caret may need more memory:
|
|
|
|
if (caret->dimensions.g_h < h) {
|
|
|
|
caret->fd_size = init_mfdb(1, 16, h, MFDB_FLAG_NOALLOC,
|
|
|
|
&caret->symbol);
|
|
|
|
realloc(caret->symbol.fd_addr, caret->fd_size);
|
|
|
|
render_required = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// set new caret position:
|
|
|
|
caret->dimensions.g_x = content_x;
|
|
|
|
caret->dimensions.g_y = content_y;
|
|
|
|
caret->dimensions.g_w = 1;
|
|
|
|
caret->dimensions.g_h = h;
|
|
|
|
|
|
|
|
// draw the caret into the mfdb buffer:
|
|
|
|
if (render_required) {
|
2014-05-21 00:06:00 +04:00
|
|
|
int i;
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
assert(caret->symbol.fd_nplanes == 1);
|
|
|
|
assert(caret->symbol.fd_w == 16);
|
|
|
|
|
|
|
|
// draw an vertical line into the mfdb buffer
|
|
|
|
fd_addr = (uint16_t*)caret->symbol.fd_addr;
|
|
|
|
for(i = 0; i<caret->symbol.fd_h; i++) {
|
|
|
|
fd_addr[i] = 0xFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert content coords to screen coords:
|
|
|
|
|
|
|
|
caret_pos.g_x = work->g_x + (content_x - scroll_x);
|
|
|
|
caret_pos.g_y = work->g_y + (content_y - scroll_y);
|
|
|
|
caret_pos.g_w = caret->dimensions.g_w;
|
|
|
|
caret_pos.g_h = caret->dimensions.g_h;
|
|
|
|
|
2013-01-03 04:22:38 +04:00
|
|
|
if (rc_intersect(work, &caret_pos) && redraw_active == false) {
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
pxy[0] = 0;
|
|
|
|
pxy[1] = 0;
|
|
|
|
pxy[2] = caret->dimensions.g_w-1;
|
|
|
|
pxy[3] = caret->dimensions.g_h-1;
|
|
|
|
|
|
|
|
pxy[4] = caret_pos.g_x;
|
|
|
|
pxy[5] = caret_pos.g_y;
|
|
|
|
pxy[6] = pxy[4] + caret_pos.g_w-1;
|
|
|
|
pxy[7] = pxy[5] + caret_pos.g_h-1;
|
|
|
|
|
|
|
|
//dbg_pxy("caret screen coords (md_repl)", &pxy[4]);
|
|
|
|
|
2013-12-28 04:24:01 +04:00
|
|
|
// TODO: walk rectangle list (use MD_REPLACE then)
|
2013-01-02 01:08:19 +04:00
|
|
|
// draw caret to screen coords:
|
|
|
|
vrt_cpyfm(vh, /*MD_REPLACE*/ MD_XOR, pxy, &caret->symbol, &screen, colors);
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
// update state:
|
|
|
|
caret->state |= CARET_STATE_VISIBLE;
|
2013-01-02 01:08:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
// disable clipping:
|
2013-01-22 05:33:27 +04:00
|
|
|
vs_clip(gemtk_wm_get_vdi_handle(rootwin->win), 0, pxy);
|
2012-11-29 00:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void window_process_redraws(ROOTWIN * rootwin)
|
|
|
|
{
|
2014-09-16 01:27:15 +04:00
|
|
|
GRECT visible_ro, tb_area, content_area;
|
2012-12-21 03:56:50 +04:00
|
|
|
short i;
|
2013-01-14 04:01:22 +04:00
|
|
|
short scroll_x=0, scroll_y=0;
|
2013-01-02 01:08:19 +04:00
|
|
|
bool caret_rdrw_required = false;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid =NULL;
|
2013-01-02 01:08:19 +04:00
|
|
|
int caret_h = 0;
|
|
|
|
struct s_caret *caret = &rootwin->caret;
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
redraw_active = true;
|
2012-11-29 00:30:24 +04:00
|
|
|
|
2013-03-11 04:16:37 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_TOOLBAR, &tb_area);
|
2013-01-22 05:33:27 +04:00
|
|
|
//gemtk_wm_set_toolbar_size(rootwin->win, tb_area.g_h);
|
2013-01-14 04:01:22 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &content_area);
|
2012-11-29 00:30:24 +04:00
|
|
|
|
2012-12-04 04:32:43 +04:00
|
|
|
//dbg_grect("content area", &content_area);
|
2013-01-17 04:18:27 +04:00
|
|
|
//dbg_grect("window_process_redraws toolbar area", &tb_area);
|
2012-12-04 04:32:43 +04:00
|
|
|
|
2013-01-02 01:08:19 +04:00
|
|
|
while(plot_lock() == false);
|
|
|
|
|
|
|
|
if (((rootwin->caret.state & CARET_STATE_ENABLED)!=0)
|
|
|
|
&& rootwin->caret.dimensions.g_h > 0) {
|
|
|
|
// hide caret:
|
|
|
|
window_place_caret(rootwin, 0, -1, -1, -1, &content_area);
|
|
|
|
}
|
2013-01-16 06:21:35 +04:00
|
|
|
/*
|
2012-12-03 03:07:47 +04:00
|
|
|
short pxy_clip[4];
|
|
|
|
pxy_clip[0] = tb_area.g_x;
|
|
|
|
pxy_clip[0] = tb_area.g_y;
|
|
|
|
pxy_clip[0] = pxy_clip[0] + tb_area.g_w + content_area.g_w - 1;
|
|
|
|
pxy_clip[0] = pxy_clip[1] + tb_area.g_h + content_area.g_h - 1;
|
2013-01-22 05:33:27 +04:00
|
|
|
vs_clip(gemtk_wm_get_vdi_handle(rootwin->win), 1, pxy_clip);
|
|
|
|
//gemtk_wm_clear(rootwin->win);
|
2013-01-16 06:21:35 +04:00
|
|
|
*/
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_get_grect(rootwin->aes_handle, WF_FIRSTXYWH, &visible_ro);
|
2012-11-29 00:30:24 +04:00
|
|
|
while (visible_ro.g_w > 0 && visible_ro.g_h > 0) {
|
2013-12-28 22:42:40 +04:00
|
|
|
plot_set_abs_clipping(&visible_ro);
|
2012-11-29 00:30:24 +04:00
|
|
|
|
2013-04-15 02:36:57 +04:00
|
|
|
//dbg_grect("visible ", &visible_ro);
|
|
|
|
|
2012-11-29 00:30:24 +04:00
|
|
|
// TODO: optimze the rectangle list -
|
|
|
|
// remove rectangles which were completly inside the visible area.
|
|
|
|
// that way we don't have to loop over again...
|
2012-12-01 19:18:02 +04:00
|
|
|
for(i=0; i<rootwin->redraw_slots.areas_used; i++) {
|
2012-11-29 00:30:24 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
GRECT rdrw_area_ro = {
|
2012-12-01 19:18:02 +04:00
|
|
|
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
|
2012-11-29 00:30:24 +04:00
|
|
|
};
|
2013-04-15 02:36:57 +04:00
|
|
|
|
|
|
|
if (!rc_intersect(&visible_ro, &rdrw_area_ro)) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-11-30 06:20:52 +04:00
|
|
|
GRECT rdrw_area = rdrw_area_ro;
|
|
|
|
|
|
|
|
if (rc_intersect(&tb_area, &rdrw_area)) {
|
2013-01-16 06:21:35 +04:00
|
|
|
toolbar_redraw(rootwin->toolbar, &rdrw_area);
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
2012-11-29 00:30:24 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
rdrw_area = rdrw_area_ro;
|
|
|
|
if (rc_intersect(&content_area, &rdrw_area)) {
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
if(slid == NULL) {
|
2013-01-22 05:33:27 +04:00
|
|
|
slid = gemtk_wm_get_scroll_info(rootwin->win);
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
scroll_x = slid->x_pos * slid->x_unit_px;
|
2013-01-14 04:01:22 +04:00
|
|
|
scroll_y = slid->y_pos * slid->y_unit_px;
|
2013-01-02 01:08:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
window_redraw_content(rootwin, &content_area, &rdrw_area,
|
|
|
|
slid,
|
2012-12-01 19:18:02 +04:00
|
|
|
rootwin->active_gui_window->browser->bw);
|
2013-01-02 01:08:19 +04:00
|
|
|
if (((rootwin->caret.state & CARET_STATE_ENABLED)!=0)) {
|
|
|
|
|
|
|
|
GRECT caret_pos;
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2013-01-02 01:08:19 +04:00
|
|
|
caret_pos.g_x = content_area.g_x +
|
|
|
|
(caret->dimensions.g_x - scroll_x);
|
|
|
|
caret_pos.g_y = content_area.g_y +
|
|
|
|
(caret->dimensions.g_y - scroll_y);
|
|
|
|
caret_pos.g_w = caret->dimensions.g_w;
|
|
|
|
caret_pos.g_h = caret->dimensions.g_h;
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
if (gemtk_rc_intersect_ro(&caret_pos, &content_area)) {
|
2013-01-02 01:08:19 +04:00
|
|
|
caret_rdrw_required = true;
|
|
|
|
}
|
|
|
|
}
|
2013-01-16 06:21:35 +04:00
|
|
|
|
2013-01-02 01:08:19 +04:00
|
|
|
}
|
2012-11-29 00:30:24 +04:00
|
|
|
}
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_get_grect(rootwin->aes_handle, WF_NEXTXYWH, &visible_ro);
|
2012-11-29 00:30:24 +04:00
|
|
|
}
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
|
|
|
|
// disable clipping:
|
2013-01-22 05:33:27 +04:00
|
|
|
//vs_clip(gemtk_wm_get_vdi_handle(rootwin->win), 0, pxy_clip);
|
2013-01-02 01:08:19 +04:00
|
|
|
|
|
|
|
if (caret_rdrw_required && ((rootwin->caret.state & CARET_STATE_ENABLED)!=0)) {
|
|
|
|
|
|
|
|
// force redraw of caret:
|
|
|
|
caret_h = rootwin->caret.dimensions.g_h;
|
|
|
|
rootwin->caret.dimensions.g_h = 0;
|
2013-01-03 04:22:38 +04:00
|
|
|
redraw_active = false;
|
2013-01-02 01:08:19 +04:00
|
|
|
window_place_caret(rootwin, 1, rootwin->caret.dimensions.g_x,
|
|
|
|
rootwin->caret.dimensions.g_y,
|
|
|
|
caret_h, &content_area);
|
|
|
|
}
|
|
|
|
|
2012-11-29 00:30:24 +04:00
|
|
|
rootwin->redraw_slots.areas_used = 0;
|
2012-11-30 06:20:52 +04:00
|
|
|
redraw_active = false;
|
2012-11-29 00:30:24 +04:00
|
|
|
|
|
|
|
plot_unlock();
|
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* Event Handlers: */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
2014-09-16 01:27:15 +04:00
|
|
|
static void on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area)
|
2012-12-06 03:26:00 +04:00
|
|
|
{
|
2013-01-02 01:08:19 +04:00
|
|
|
int mx, my, sx, sy;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid;
|
2013-01-02 01:08:19 +04:00
|
|
|
struct gui_window *gw;
|
|
|
|
struct browser_window *bw;
|
|
|
|
|
|
|
|
// make relative mouse coords:
|
|
|
|
mx = aes_event_out.emo_mouse.p_x - content_area->g_x;
|
|
|
|
my = aes_event_out.emo_mouse.p_y - content_area->g_y;
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
slid = gemtk_wm_get_scroll_info(rootwin->win);
|
2013-01-02 01:08:19 +04:00
|
|
|
gw = window_get_active_gui_window(rootwin);
|
|
|
|
bw = gw->browser->bw;
|
|
|
|
|
|
|
|
// calculate scroll pos. in pixel:
|
|
|
|
sx = slid->x_pos * slid->x_unit_px;
|
|
|
|
sy = slid->y_pos * slid->y_unit_px;
|
2012-12-06 03:26:00 +04:00
|
|
|
|
|
|
|
browser_window_mouse_track(bw, 0, mx + sx, my + sy);
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2014-09-16 01:27:15 +04:00
|
|
|
static void on_content_mouse_click(ROOTWIN *rootwin)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-12-03 03:07:47 +04:00
|
|
|
short dummy, mbut, mx, my;
|
2012-11-27 05:12:09 +04:00
|
|
|
GRECT cwork;
|
2012-12-03 03:07:47 +04:00
|
|
|
browser_mouse_state bmstate = 0;
|
|
|
|
struct gui_window *gw;
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
gw = window_get_active_gui_window(rootwin);
|
2013-01-17 04:18:27 +04:00
|
|
|
if(input_window != gw) {
|
2012-12-04 04:32:43 +04:00
|
|
|
gui_set_input_gui_window(gw);
|
2012-12-03 03:07:47 +04:00
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
window_set_focus(gw->root, BROWSER, (void*)gw->browser );
|
2013-01-11 00:19:05 +04:00
|
|
|
window_get_grect(gw->root, BROWSER_AREA_CONTENT, &cwork);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
/* 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;
|
2012-12-04 04:32:43 +04:00
|
|
|
//printf("content click at %d,%d\n", mx, my);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
/* Translate GEM key state to netsurf mouse modifier */
|
|
|
|
if ( aes_event_out.emo_kmeta & (K_RSHIFT | K_LSHIFT)) {
|
|
|
|
bmstate |= BROWSER_MOUSE_MOD_1;
|
|
|
|
} else {
|
|
|
|
bmstate &= ~(BROWSER_MOUSE_MOD_1);
|
|
|
|
}
|
|
|
|
if ( (aes_event_out.emo_kmeta & K_CTRL) ) {
|
|
|
|
bmstate |= BROWSER_MOUSE_MOD_2;
|
|
|
|
} else {
|
|
|
|
bmstate &= ~(BROWSER_MOUSE_MOD_2);
|
|
|
|
}
|
|
|
|
if ( (aes_event_out.emo_kmeta & K_ALT) ) {
|
|
|
|
bmstate |= BROWSER_MOUSE_MOD_3;
|
|
|
|
} else {
|
|
|
|
bmstate &= ~(BROWSER_MOUSE_MOD_3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert component coords to scrolled content coords: */
|
2013-01-22 05:33:27 +04:00
|
|
|
slid = gemtk_wm_get_scroll_info(rootwin->win);
|
2012-12-04 04:32:43 +04:00
|
|
|
int sx_origin = mx;
|
|
|
|
int sy_origin = my;
|
2012-12-03 03:07:47 +04:00
|
|
|
|
|
|
|
short rel_cur_x, rel_cur_y;
|
|
|
|
short prev_x=sx_origin, prev_y=sy_origin;
|
|
|
|
bool dragmode = false;
|
|
|
|
|
|
|
|
/* Detect left mouse button state and compare with event state: */
|
|
|
|
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
|
2012-12-03 04:27:33 +04:00
|
|
|
if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
|
2012-12-03 03:07:47 +04:00
|
|
|
/* Mouse still pressed, report drag */
|
2012-12-04 04:32:43 +04:00
|
|
|
rel_cur_x = (rel_cur_x - cwork.g_x);
|
|
|
|
rel_cur_y = (rel_cur_y - cwork.g_y);
|
2012-12-03 03:07:47 +04:00
|
|
|
browser_window_mouse_click( gw->browser->bw,
|
|
|
|
BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1,
|
2012-12-04 04:32:43 +04:00
|
|
|
rel_cur_x + slid->x_pos * slid->x_unit_px,
|
|
|
|
rel_cur_y + slid->y_pos * slid->y_unit_px);
|
2012-12-03 03:07:47 +04:00
|
|
|
do {
|
|
|
|
// 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,
|
2012-12-04 04:32:43 +04:00
|
|
|
rel_cur_x + slid->x_pos * slid->x_unit_px,
|
|
|
|
rel_cur_y + slid->y_pos * slid->y_unit_px);
|
2012-12-03 03:07:47 +04:00
|
|
|
prev_x = rel_cur_x;
|
|
|
|
prev_y = rel_cur_y;
|
|
|
|
dragmode = true;
|
|
|
|
} else {
|
|
|
|
if( dragmode == false ) {
|
|
|
|
browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
|
2012-12-04 04:32:43 +04:00
|
|
|
rel_cur_x + slid->x_pos * slid->x_unit_px,
|
|
|
|
rel_cur_y + slid->y_pos * slid->y_unit_px);
|
2012-12-03 03:07:47 +04:00
|
|
|
}
|
|
|
|
}
|
2012-12-03 04:27:33 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
// we may need to process scrolling:
|
2012-12-03 04:27:33 +04:00
|
|
|
// TODO: this doesn't work, because gemtk schedules redraw via
|
|
|
|
// AES window messages but we do not process them right here...
|
2012-12-04 04:32:43 +04:00
|
|
|
if (rootwin->redraw_slots.areas_used > 0) {
|
|
|
|
window_process_redraws(rootwin);
|
|
|
|
}
|
|
|
|
evnt_timer(150);
|
2012-12-03 04:27:33 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
|
2012-12-04 04:32:43 +04:00
|
|
|
rel_cur_x = (rel_cur_x - cwork.g_x);
|
|
|
|
rel_cur_y = (rel_cur_y - cwork.g_y);
|
2012-12-03 03:07:47 +04:00
|
|
|
} while( mbut & 1 );
|
2012-12-04 04:32:43 +04:00
|
|
|
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);
|
2012-12-03 03:07:47 +04:00
|
|
|
} else {
|
|
|
|
/* Right button pressed? */
|
2012-12-03 04:27:33 +04:00
|
|
|
if ((aes_event_out.emo_mbutton & 2 ) ) {
|
2012-12-06 03:26:00 +04:00
|
|
|
context_popup(gw, aes_event_out.emo_mouse.p_x,
|
|
|
|
aes_event_out.emo_mouse.p_y);
|
2012-12-03 03:07:47 +04:00
|
|
|
} else {
|
|
|
|
browser_window_mouse_click(gw->browser->bw,
|
|
|
|
bmstate|BROWSER_MOUSE_PRESS_1,
|
2012-12-04 04:32:43 +04:00
|
|
|
sx_origin + slid->x_pos * slid->x_unit_px,
|
|
|
|
sy_origin + slid->y_pos * slid->y_unit_px);
|
2012-12-03 03:07:47 +04:00
|
|
|
browser_window_mouse_click(gw->browser->bw,
|
|
|
|
bmstate|BROWSER_MOUSE_CLICK_1,
|
2012-12-04 04:32:43 +04:00
|
|
|
sx_origin + slid->x_pos * slid->x_unit_px,
|
|
|
|
sy_origin + slid->y_pos * slid->y_unit_px);
|
2012-12-03 03:07:47 +04:00
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2012-12-03 04:27:33 +04:00
|
|
|
if (rootwin->redraw_slots.areas_used > 0) {
|
2012-12-04 04:32:43 +04:00
|
|
|
window_process_redraws(rootwin);
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
/*
|
|
|
|
Report keypress to browser component.
|
|
|
|
parameter:
|
|
|
|
- unsigned short nkc ( CFLIB normalised key code )
|
|
|
|
*/
|
2014-10-25 19:10:49 +04:00
|
|
|
static bool on_content_keypress(struct gui_window *gw, unsigned short nkc)
|
2012-12-03 03:07:47 +04:00
|
|
|
{
|
|
|
|
bool r = false;
|
|
|
|
unsigned char ascii = (nkc & 0xFF);
|
|
|
|
long ucs4;
|
|
|
|
long ik = nkc_to_input_key( nkc, &ucs4 );
|
|
|
|
|
|
|
|
// pass event to specific control?
|
|
|
|
|
|
|
|
if (ik == 0) {
|
|
|
|
if (ascii >= 9) {
|
2014-10-25 19:10:49 +04:00
|
|
|
r = browser_window_key_press(gw->browser->bw, ucs4);
|
2012-12-03 03:07:47 +04:00
|
|
|
}
|
|
|
|
} else {
|
2014-10-25 19:10:49 +04:00
|
|
|
r = browser_window_key_press(gw->browser->bw, ik);
|
2012-12-03 03:07:47 +04:00
|
|
|
if (r == false) {
|
|
|
|
|
|
|
|
GRECT g;
|
2014-10-25 19:10:49 +04:00
|
|
|
GUIWIN * w = gw->root->win;
|
|
|
|
window_get_grect(gw->root, BROWSER_AREA_CONTENT, &g);
|
2012-12-03 03:07:47 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(w);
|
2012-12-03 03:07:47 +04:00
|
|
|
|
|
|
|
switch( ik ) {
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_LINE_START:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_HSLIDER, -(g.g_w/slid->x_unit_px),
|
2012-12-03 03:07:47 +04:00
|
|
|
false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_LINE_END:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_HSLIDER, (g.g_w/slid->x_unit_px),
|
2012-12-03 03:07:47 +04:00
|
|
|
false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_PAGE_UP:
|
2013-04-11 02:46:39 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_VSLIDER, -(g.g_h/slid->y_unit_px),
|
2012-12-03 03:07:47 +04:00
|
|
|
false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_PAGE_DOWN:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_VSLIDER, (g.g_h/slid->y_unit_px),
|
2012-12-03 03:07:47 +04:00
|
|
|
false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_RIGHT:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_HSLIDER, -1, false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_LEFT:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_HSLIDER, 1, false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_UP:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_VSLIDER, -1, false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_DOWN:
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_scroll(w, GEMTK_WM_VSLIDER, 1, false);
|
2013-04-09 02:40:21 +04:00
|
|
|
r = true;
|
2012-12-03 03:07:47 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-27 12:36:19 +03:00
|
|
|
case NS_KEY_TEXT_START:
|
2014-10-25 19:10:49 +04:00
|
|
|
window_scroll_by(gw->root, 0, 0);
|
2013-04-13 17:34:08 +04:00
|
|
|
r = true;
|
|
|
|
break;
|
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_update_slider(w, GEMTK_WM_VSLIDER|GEMTK_WM_HSLIDER);
|
2012-12-03 03:07:47 +04:00
|
|
|
}
|
|
|
|
}
|
2012-12-01 19:18:02 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
return(r);
|
2012-12-01 19:18:02 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
static short on_window_key_input(ROOTWIN *rootwin, unsigned short nkc)
|
2012-12-01 19:18:02 +04:00
|
|
|
{
|
|
|
|
bool done = false;
|
|
|
|
struct gui_window * gw = window_get_active_gui_window(rootwin);
|
|
|
|
|
|
|
|
if( gw == NULL )
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
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 {
|
2013-01-31 22:22:35 +04:00
|
|
|
if( window_widget_has_focus(input_window->root, BROWSER,
|
|
|
|
(void*)input_window->browser)) {
|
2014-10-25 19:10:49 +04:00
|
|
|
done = on_content_keypress(input_window, nkc);
|
2013-01-31 22:22:35 +04:00
|
|
|
}
|
|
|
|
else if(window_widget_has_focus(input_window->root, SEARCH_INPUT, NULL)) {
|
|
|
|
OBJECT * obj;
|
|
|
|
obj = toolbar_get_form(input_window->root->toolbar);
|
|
|
|
obj[TOOLBAR_BT_SEARCH_FWD].ob_state &= ~OS_DISABLED;
|
|
|
|
obj[TOOLBAR_BT_SEARCH_BACK].ob_state &= ~OS_DISABLED;
|
|
|
|
window_schedule_redraw_grect(input_window->root,
|
|
|
|
gemtk_obj_screen_rect(obj, TOOLBAR_BT_SEARCH_FWD));
|
|
|
|
window_schedule_redraw_grect(input_window->root,
|
|
|
|
gemtk_obj_screen_rect(obj, TOOLBAR_BT_SEARCH_BACK));
|
|
|
|
}
|
2012-12-01 19:18:02 +04:00
|
|
|
}
|
|
|
|
return((done==true) ? 1 : 0);
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
static void on_redraw(ROOTWIN *rootwin, short msg[8])
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-15 04:54:54 +04:00
|
|
|
//dbg_grect("on_redraw", &clip);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
if(gemtk_wm_get_state(rootwin->win) & GEMTK_WM_STATUS_ICONIFIED) {
|
2013-12-22 07:52:18 +04:00
|
|
|
// TODO: remove asignment:
|
2013-04-12 03:04:21 +04:00
|
|
|
window_redraw_favicon(rootwin, NULL);
|
2012-11-19 02:22:43 +04:00
|
|
|
} else {
|
2012-12-01 19:18:02 +04:00
|
|
|
window_schedule_redraw_grect(rootwin, &clip);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
static void on_resized(ROOTWIN *rootwin)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2013-01-15 04:31:35 +04:00
|
|
|
GRECT g, work;
|
2012-11-19 02:22:43 +04:00
|
|
|
struct gui_window *gw;
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
gw = window_get_active_gui_window(rootwin);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
//printf("resized...\n");
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
assert(gw != NULL);
|
|
|
|
|
|
|
|
if(gw == NULL)
|
|
|
|
return;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-12-21 03:56:50 +04:00
|
|
|
wind_get_grect(rootwin->aes_handle, WF_CURRXYWH, &g);
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_wm_get_grect(rootwin->win, GEMTK_WM_AREA_WORK, &work);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-29 00:30:24 +04:00
|
|
|
if (rootwin->loc.g_w != g.g_w || rootwin->loc.g_h != g.g_h) {
|
2013-01-15 04:31:35 +04:00
|
|
|
|
|
|
|
/* resized */
|
|
|
|
toolbar_set_width(rootwin->toolbar, work.g_w);
|
|
|
|
|
2014-10-25 18:44:50 +04:00
|
|
|
if ( browser_window_has_content(gw->browser->bw) ) {
|
2013-04-16 02:53:33 +04:00
|
|
|
browser_window_reformat(gw->browser->bw, true, work.g_w, work.g_h);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
2013-01-15 04:31:35 +04:00
|
|
|
if (rootwin->loc.g_x != g.g_x || rootwin->loc.g_y != g.g_y) {
|
|
|
|
/* moved */
|
|
|
|
toolbar_set_origin(rootwin->toolbar, work.g_x, work.g_y);
|
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2012-11-29 00:30:24 +04:00
|
|
|
rootwin->loc = g;
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 03:07:47 +04:00
|
|
|
static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
|
|
|
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;
|
2012-12-01 19:18:02 +04:00
|
|
|
struct gui_window *gw;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
graf_mkstate(&mx, &my, &bmstat, &mkstat);
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
gw = window_get_active_gui_window(rootwin);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
if( gw == NULL )
|
|
|
|
return;
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
if(gemtk_wm_get_state(rootwin->win) & GEMTK_WM_STATUS_ICONIFIED)
|
2012-12-01 19:18:02 +04:00
|
|
|
return;
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
dd_hdl = gemtk_dd_open( msg[7], DD_OK);
|
2012-11-19 02:22:43 +04:00
|
|
|
if( dd_hdl<0)
|
|
|
|
return; /* pipe not open */
|
|
|
|
memset( ext, 0, 32);
|
|
|
|
strcpy( ext, "ARGS");
|
2013-01-22 05:33:27 +04:00
|
|
|
dd_msg = gemtk_dd_sexts( dd_hdl, ext);
|
2012-11-19 02:22:43 +04:00
|
|
|
if( dd_msg<0)
|
|
|
|
goto error;
|
2013-01-22 05:33:27 +04:00
|
|
|
dd_msg = gemtk_dd_rtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
|
2012-11-19 02:22:43 +04:00
|
|
|
if( size+1 >= PATH_MAX )
|
|
|
|
goto error;
|
|
|
|
if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) {
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_dd_reply(dd_hdl, DD_OK);
|
2012-11-19 02:22:43 +04:00
|
|
|
buff = (char*)malloc(sizeof(char)*(size+1));
|
|
|
|
if (buff != NULL) {
|
2013-11-25 03:09:09 +04:00
|
|
|
if (Fread(dd_hdl, size, buff ) == size) {
|
|
|
|
|
|
|
|
int sx, sy;
|
|
|
|
bool processed = false;
|
|
|
|
GRECT content_area;
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
buff[size] = 0;
|
2013-11-25 03:09:09 +04:00
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
LOG("file: %s, ext: %s, size: %ld dropped at: %d,%d\n", (char *)buff, (char *)&ext, size, mx, my);
|
2013-11-25 03:09:09 +04:00
|
|
|
|
2014-05-21 00:05:11 +04:00
|
|
|
gui_window_get_scroll(gw, &sx, &sy);
|
|
|
|
|
2013-01-03 04:22:38 +04:00
|
|
|
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &content_area);
|
|
|
|
mx = mx - content_area.g_x;
|
|
|
|
my = my - content_area.g_y;
|
2013-11-25 03:09:09 +04:00
|
|
|
if((mx < 0 || mx > content_area.g_w)
|
|
|
|
|| (my < 0 || my > content_area.g_h))
|
2012-11-19 02:22:43 +04:00
|
|
|
return;
|
|
|
|
|
2013-11-25 03:09:09 +04:00
|
|
|
processed = browser_window_drop_file_at_point(gw->browser->bw,
|
|
|
|
mx+sx, my+sy,
|
|
|
|
NULL);
|
|
|
|
if(processed == true) {
|
2014-01-29 01:40:13 +04:00
|
|
|
nserror ret;
|
2013-11-25 03:09:09 +04:00
|
|
|
char *utf8_fn;
|
|
|
|
|
|
|
|
ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
|
2014-01-29 01:40:13 +04:00
|
|
|
if (ret != NSERROR_OK) {
|
2013-11-25 03:09:09 +04:00
|
|
|
free(buff);
|
|
|
|
/* A bad encoding should never happen */
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("utf8_from_local_encoding failed");
|
2014-01-29 01:40:13 +04:00
|
|
|
assert(ret != NSERROR_BAD_ENCODING);
|
2013-11-25 03:09:09 +04:00
|
|
|
/* no memory */
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
processed = browser_window_drop_file_at_point(gw->browser->bw,
|
|
|
|
mx+sx, my+sy,
|
|
|
|
utf8_fn);
|
|
|
|
free(utf8_fn);
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-11-25 03:09:09 +04:00
|
|
|
if(processed == false) {
|
|
|
|
// TODO: use localized string:
|
|
|
|
if(gemtk_msg_box_show(GEMTK_MSG_BOX_CONFIRM, "Open File?") > 0) {
|
|
|
|
nsurl * ns_url = NULL;
|
|
|
|
char * tmp_url = local_file_to_url(buff);
|
|
|
|
if ((tmp_url != NULL)
|
|
|
|
&& nsurl_create(tmp_url, &ns_url) == NSERROR_OK) {
|
2014-05-20 23:42:25 +04:00
|
|
|
browser_window_navigate(gw->browser->bw, ns_url, NULL,
|
|
|
|
BW_NAVIGATE_HISTORY,
|
2013-11-25 03:09:09 +04:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
nsurl_unref(ns_url);
|
|
|
|
}
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error:
|
2013-11-25 03:09:09 +04:00
|
|
|
if (buff) {
|
|
|
|
free(buff);
|
|
|
|
}
|
2013-01-22 05:33:27 +04:00
|
|
|
gemtk_dd_close( dd_hdl);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
static void toolbar_redraw_cb(GUIWIN *win, uint16_t msg, GRECT *clip)
|
|
|
|
{
|
|
|
|
struct rootwin_data_s * ud;
|
|
|
|
|
|
|
|
if (msg != WM_REDRAW) {
|
2013-01-22 05:33:27 +04:00
|
|
|
ud = gemtk_wm_get_user_data(win);
|
2013-01-15 04:31:35 +04:00
|
|
|
|
|
|
|
assert(ud);
|
|
|
|
|
|
|
|
toolbar_redraw(ud->rootwin->toolbar, clip);
|
|
|
|
}
|
|
|
|
}
|