2011-04-04 02:01:37 +04:00
|
|
|
/*
|
2016-10-27 01:19:43 +03:00
|
|
|
* Copyright 2011-2016 Vincent Sanders <vince@netsurf-browser.org>
|
2011-04-04 02:01:37 +04:00
|
|
|
*
|
|
|
|
* 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-10-27 01:19:43 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Main browser window handling for windows win32 frontend.
|
|
|
|
*/
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
#include "utils/config.h"
|
2011-04-04 02:01:37 +04:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
#include <stdbool.h>
|
2011-04-04 02:01:37 +04:00
|
|
|
#include <windows.h>
|
2015-03-13 02:48:53 +03:00
|
|
|
#include <windowsx.h>
|
|
|
|
#include <commctrl.h>
|
2011-04-04 02:01:37 +04:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
#include "utils/errors.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "utils/nsurl.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "content/content.h"
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2016-05-30 13:01:40 +03:00
|
|
|
#include "netsurf/window.h"
|
2016-07-01 16:27:04 +03:00
|
|
|
#include "netsurf/keypress.h"
|
2015-03-13 02:48:53 +03:00
|
|
|
#include "desktop/browser_history.h"
|
|
|
|
|
|
|
|
#include "windows/gui.h"
|
2015-03-13 17:32:06 +03:00
|
|
|
#include "windows/pointers.h"
|
2015-03-13 02:48:53 +03:00
|
|
|
#include "windows/about.h"
|
|
|
|
#include "windows/resourceid.h"
|
|
|
|
#include "windows/findfile.h"
|
|
|
|
#include "windows/windbg.h"
|
|
|
|
#include "windows/drawable.h"
|
|
|
|
#include "windows/font.h"
|
|
|
|
#include "windows/prefs.h"
|
2017-06-02 01:57:09 +03:00
|
|
|
#include "windows/local_history.h"
|
2016-11-19 14:22:22 +03:00
|
|
|
#include "windows/hotlist.h"
|
|
|
|
#include "windows/cookies.h"
|
|
|
|
#include "windows/global_history.h"
|
2011-04-04 02:01:37 +04:00
|
|
|
#include "windows/window.h"
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/**
|
|
|
|
* List of all gui windows
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static struct gui_window *window_list = NULL;
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/**
|
|
|
|
* The main window class name
|
|
|
|
*/
|
2019-12-01 14:27:21 +03:00
|
|
|
static const LPCWSTR windowclassname_main = L"nswsmainwindow";
|
2015-03-13 02:48:53 +03:00
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/**
|
|
|
|
* width of the throbber element
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
#define NSWS_THROBBER_WIDTH 24
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/**
|
|
|
|
* height of the url entry box
|
|
|
|
*/
|
2016-10-30 15:58:43 +03:00
|
|
|
#define NSWS_URLBAR_HEIGHT 23
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/**
|
|
|
|
* height of the Page Information bitmap button
|
|
|
|
*/
|
|
|
|
#define NSW32_PGIBUTTON_HEIGHT 16
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of open windows
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static int open_windows = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-29 19:24:31 +03:00
|
|
|
* create and attach accelerator table to main window
|
|
|
|
*
|
|
|
|
* \param gw gui window context.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2017-02-17 23:44:37 +03:00
|
|
|
static void nsws_window_set_accels(struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
int i, nitems = 13;
|
|
|
|
ACCEL accels[nitems];
|
|
|
|
|
|
|
|
for (i = 0; i < nitems; i++) {
|
|
|
|
accels[i].fVirt = FCONTROL | FVIRTKEY;
|
|
|
|
}
|
|
|
|
|
|
|
|
accels[0].key = 0x51; /* Q */
|
|
|
|
accels[0].cmd = IDM_FILE_QUIT;
|
|
|
|
accels[1].key = 0x4E; /* N */
|
|
|
|
accels[1].cmd = IDM_FILE_OPEN_WINDOW;
|
|
|
|
accels[2].key = VK_LEFT;
|
|
|
|
accels[2].cmd = IDM_NAV_BACK;
|
|
|
|
accels[3].key = VK_RIGHT;
|
|
|
|
accels[3].cmd = IDM_NAV_FORWARD;
|
|
|
|
accels[4].key = VK_UP;
|
|
|
|
accels[4].cmd = IDM_NAV_HOME;
|
|
|
|
accels[5].key = VK_BACK;
|
|
|
|
accels[5].cmd = IDM_NAV_STOP;
|
|
|
|
accels[6].key = VK_SPACE;
|
|
|
|
accels[6].cmd = IDM_NAV_RELOAD;
|
|
|
|
accels[7].key = 0x4C; /* L */
|
|
|
|
accels[7].cmd = IDM_FILE_OPEN_LOCATION;
|
|
|
|
accels[8].key = 0x57; /* w */
|
|
|
|
accels[8].cmd = IDM_FILE_CLOSE_WINDOW;
|
|
|
|
accels[9].key = 0x41; /* A */
|
|
|
|
accels[9].cmd = IDM_EDIT_SELECT_ALL;
|
|
|
|
accels[10].key = VK_F8;
|
|
|
|
accels[10].cmd = IDM_VIEW_SOURCE;
|
|
|
|
accels[11].key = VK_RETURN;
|
|
|
|
accels[11].fVirt = FVIRTKEY;
|
|
|
|
accels[11].cmd = IDC_MAIN_LAUNCH_URL;
|
|
|
|
accels[12].key = VK_F11;
|
|
|
|
accels[12].fVirt = FVIRTKEY;
|
|
|
|
accels[12].cmd = IDM_VIEW_FULLSCREEN;
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
gw->acceltable = CreateAcceleratorTable(accels, nitems);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* creation of a new full browser window
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2016-10-30 15:58:43 +03:00
|
|
|
* \param hInstance The application instance handle.
|
2016-10-29 19:24:31 +03:00
|
|
|
* \param gw gui window context.
|
|
|
|
* \return The newly created window instance.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2016-10-30 15:58:43 +03:00
|
|
|
static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
INITCOMMONCONTROLSEX icc;
|
2019-12-16 03:31:48 +03:00
|
|
|
int xpos = CW_USEDEFAULT;
|
|
|
|
int ypos = CW_USEDEFAULT;
|
|
|
|
int width = CW_USEDEFAULT;
|
|
|
|
int height = CW_USEDEFAULT;
|
|
|
|
|
|
|
|
if ((nsoption_int(window_width) >= 100) &&
|
|
|
|
(nsoption_int(window_height) >= 100) &&
|
|
|
|
(nsoption_int(window_x) >= 0) &&
|
|
|
|
(nsoption_int(window_y) >= 0)) {
|
|
|
|
xpos = nsoption_int(window_x);
|
|
|
|
ypos = nsoption_int(window_y);
|
|
|
|
width = nsoption_int(window_width);
|
|
|
|
height = nsoption_int(window_height);
|
|
|
|
|
|
|
|
NSLOG(netsurf, DEBUG, "Setting Window position %d,%d %d,%d",
|
|
|
|
xpos, ypos, width, height);
|
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
icc.dwSize = sizeof(icc);
|
|
|
|
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
|
|
|
|
#if WINVER > 0x0501
|
|
|
|
icc.dwICC |= ICC_STANDARD_CLASSES;
|
|
|
|
#endif
|
|
|
|
InitCommonControlsEx(&icc);
|
|
|
|
|
|
|
|
gw->mainmenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_MAIN));
|
|
|
|
gw->rclick = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_CONTEXT));
|
|
|
|
|
2019-12-01 14:27:21 +03:00
|
|
|
hwnd = CreateWindowExW(0,
|
2019-12-16 03:31:48 +03:00
|
|
|
windowclassname_main,
|
|
|
|
L"NetSurf Browser",
|
|
|
|
WS_OVERLAPPEDWINDOW |
|
|
|
|
WS_CLIPCHILDREN |
|
|
|
|
WS_CLIPSIBLINGS |
|
|
|
|
CS_DBLCLKS,
|
|
|
|
xpos,
|
|
|
|
ypos,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
NULL,
|
|
|
|
gw->mainmenu,
|
|
|
|
hInstance,
|
|
|
|
(LPVOID)gw);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
if (hwnd == NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Window create failed");
|
2019-12-16 03:31:48 +03:00
|
|
|
} else {
|
|
|
|
nsws_window_set_accels(gw);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-29 19:24:31 +03:00
|
|
|
* toolbar command message handler
|
|
|
|
*
|
|
|
|
* \todo This entire command handler appears superfluous.
|
|
|
|
*
|
|
|
|
* \param gw The graphical window context
|
|
|
|
* \param notification_code The notification code of the message
|
|
|
|
* \param identifier The identifier the command was delivered for
|
|
|
|
* \param ctrl_window The controlling window.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static LRESULT
|
|
|
|
nsws_window_toolbar_command(struct gui_window *gw,
|
2017-02-17 23:44:37 +03:00
|
|
|
int notification_code,
|
|
|
|
int identifier,
|
|
|
|
HWND ctrl_window)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG,
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
"notification_code %d identifier %d ctrl_window %p",
|
|
|
|
notification_code,
|
|
|
|
identifier,
|
|
|
|
ctrl_window);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
switch(identifier) {
|
|
|
|
|
|
|
|
case IDC_MAIN_URLBAR:
|
|
|
|
switch (notification_code) {
|
|
|
|
case EN_CHANGE:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_CHANGE");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_ERRSPACE:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_ERRSPACE");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_HSCROLL:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_HSCROLL");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_KILLFOCUS:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_KILLFOCUS");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_MAXTEXT:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_MAXTEXT");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_SETFOCUS:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_SETFOCUS");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_UPDATE:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_UPDATE");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EN_VSCROLL:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "EN_VSCROLL");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-05-12 02:17:25 +03:00
|
|
|
NSLOG(netsurf, DEBUG, "Unknown notification_code");
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 1; /* unhandled */
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0; /* control message handled */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
/**
|
|
|
|
* calculate the dimensions of the url bar relative to the parent toolbar
|
|
|
|
*
|
|
|
|
* \param hWndParent The parent window of the url bar
|
|
|
|
* \param toolbuttonsize size of the buttons
|
|
|
|
* \param buttonc The number of buttons
|
|
|
|
* \param[out] x The calculated x location
|
|
|
|
* \param[out] y The calculated y location
|
|
|
|
* \param[out] width The calculated width
|
|
|
|
* \param[out] height The calculated height
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
urlbar_dimensions(HWND hWndParent,
|
|
|
|
int toolbuttonsize,
|
|
|
|
int buttonc,
|
|
|
|
int *x,
|
|
|
|
int *y,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
|
|
|
RECT rc;
|
2016-10-30 15:58:43 +03:00
|
|
|
const int cy_edit = NSWS_URLBAR_HEIGHT;
|
2016-10-29 19:24:31 +03:00
|
|
|
|
|
|
|
GetClientRect(hWndParent, &rc);
|
|
|
|
*x = (toolbuttonsize + 1) * (buttonc + 1) + (NSWS_THROBBER_WIDTH>>1);
|
|
|
|
*y = ((((rc.bottom - 1) - cy_edit) >> 1) * 2) / 3;
|
|
|
|
*width = (rc.right - 1) - *x - (NSWS_THROBBER_WIDTH>>1) - NSWS_THROBBER_WIDTH;
|
|
|
|
*height = cy_edit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
/**
|
|
|
|
* callback for toolbar events
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2019-12-16 03:31:48 +03:00
|
|
|
* subclass message handler for toolbar window
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
|
|
|
* \param hwnd win32 window handle message arrived for
|
|
|
|
* \param msg The message ID
|
|
|
|
* \param wparam The w parameter of the message.
|
|
|
|
* \param lparam The l parameter of the message.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
nsws_window_toolbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
int urlx, urly, urlwidth, urlheight;
|
|
|
|
WNDPROC toolproc;
|
|
|
|
|
|
|
|
LOG_WIN_MSG(hwnd, msg, wparam, lparam);
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
toolproc = (WNDPROC)GetProp(hwnd, TEXT("OrigMsgProc"));
|
|
|
|
assert(toolproc != NULL);
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
gw = nsws_get_gui_window(hwnd);
|
2019-12-16 03:31:48 +03:00
|
|
|
assert(gw != NULL);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_SIZE:
|
|
|
|
urlbar_dimensions(hwnd,
|
|
|
|
gw->toolbuttonsize,
|
|
|
|
gw->toolbuttonc,
|
|
|
|
&urlx, &urly, &urlwidth, &urlheight);
|
|
|
|
|
|
|
|
/* resize url */
|
|
|
|
if (gw->urlbar != NULL) {
|
|
|
|
MoveWindow(gw->urlbar,
|
|
|
|
urlx, urly,
|
|
|
|
urlwidth, urlheight,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* move throbber */
|
|
|
|
if (gw->throbber != NULL) {
|
|
|
|
MoveWindow(gw->throbber,
|
2016-10-30 15:58:43 +03:00
|
|
|
LOWORD(lparam) - NSWS_THROBBER_WIDTH - 4,
|
|
|
|
urly,
|
|
|
|
NSWS_THROBBER_WIDTH,
|
|
|
|
NSWS_THROBBER_WIDTH,
|
2015-03-13 02:48:53 +03:00
|
|
|
true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (nsws_window_toolbar_command(gw,
|
|
|
|
HIWORD(wparam),
|
|
|
|
LOWORD(wparam),
|
|
|
|
(HWND)lparam) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
case WM_NCDESTROY:
|
|
|
|
/* remove properties if window is being destroyed */
|
2015-03-13 02:48:53 +03:00
|
|
|
RemoveProp(hwnd, TEXT("GuiWnd"));
|
2019-12-16 03:31:48 +03:00
|
|
|
RemoveProp(hwnd, TEXT("OrigMsgProc"));
|
|
|
|
/* put the original message handler back */
|
|
|
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)toolproc);
|
|
|
|
break;
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* chain to the next handler */
|
|
|
|
return CallWindowProc(toolproc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
static void set_urlbar_edit_size(HWND hwnd)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
rc.left += NSW32_PGIBUTTON_HEIGHT;
|
|
|
|
SendMessage(hwnd, EM_SETRECT, 0, (LPARAM)&rc);
|
|
|
|
NSLOG(netsurf, DEBUG, "left:%ld right:%ld top:%ld bot:%ld",
|
|
|
|
rc.left,rc.right,rc.top,rc.bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
/**
|
|
|
|
* callback for url bar events
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2019-12-16 03:31:48 +03:00
|
|
|
* subclass message handler for urlbar window
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
|
|
|
* \param hwnd win32 window handle message arrived for
|
|
|
|
* \param msg The message ID
|
|
|
|
* \param wparam The w parameter of the message.
|
|
|
|
* \param lparam The l parameter of the message.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
WNDPROC urlproc;
|
|
|
|
HFONT hFont;
|
2019-12-16 03:31:48 +03:00
|
|
|
LRESULT result;
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
LOG_WIN_MSG(hwnd, msg, wparam, lparam);
|
|
|
|
|
|
|
|
urlproc = (WNDPROC)GetProp(hwnd, TEXT("OrigMsgProc"));
|
2019-12-16 03:31:48 +03:00
|
|
|
assert(urlproc != NULL);
|
|
|
|
|
|
|
|
gw = nsws_get_gui_window(hwnd);
|
|
|
|
assert(gw != NULL);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
/* override messages */
|
|
|
|
switch (msg) {
|
|
|
|
case WM_CHAR:
|
|
|
|
if (wparam == 13) {
|
|
|
|
SendMessage(gw->main, WM_COMMAND, IDC_MAIN_LAUNCH_URL, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
|
|
|
|
if (hFont != NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Destroyed font object");
|
2015-03-13 02:48:53 +03:00
|
|
|
DeleteObject(hFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
/* remove properties if window is being destroyed */
|
|
|
|
RemoveProp(hwnd, TEXT("GuiWnd"));
|
|
|
|
RemoveProp(hwnd, TEXT("OrigMsgProc"));
|
2019-12-16 03:31:48 +03:00
|
|
|
/* put the original message handler back */
|
|
|
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)urlproc);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
case WM_SIZE:
|
|
|
|
result = CallWindowProc(urlproc, hwnd, msg, wparam, lparam);
|
|
|
|
set_urlbar_edit_size(hwnd);
|
|
|
|
return result;
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* chain to the next handler */
|
|
|
|
return CallWindowProc(urlproc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create a urlbar and message handler
|
|
|
|
*
|
2017-02-17 23:44:37 +03:00
|
|
|
* Create an Edit control for entering urls
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2016-10-30 15:58:43 +03:00
|
|
|
* \param hInstance The application instance handle.
|
|
|
|
* \param hWndParent The containing window.
|
2016-10-29 19:24:31 +03:00
|
|
|
* \param gw win32 frontends window context.
|
|
|
|
* \return win32 window handle of created window or NULL on error.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static HWND
|
2016-10-30 15:58:43 +03:00
|
|
|
nsws_window_urlbar_create(HINSTANCE hInstance,
|
|
|
|
HWND hWndParent,
|
|
|
|
struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
int urlx, urly, urlwidth, urlheight;
|
|
|
|
HWND hwnd;
|
2019-12-16 03:31:48 +03:00
|
|
|
HWND hbutton;
|
2015-03-13 02:48:53 +03:00
|
|
|
WNDPROC urlproc;
|
|
|
|
HFONT hFont;
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
urlbar_dimensions(hWndParent,
|
2015-03-13 02:48:53 +03:00
|
|
|
gw->toolbuttonsize,
|
|
|
|
gw->toolbuttonc,
|
|
|
|
&urlx, &urly, &urlwidth, &urlheight);
|
|
|
|
|
|
|
|
/* Create the edit control */
|
|
|
|
hwnd = CreateWindowEx(0L,
|
|
|
|
TEXT("Edit"),
|
|
|
|
NULL,
|
2019-12-16 03:31:48 +03:00
|
|
|
WS_CHILD | WS_BORDER | WS_VISIBLE |
|
|
|
|
ES_LEFT | ES_AUTOHSCROLL | ES_MULTILINE,
|
2015-03-13 02:48:53 +03:00
|
|
|
urlx,
|
|
|
|
urly,
|
|
|
|
urlwidth,
|
|
|
|
urlheight,
|
2016-10-29 19:24:31 +03:00
|
|
|
hWndParent,
|
2015-03-13 02:48:53 +03:00
|
|
|
(HMENU)IDC_MAIN_URLBAR,
|
|
|
|
hInstance,
|
2019-12-16 03:31:48 +03:00
|
|
|
NULL);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
if (hwnd == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the gui window associated with this control */
|
|
|
|
SetProp(hwnd, TEXT("GuiWnd"), (HANDLE)gw);
|
|
|
|
|
|
|
|
/* subclass the message handler */
|
|
|
|
urlproc = (WNDPROC)SetWindowLongPtr(hwnd,
|
2017-02-17 23:44:37 +03:00
|
|
|
GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)nsws_window_urlbar_callback);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
/* save the real handler */
|
|
|
|
SetProp(hwnd, TEXT("OrigMsgProc"), (HANDLE)urlproc);
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
hFont = CreateFont(urlheight - 4, 0, 0, 0, FW_BOLD, FALSE, FALSE,
|
|
|
|
FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
|
|
|
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
|
|
|
DEFAULT_PITCH | FF_SWISS, "Arial");
|
2015-03-13 02:48:53 +03:00
|
|
|
if (hFont != NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Setting font object");
|
2015-03-13 02:48:53 +03:00
|
|
|
SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 0);
|
|
|
|
}
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
|
|
|
|
/* Create the page info button */
|
|
|
|
hbutton = CreateWindowEx(0L,
|
|
|
|
TEXT("BUTTON"),
|
|
|
|
NULL,
|
|
|
|
WS_CHILD | WS_VISIBLE | BS_BITMAP | BS_FLAT,
|
|
|
|
(NSWS_URLBAR_HEIGHT - NSW32_PGIBUTTON_HEIGHT) /2,
|
|
|
|
(NSWS_URLBAR_HEIGHT - NSW32_PGIBUTTON_HEIGHT) /2,
|
|
|
|
NSW32_PGIBUTTON_HEIGHT,
|
|
|
|
NSW32_PGIBUTTON_HEIGHT,
|
|
|
|
hwnd,
|
|
|
|
(HMENU)IDC_PAGEINFO,
|
|
|
|
hInstance,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* put a property on the parent toolbar so it can set the page info */
|
|
|
|
SetProp(hWndParent, TEXT("hPGIbutton"), (HANDLE)hbutton);
|
|
|
|
|
|
|
|
SendMessageW(hbutton, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)gw->hPageInfo[PAGE_STATE_UNKNOWN]);
|
|
|
|
|
|
|
|
set_urlbar_edit_size(hwnd);
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"Created url bar hwnd:%p, x:%d, y:%d, w:%d, h:%d", hwnd, urlx,
|
|
|
|
urly, urlwidth, urlheight);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* creation of throbber
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2016-10-30 15:58:43 +03:00
|
|
|
* \param hInstance The application instance handle.
|
|
|
|
* \param hWndParent The containing window.
|
2016-10-29 19:24:31 +03:00
|
|
|
* \param gw win32 frontends window context.
|
|
|
|
* \return win32 window handle of created window or NULL on error.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static HWND
|
2016-10-30 15:58:43 +03:00
|
|
|
nsws_window_throbber_create(HINSTANCE hInstance,
|
|
|
|
HWND hWndParent,
|
|
|
|
struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
2016-10-30 15:58:43 +03:00
|
|
|
int urlx, urly, urlwidth, urlheight;
|
|
|
|
|
|
|
|
urlbar_dimensions(hWndParent,
|
|
|
|
gw->toolbuttonsize,
|
|
|
|
gw->toolbuttonc,
|
|
|
|
&urlx, &urly, &urlwidth, &urlheight);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
hwnd = CreateWindow(ANIMATE_CLASS,
|
|
|
|
"",
|
|
|
|
WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT,
|
2016-10-29 19:24:31 +03:00
|
|
|
gw->width - NSWS_THROBBER_WIDTH - 4,
|
2016-10-30 15:58:43 +03:00
|
|
|
urly,
|
2015-03-13 02:48:53 +03:00
|
|
|
NSWS_THROBBER_WIDTH,
|
|
|
|
NSWS_THROBBER_WIDTH,
|
2016-10-30 15:58:43 +03:00
|
|
|
hWndParent,
|
2015-03-13 02:48:53 +03:00
|
|
|
(HMENU) IDC_MAIN_THROBBER,
|
|
|
|
hInstance,
|
|
|
|
NULL);
|
|
|
|
|
2018-08-21 00:26:41 +03:00
|
|
|
Animate_Open(hwnd, MAKEINTRESOURCE(IDR_THROBBER_AVI));
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
if (gw->throbbing) {
|
2015-03-13 02:48:53 +03:00
|
|
|
Animate_Play(hwnd, 0, -1, -1);
|
2016-10-29 19:24:31 +03:00
|
|
|
} else {
|
2015-03-13 02:48:53 +03:00
|
|
|
Animate_Seek(hwnd, 0);
|
2016-10-29 19:24:31 +03:00
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
ShowWindow(hwnd, SW_SHOWNORMAL);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
/**
|
|
|
|
* create a win32 image list for the toolbar.
|
|
|
|
*
|
2016-10-30 15:58:43 +03:00
|
|
|
* \param hInstance The application instance handle.
|
2016-10-29 19:24:31 +03:00
|
|
|
* \param resid The resource ID of the image.
|
|
|
|
* \param bsize The size of the image to load.
|
|
|
|
* \param bcnt The number of bitmaps to load into the list.
|
|
|
|
* \return The image list or NULL on error.
|
|
|
|
*/
|
|
|
|
static HIMAGELIST
|
2016-10-30 15:58:43 +03:00
|
|
|
get_imagelist(HINSTANCE hInstance, int resid, int bsize, int bcnt)
|
2016-10-29 19:24:31 +03:00
|
|
|
{
|
|
|
|
HIMAGELIST hImageList;
|
|
|
|
HBITMAP hScrBM;
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "resource id %d, bzize %d, bcnt %d", resid,
|
|
|
|
bsize, bcnt);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
2016-10-30 15:58:43 +03:00
|
|
|
hImageList = ImageList_Create(bsize, bsize,
|
|
|
|
ILC_COLOR24 | ILC_MASK, 0,
|
2016-10-29 19:24:31 +03:00
|
|
|
bcnt);
|
2016-10-30 15:58:43 +03:00
|
|
|
if (hImageList == NULL) {
|
2016-10-29 19:24:31 +03:00
|
|
|
return NULL;
|
2016-10-30 15:58:43 +03:00
|
|
|
}
|
2016-10-29 19:24:31 +03:00
|
|
|
|
2016-10-30 15:58:43 +03:00
|
|
|
hScrBM = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(resid),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
2016-10-29 19:24:31 +03:00
|
|
|
if (hScrBM == NULL) {
|
|
|
|
win_perror("LoadImage");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImageList_AddMasked(hImageList, hScrBM, 0xcccccc) == -1) {
|
|
|
|
/* failed to add masked bitmap */
|
|
|
|
ImageList_Destroy(hImageList);
|
|
|
|
hImageList = NULL;
|
|
|
|
}
|
|
|
|
DeleteObject(hScrBM);
|
|
|
|
|
|
|
|
return hImageList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create win32 main window toolbar and add controls and message handler
|
|
|
|
*
|
2016-10-30 15:58:43 +03:00
|
|
|
* Toolbar has buttons on the left, url entry space in the middle and
|
|
|
|
* activity throbber on the right.
|
|
|
|
*
|
|
|
|
* \param hInstance The application instance handle.
|
|
|
|
* \param hWndParent The containing window.
|
2016-10-29 19:24:31 +03:00
|
|
|
* \param gw win32 frontends window context.
|
|
|
|
* \return win32 window handle of created window or NULL on error.
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static HWND
|
2016-10-30 15:58:43 +03:00
|
|
|
nsws_window_create_toolbar(HINSTANCE hInstance,
|
|
|
|
HWND hWndParent,
|
|
|
|
struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
HIMAGELIST hImageList;
|
|
|
|
HWND hWndToolbar;
|
|
|
|
/* Toolbar buttons */
|
|
|
|
TBBUTTON tbButtons[] = {
|
|
|
|
{0, IDM_NAV_BACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{1, IDM_NAV_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{2, IDM_NAV_HOME, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{3, IDM_NAV_RELOAD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{4, IDM_NAV_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
};
|
|
|
|
WNDPROC toolproc;
|
|
|
|
|
|
|
|
/* Create the toolbar window and subclass its message handler. */
|
2016-10-30 15:58:43 +03:00
|
|
|
hWndToolbar = CreateWindowEx(0,
|
|
|
|
TOOLBARCLASSNAME,
|
|
|
|
"Toolbar",
|
2019-12-16 03:31:48 +03:00
|
|
|
WS_CHILD | TBSTYLE_FLAT,
|
2015-03-13 02:48:53 +03:00
|
|
|
0, 0, 0, 0,
|
2016-10-30 15:58:43 +03:00
|
|
|
hWndParent,
|
|
|
|
NULL,
|
|
|
|
HINST_COMMCTRL,
|
|
|
|
NULL);
|
2015-03-13 02:48:53 +03:00
|
|
|
if (!hWndToolbar) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the gui window associated with this toolbar */
|
|
|
|
SetProp(hWndToolbar, TEXT("GuiWnd"), (HANDLE)gw);
|
|
|
|
|
|
|
|
/* subclass the message handler */
|
|
|
|
toolproc = (WNDPROC)SetWindowLongPtr(hWndToolbar,
|
2017-02-17 23:44:37 +03:00
|
|
|
GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)nsws_window_toolbar_callback);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
/* save the real handler */
|
|
|
|
SetProp(hWndToolbar, TEXT("OrigMsgProc"), (HANDLE)toolproc);
|
|
|
|
|
|
|
|
/* remember how many buttons are being created */
|
|
|
|
gw->toolbuttonc = sizeof(tbButtons) / sizeof(TBBUTTON);
|
|
|
|
|
|
|
|
/* Create the standard image list and assign to toolbar. */
|
2016-10-30 15:58:43 +03:00
|
|
|
hImageList = get_imagelist(hInstance,
|
|
|
|
IDR_TOOLBAR_BITMAP,
|
2015-03-13 02:48:53 +03:00
|
|
|
gw->toolbuttonsize,
|
|
|
|
gw->toolbuttonc);
|
|
|
|
if (hImageList != NULL) {
|
2016-10-30 15:58:43 +03:00
|
|
|
SendMessage(hWndToolbar,
|
|
|
|
TB_SETIMAGELIST,
|
|
|
|
0,
|
|
|
|
(LPARAM)hImageList);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the disabled image list and assign to toolbar. */
|
2016-10-30 15:58:43 +03:00
|
|
|
hImageList = get_imagelist(hInstance,
|
|
|
|
IDR_TOOLBAR_BITMAP_GREY,
|
2015-03-13 02:48:53 +03:00
|
|
|
gw->toolbuttonsize,
|
|
|
|
gw->toolbuttonc);
|
|
|
|
if (hImageList != NULL) {
|
2016-10-30 15:58:43 +03:00
|
|
|
SendMessage(hWndToolbar,
|
|
|
|
TB_SETDISABLEDIMAGELIST,
|
|
|
|
0,
|
2015-03-13 02:48:53 +03:00
|
|
|
(LPARAM)hImageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the hot image list and assign to toolbar. */
|
2016-10-30 15:58:43 +03:00
|
|
|
hImageList = get_imagelist(hInstance,
|
|
|
|
IDR_TOOLBAR_BITMAP_HOT,
|
2015-03-13 02:48:53 +03:00
|
|
|
gw->toolbuttonsize,
|
|
|
|
gw->toolbuttonc);
|
|
|
|
if (hImageList != NULL) {
|
2016-10-30 15:58:43 +03:00
|
|
|
SendMessage(hWndToolbar,
|
|
|
|
TB_SETHOTIMAGELIST,
|
|
|
|
0,
|
2015-03-13 02:48:53 +03:00
|
|
|
(LPARAM)hImageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add buttons. */
|
|
|
|
SendMessage(hWndToolbar,
|
|
|
|
TB_BUTTONSTRUCTSIZE,
|
|
|
|
(WPARAM)sizeof(TBBUTTON),
|
|
|
|
0);
|
2019-12-16 03:31:48 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
SendMessage(hWndToolbar,
|
|
|
|
TB_ADDBUTTONS,
|
|
|
|
(WPARAM)gw->toolbuttonc,
|
|
|
|
(LPARAM)&tbButtons);
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/* create url widget */
|
2016-10-30 15:58:43 +03:00
|
|
|
gw->urlbar = nsws_window_urlbar_create(hInstance, hWndToolbar, gw);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/* create throbber widget */
|
2016-10-30 15:58:43 +03:00
|
|
|
gw->throbber = nsws_window_throbber_create(hInstance, hWndToolbar, gw);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
SendMessage(hWndToolbar, TB_AUTOSIZE, 0, 0);
|
|
|
|
ShowWindow(hWndToolbar, TRUE);
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
return hWndToolbar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* creation of status bar
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2016-10-30 15:58:43 +03:00
|
|
|
* \param hInstance The application instance handle.
|
|
|
|
* \param hWndParent The containing window.
|
2016-10-29 19:24:31 +03:00
|
|
|
* \param gw win32 frontends window context.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2016-10-30 15:58:43 +03:00
|
|
|
static HWND
|
|
|
|
nsws_window_create_statusbar(HINSTANCE hInstance,
|
|
|
|
HWND hWndParent,
|
|
|
|
struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2016-10-30 15:58:43 +03:00
|
|
|
HWND hwnd;
|
|
|
|
hwnd = CreateWindowEx(0,
|
|
|
|
STATUSCLASSNAME,
|
|
|
|
NULL,
|
|
|
|
WS_CHILD | WS_VISIBLE,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
hWndParent,
|
|
|
|
(HMENU)IDC_MAIN_STATUSBAR,
|
|
|
|
hInstance,
|
|
|
|
NULL);
|
|
|
|
if (hwnd != NULL) {
|
|
|
|
SendMessage(hwnd, SB_SETTEXT, 0, (LPARAM)"NetSurf");
|
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
/**
|
|
|
|
* Update popup context menu editing functionality
|
|
|
|
*
|
|
|
|
* \param w win32 frontends window context.
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static void nsws_update_edit(struct gui_window *w)
|
|
|
|
{
|
|
|
|
browser_editor_flags editor_flags = (w->bw == NULL) ?
|
2017-02-17 23:44:37 +03:00
|
|
|
BW_EDITOR_NONE : browser_window_get_editor_flags(w->bw);
|
2015-03-13 02:48:53 +03:00
|
|
|
bool paste, copy, del;
|
|
|
|
bool sel = (editor_flags & BW_EDITOR_CAN_COPY);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
if (GetFocus() == w->urlbar) {
|
|
|
|
DWORD i, ii;
|
|
|
|
SendMessage(w->urlbar, EM_GETSEL, (WPARAM)&i, (LPARAM)&ii);
|
|
|
|
paste = true;
|
|
|
|
copy = (i != ii);
|
|
|
|
del = (i != ii);
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
} else if (sel) {
|
2015-03-13 02:48:53 +03:00
|
|
|
paste = (editor_flags & BW_EDITOR_CAN_PASTE);
|
|
|
|
copy = sel;
|
|
|
|
del = (editor_flags & BW_EDITOR_CAN_CUT);
|
|
|
|
} else {
|
|
|
|
paste = false;
|
|
|
|
copy = false;
|
|
|
|
del = false;
|
|
|
|
}
|
|
|
|
EnableMenuItem(w->mainmenu,
|
|
|
|
IDM_EDIT_PASTE,
|
|
|
|
(paste ? MF_ENABLED : MF_GRAYED));
|
|
|
|
|
|
|
|
EnableMenuItem(w->rclick,
|
|
|
|
IDM_EDIT_PASTE,
|
|
|
|
(paste ? MF_ENABLED : MF_GRAYED));
|
|
|
|
|
|
|
|
EnableMenuItem(w->mainmenu,
|
|
|
|
IDM_EDIT_COPY,
|
|
|
|
(copy ? MF_ENABLED : MF_GRAYED));
|
|
|
|
|
|
|
|
EnableMenuItem(w->rclick,
|
|
|
|
IDM_EDIT_COPY,
|
|
|
|
(copy ? MF_ENABLED : MF_GRAYED));
|
|
|
|
|
|
|
|
if (del == true) {
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_EDIT_CUT, MF_ENABLED);
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_EDIT_DELETE, MF_ENABLED);
|
|
|
|
EnableMenuItem(w->rclick, IDM_EDIT_CUT, MF_ENABLED);
|
|
|
|
EnableMenuItem(w->rclick, IDM_EDIT_DELETE, MF_ENABLED);
|
|
|
|
} else {
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_EDIT_CUT, MF_GRAYED);
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_EDIT_DELETE, MF_GRAYED);
|
|
|
|
EnableMenuItem(w->rclick, IDM_EDIT_CUT, MF_GRAYED);
|
|
|
|
EnableMenuItem(w->rclick, IDM_EDIT_DELETE, MF_GRAYED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
/**
|
|
|
|
* Handle win32 context menu message
|
|
|
|
*
|
|
|
|
* \param gw win32 frontends graphical window.
|
|
|
|
* \param hwnd The win32 window handle
|
2017-02-19 14:32:17 +03:00
|
|
|
* \param x The x coordinate of the event.
|
2017-02-17 23:44:37 +03:00
|
|
|
* \param y the y coordinate of the event.
|
2017-02-19 14:32:17 +03:00
|
|
|
* \return true if menu displayed else false
|
2016-10-29 19:24:31 +03:00
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static bool
|
2017-02-19 14:32:17 +03:00
|
|
|
nsws_ctx_menu(struct gui_window *gw, HWND hwnd, int x, int y)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
RECT rc; /* client area of window */
|
|
|
|
POINT pt = { x, y }; /* location of mouse click */
|
|
|
|
|
|
|
|
/* Get the bounding rectangle of the client area. */
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
|
|
|
|
/* Convert the mouse position to client coordinates. */
|
|
|
|
ScreenToClient(hwnd, &pt);
|
|
|
|
|
|
|
|
/* If the position is in the client area, display a shortcut menu. */
|
|
|
|
if (PtInRect(&rc, pt)) {
|
|
|
|
ClientToScreen(hwnd, &pt);
|
2017-02-19 15:02:23 +03:00
|
|
|
nsws_update_edit(gw);
|
2017-02-19 14:32:17 +03:00
|
|
|
TrackPopupMenu(GetSubMenu(gw->rclick, 0),
|
2015-03-13 02:48:53 +03:00
|
|
|
TPM_CENTERALIGN | TPM_TOPALIGN,
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
0,
|
|
|
|
hwnd,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return false if no menu is displayed. */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* update state of forward/back buttons/menu items when page changes
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
|
|
|
* \param w win32 frontends graphical window.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static void nsws_window_update_forward_back(struct gui_window *w)
|
|
|
|
{
|
|
|
|
if (w->bw == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool forward = browser_window_history_forward_available(w->bw);
|
|
|
|
bool back = browser_window_history_back_available(w->bw);
|
|
|
|
|
|
|
|
if (w->mainmenu != NULL) {
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_NAV_FORWARD,
|
|
|
|
(forward ? MF_ENABLED : MF_GRAYED));
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_NAV_BACK,
|
|
|
|
(back ? MF_ENABLED : MF_GRAYED));
|
|
|
|
EnableMenuItem(w->rclick, IDM_NAV_FORWARD,
|
|
|
|
(forward ? MF_ENABLED : MF_GRAYED));
|
|
|
|
EnableMenuItem(w->rclick, IDM_NAV_BACK,
|
|
|
|
(back ? MF_ENABLED : MF_GRAYED));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w->toolbar != NULL) {
|
|
|
|
SendMessage(w->toolbar, TB_SETSTATE,
|
|
|
|
(WPARAM) IDM_NAV_FORWARD,
|
|
|
|
MAKELONG((forward ? TBSTATE_ENABLED :
|
|
|
|
TBSTATE_INDETERMINATE), 0));
|
|
|
|
SendMessage(w->toolbar, TB_SETSTATE,
|
|
|
|
(WPARAM) IDM_NAV_BACK,
|
|
|
|
MAKELONG((back ? TBSTATE_ENABLED :
|
|
|
|
TBSTATE_INDETERMINATE), 0));
|
|
|
|
}
|
2017-06-02 01:57:09 +03:00
|
|
|
nsw32_local_history_hide();
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2017-04-23 14:04:07 +03:00
|
|
|
* Invalidate an area of a win32 browser window
|
2016-10-29 19:24:31 +03:00
|
|
|
*
|
2017-04-23 14:04:07 +03:00
|
|
|
* \param gw The netsurf window being invalidated.
|
|
|
|
* \param rect area to redraw or NULL for entrire window area.
|
|
|
|
* \return NSERROR_OK or appropriate error code.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2017-04-23 14:04:07 +03:00
|
|
|
static nserror
|
|
|
|
win32_window_invalidate_area(struct gui_window *gw, const struct rect *rect)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2017-04-23 14:04:07 +03:00
|
|
|
RECT *redrawrectp = NULL;
|
|
|
|
RECT redrawrect;
|
|
|
|
|
|
|
|
assert(gw != NULL);
|
|
|
|
|
|
|
|
if (rect != NULL) {
|
|
|
|
redrawrectp = &redrawrect;
|
|
|
|
|
2019-08-04 13:23:35 +03:00
|
|
|
redrawrect.left = (long)rect->x0 - gw->scrollx;
|
|
|
|
redrawrect.top = (long)rect->y0 - gw->scrolly;
|
2017-04-23 14:04:07 +03:00
|
|
|
redrawrect.right =(long)rect->x1;
|
|
|
|
redrawrect.bottom = (long)rect->y1;
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
2017-04-23 14:04:07 +03:00
|
|
|
RedrawWindow(gw->drawingarea,
|
|
|
|
redrawrectp,
|
|
|
|
NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE);
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-20 23:28:20 +03:00
|
|
|
/**
|
|
|
|
* Create a new window due to menu selection
|
|
|
|
*
|
|
|
|
* \param gw frontends graphical window.
|
|
|
|
* \return NSERROR_OK on success else appropriate error code.
|
|
|
|
*/
|
|
|
|
static nserror win32_open_new_window(struct gui_window *gw)
|
|
|
|
{
|
|
|
|
const char *addr;
|
|
|
|
nsurl *url;
|
|
|
|
nserror ret;
|
|
|
|
|
|
|
|
if (nsoption_charp(homepage_url) != NULL) {
|
|
|
|
addr = nsoption_charp(homepage_url);
|
|
|
|
} else {
|
|
|
|
addr = NETSURF_HOMEPAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = nsurl_create(addr, &url);
|
|
|
|
if (ret == NSERROR_OK) {
|
|
|
|
ret = browser_window_create(BW_CREATE_HISTORY,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
gw->bw,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* handle command message on main browser window
|
|
|
|
*
|
|
|
|
* \param hwnd The win32 window handle
|
|
|
|
* \param gw win32 gui window
|
2017-02-17 23:44:37 +03:00
|
|
|
* \param notification_code notification code
|
2016-10-27 01:19:43 +03:00
|
|
|
* \param identifier notification identifier
|
|
|
|
* \param ctrl_window The win32 control window handle
|
2017-02-17 23:44:37 +03:00
|
|
|
* \return appropriate response for command
|
2016-10-27 01:19:43 +03:00
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static LRESULT
|
|
|
|
nsws_window_command(HWND hwnd,
|
|
|
|
struct gui_window *gw,
|
|
|
|
int notification_code,
|
|
|
|
int identifier,
|
|
|
|
HWND ctrl_window)
|
|
|
|
{
|
|
|
|
nserror ret;
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"notification_code %x identifier %x ctrl_window %p",
|
|
|
|
notification_code,
|
|
|
|
identifier,
|
|
|
|
ctrl_window);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
switch(identifier) {
|
|
|
|
|
|
|
|
case IDM_FILE_QUIT:
|
|
|
|
{
|
|
|
|
struct gui_window *w;
|
|
|
|
w = window_list;
|
|
|
|
while (w != NULL) {
|
|
|
|
PostMessage(w->main, WM_CLOSE, 0, 0);
|
|
|
|
w = w->next;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IDM_FILE_OPEN_LOCATION:
|
|
|
|
SetFocus(gw->urlbar);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_OPEN_WINDOW:
|
2016-03-20 23:28:20 +03:00
|
|
|
ret = win32_open_new_window(gw);
|
2015-03-13 02:48:53 +03:00
|
|
|
if (ret != NSERROR_OK) {
|
2016-04-28 00:41:59 +03:00
|
|
|
win32_warning(messages_get_errorcode(ret), 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_CLOSE_WINDOW:
|
|
|
|
PostMessage(gw->main, WM_CLOSE, 0, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_SAVE_PAGE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_SAVEAS_TEXT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_SAVEAS_PDF:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_SAVEAS_POSTSCRIPT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_PRINT_PREVIEW:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_FILE_PRINT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDIT_CUT:
|
|
|
|
if (GetFocus() == gw->urlbar) {
|
|
|
|
SendMessage(gw->urlbar, WM_CUT, 0, 0);
|
2019-05-10 01:11:05 +03:00
|
|
|
} else {
|
|
|
|
SendMessage(gw->drawingarea, WM_CUT, 0, 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDIT_COPY:
|
|
|
|
if (GetFocus() == gw->urlbar) {
|
|
|
|
SendMessage(gw->urlbar, WM_COPY, 0, 0);
|
2019-05-10 01:11:05 +03:00
|
|
|
} else {
|
|
|
|
SendMessage(gw->drawingarea, WM_COPY, 0, 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDIT_PASTE: {
|
2019-05-10 01:11:05 +03:00
|
|
|
if (GetFocus() == gw->urlbar) {
|
2015-03-13 02:48:53 +03:00
|
|
|
SendMessage(gw->urlbar, WM_PASTE, 0, 0);
|
2019-05-10 01:11:05 +03:00
|
|
|
} else {
|
|
|
|
SendMessage(gw->drawingarea, WM_PASTE, 0, 0);
|
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IDM_EDIT_DELETE:
|
|
|
|
if (GetFocus() == gw->urlbar)
|
2019-05-10 01:11:05 +03:00
|
|
|
SendMessage(gw->urlbar, WM_CLEAR, 0, 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
else
|
2019-05-10 01:11:05 +03:00
|
|
|
SendMessage(gw->drawingarea, WM_CLEAR, 0, 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDIT_SELECT_ALL:
|
|
|
|
if (GetFocus() == gw->urlbar)
|
|
|
|
SendMessage(gw->urlbar, EM_SETSEL, 0, -1);
|
|
|
|
else
|
2015-03-27 12:36:19 +03:00
|
|
|
browser_window_key_press(gw->bw, NS_KEY_SELECT_ALL);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDIT_SEARCH:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDIT_PREFERENCES:
|
2016-10-30 15:58:43 +03:00
|
|
|
nsws_prefs_dialog_init(hinst, gw->main);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_BACK:
|
|
|
|
if ((gw->bw != NULL) &&
|
|
|
|
(browser_window_history_back_available(gw->bw))) {
|
|
|
|
browser_window_history_back(gw->bw, false);
|
|
|
|
}
|
|
|
|
nsws_window_update_forward_back(gw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_FORWARD:
|
|
|
|
if ((gw->bw != NULL) &&
|
|
|
|
(browser_window_history_forward_available(gw->bw))) {
|
|
|
|
browser_window_history_forward(gw->bw, false);
|
|
|
|
}
|
|
|
|
nsws_window_update_forward_back(gw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_HOME:
|
|
|
|
{
|
|
|
|
nsurl *url;
|
2020-02-24 15:10:35 +03:00
|
|
|
ret = nsurl_create(nsoption_charp(homepage_url), &url);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
2020-02-24 15:10:35 +03:00
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
win32_report_nserror(ret, 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
} else {
|
|
|
|
browser_window_navigate(gw->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
BW_NAVIGATE_HISTORY,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IDM_NAV_STOP:
|
|
|
|
browser_window_stop(gw->bw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_RELOAD:
|
|
|
|
browser_window_reload(gw->bw, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_LOCALHISTORY:
|
2017-06-02 01:57:09 +03:00
|
|
|
nsw32_local_history_present(gw->main, gw->bw);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_GLOBALHISTORY:
|
2016-11-19 14:22:22 +03:00
|
|
|
nsw32_global_history_present(hinst);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_TOOLS_COOKIES:
|
2020-05-23 23:16:10 +03:00
|
|
|
nsw32_cookies_present(NULL);
|
2016-11-19 14:22:22 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NAV_BOOKMARKS:
|
|
|
|
nsw32_hotlist_present(hinst);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
case IDM_VIEW_ZOOMPLUS:
|
2019-08-03 17:53:07 +03:00
|
|
|
browser_window_set_scale(gw->bw, 0.1, false);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
case IDM_VIEW_ZOOMMINUS:
|
2019-08-03 17:53:07 +03:00
|
|
|
browser_window_set_scale(gw->bw, -0.1, false);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
case IDM_VIEW_ZOOMNORMAL:
|
2019-08-03 17:53:07 +03:00
|
|
|
browser_window_set_scale(gw->bw, 1.0, true);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEW_SOURCE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEW_SAVE_WIN_METRICS: {
|
|
|
|
RECT r;
|
|
|
|
GetWindowRect(gw->main, &r);
|
|
|
|
nsoption_set_int(window_x, r.left);
|
|
|
|
nsoption_set_int(window_y, r.top);
|
|
|
|
nsoption_set_int(window_width, r.right - r.left);
|
|
|
|
nsoption_set_int(window_height, r.bottom - r.top);
|
2016-10-19 13:12:19 +03:00
|
|
|
|
|
|
|
nsws_prefs_save();
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IDM_VIEW_FULLSCREEN: {
|
|
|
|
RECT rdesk;
|
|
|
|
if (gw->fullscreen == NULL) {
|
|
|
|
HWND desktop = GetDesktopWindow();
|
|
|
|
gw->fullscreen = malloc(sizeof(RECT));
|
|
|
|
if ((desktop == NULL) ||
|
|
|
|
(gw->fullscreen == NULL)) {
|
2016-04-28 00:41:59 +03:00
|
|
|
win32_warning("NoMemory", 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
GetWindowRect(desktop, &rdesk);
|
|
|
|
GetWindowRect(gw->main, gw->fullscreen);
|
|
|
|
DeleteObject(desktop);
|
|
|
|
SetWindowLong(gw->main, GWL_STYLE, 0);
|
|
|
|
SetWindowPos(gw->main, HWND_TOPMOST, 0, 0,
|
|
|
|
rdesk.right - rdesk.left,
|
|
|
|
rdesk.bottom - rdesk.top,
|
|
|
|
SWP_SHOWWINDOW);
|
|
|
|
} else {
|
|
|
|
SetWindowLong(gw->main, GWL_STYLE,
|
|
|
|
WS_OVERLAPPEDWINDOW |
|
|
|
|
WS_HSCROLL | WS_VSCROLL |
|
|
|
|
WS_CLIPCHILDREN |
|
|
|
|
WS_CLIPSIBLINGS | CS_DBLCLKS);
|
|
|
|
SetWindowPos(gw->main, HWND_TOPMOST,
|
|
|
|
gw->fullscreen->left,
|
|
|
|
gw->fullscreen->top,
|
|
|
|
gw->fullscreen->right -
|
|
|
|
gw->fullscreen->left,
|
|
|
|
gw->fullscreen->bottom -
|
|
|
|
gw->fullscreen->top,
|
|
|
|
SWP_SHOWWINDOW | SWP_FRAMECHANGED);
|
|
|
|
free(gw->fullscreen);
|
|
|
|
gw->fullscreen = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-11-19 14:22:22 +03:00
|
|
|
case IDM_TOOLS_DOWNLOADS:
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEW_TOGGLE_DEBUG_RENDERING:
|
|
|
|
if (gw->bw != NULL) {
|
|
|
|
browser_window_debug(gw->bw, CONTENT_DEBUG_REDRAW);
|
|
|
|
/* TODO: This should only redraw, not reformat.
|
|
|
|
* (Layout doesn't change, so reformat is a waste of time) */
|
2017-04-26 11:55:36 +03:00
|
|
|
browser_window_schedule_reformat(gw->bw);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEW_DEBUGGING_SAVE_BOXTREE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_VIEW_DEBUGGING_SAVE_DOMTREE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_HELP_CONTENTS:
|
|
|
|
nsws_window_go(hwnd,
|
|
|
|
"http://www.netsurf-browser.org/documentation/");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_HELP_GUIDE:
|
|
|
|
nsws_window_go(hwnd,
|
|
|
|
"http://www.netsurf-browser.org/documentation/guide");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_HELP_INFO:
|
|
|
|
nsws_window_go(hwnd,
|
|
|
|
"http://www.netsurf-browser.org/documentation/info");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_HELP_ABOUT:
|
2018-08-19 01:30:12 +03:00
|
|
|
nsw32_about_dialog_init(hinst, gw->main);
|
2015-03-13 02:48:53 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_MAIN_LAUNCH_URL:
|
|
|
|
{
|
|
|
|
nsurl *url;
|
2020-02-24 14:57:18 +03:00
|
|
|
nserror err;
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
if (GetFocus() != gw->urlbar)
|
|
|
|
break;
|
|
|
|
|
|
|
|
int len = SendMessage(gw->urlbar, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
char addr[len + 1];
|
|
|
|
SendMessage(gw->urlbar, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)addr);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "launching %s\n", addr);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
2020-02-24 14:57:18 +03:00
|
|
|
err = nsurl_create(addr, &url);
|
|
|
|
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
win32_report_nserror(err, 0);
|
2015-03-13 02:48:53 +03:00
|
|
|
} else {
|
|
|
|
browser_window_navigate(gw->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
BW_NAVIGATE_HISTORY,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 1; /* unhandled */
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0; /* control message handled */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
/**
|
|
|
|
* Get the scroll position of a win32 browser window.
|
|
|
|
*
|
2017-02-17 23:44:37 +03:00
|
|
|
* \param gw gui_window
|
|
|
|
* \param sx receives x ordinate of point at top-left of window
|
|
|
|
* \param sy receives y ordinate of point at top-left of window
|
2016-10-29 19:24:31 +03:00
|
|
|
* \return true iff successful
|
|
|
|
*/
|
|
|
|
static bool win32_window_get_scroll(struct gui_window *gw, int *sx, int *sy)
|
|
|
|
{
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "get scroll");
|
2016-10-29 19:24:31 +03:00
|
|
|
if (gw == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*sx = gw->scrollx;
|
|
|
|
*sy = gw->scrolly;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
/**
|
|
|
|
* handle WM_SIZE message on main browser window
|
|
|
|
*
|
|
|
|
* \param gw win32 gui window
|
|
|
|
* \param hwnd The win32 window handle
|
|
|
|
* \param wparam The w win32 parameter
|
|
|
|
* \param lparam The l win32 parameter
|
2017-02-17 23:44:37 +03:00
|
|
|
* \return appropriate response for resize
|
2016-10-27 01:19:43 +03:00
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static LRESULT
|
|
|
|
nsws_window_resize(struct gui_window *gw,
|
|
|
|
HWND hwnd,
|
|
|
|
WPARAM wparam,
|
|
|
|
LPARAM lparam)
|
|
|
|
{
|
|
|
|
RECT rstatus, rtool;
|
|
|
|
|
|
|
|
if ((gw->toolbar == NULL) ||
|
|
|
|
(gw->urlbar == NULL) ||
|
|
|
|
(gw->statusbar == NULL))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SendMessage(gw->statusbar, WM_SIZE, wparam, lparam);
|
|
|
|
SendMessage(gw->toolbar, WM_SIZE, wparam, lparam);
|
|
|
|
|
|
|
|
GetClientRect(gw->toolbar, &rtool);
|
|
|
|
GetWindowRect(gw->statusbar, &rstatus);
|
|
|
|
gw->width = LOWORD(lparam);
|
|
|
|
gw->height = HIWORD(lparam) - (rtool.bottom - rtool.top) - (rstatus.bottom - rstatus.top);
|
|
|
|
|
|
|
|
if (gw->drawingarea != NULL) {
|
|
|
|
MoveWindow(gw->drawingarea,
|
|
|
|
0,
|
|
|
|
rtool.bottom,
|
|
|
|
gw->width,
|
|
|
|
gw->height,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
nsws_window_update_forward_back(gw);
|
|
|
|
|
2017-07-30 12:24:13 +03:00
|
|
|
browser_window_update(gw->bw, false);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
if (gw->toolbar != NULL) {
|
|
|
|
SendMessage(gw->toolbar, TB_SETSTATE,
|
|
|
|
(WPARAM) IDM_NAV_STOP,
|
|
|
|
MAKELONG(TBSTATE_INDETERMINATE, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* callback for browser window win32 events
|
|
|
|
*
|
|
|
|
* \param hwnd The win32 window handle
|
|
|
|
* \param msg The win32 message identifier
|
|
|
|
* \param wparam The w win32 parameter
|
|
|
|
* \param lparam The l win32 parameter
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
RECT rmain;
|
2019-12-16 03:31:48 +03:00
|
|
|
LPCREATESTRUCTW createstruct;
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
LOG_WIN_MSG(hwnd, msg, wparam, lparam);
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
gw = nsws_get_gui_window(hwnd);
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_NCCREATE: /* non client area create */
|
|
|
|
/* gw is passed as the lpParam from createwindowex() */
|
|
|
|
createstruct = (LPCREATESTRUCTW)lparam;
|
|
|
|
gw = (struct gui_window *)createstruct->lpCreateParams;
|
|
|
|
|
|
|
|
/* set the gui window associated with this window handle */
|
|
|
|
SetProp(hwnd, TEXT("GuiWnd"), (HANDLE)gw);
|
|
|
|
|
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"created hWnd:%p hInstance %p GUI window %p",
|
|
|
|
hwnd, createstruct->hInstance, gw);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CREATE:
|
|
|
|
/*
|
|
|
|
* To cause all the component child windows to be
|
2015-03-13 02:48:53 +03:00
|
|
|
* re-sized correctly a WM_SIZE message of the actual
|
|
|
|
* created size must be sent.
|
|
|
|
*
|
|
|
|
* The message must be posted here because the actual
|
|
|
|
* size values of the component windows are not known
|
|
|
|
* until after the WM_CREATE message is dispatched.
|
|
|
|
*/
|
|
|
|
GetClientRect(hwnd, &rmain);
|
2019-12-16 03:31:48 +03:00
|
|
|
PostMessage(hwnd, WM_SIZE, 0,
|
|
|
|
MAKELPARAM(rmain.right, rmain.bottom));
|
|
|
|
break;
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
case WM_CONTEXTMENU:
|
|
|
|
if (nsws_ctx_menu(gw, hwnd, GET_X_LPARAM(lparam),
|
|
|
|
GET_Y_LPARAM(lparam))) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (nsws_window_command(hwnd, gw, HIWORD(wparam),
|
|
|
|
LOWORD(wparam), (HWND)lparam) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
return nsws_window_resize(gw, hwnd, wparam, lparam);
|
|
|
|
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
RemoveProp(hwnd, TEXT("GuiWnd"));
|
2017-06-02 01:57:09 +03:00
|
|
|
nsw32_local_history_hide();
|
2015-03-13 02:48:53 +03:00
|
|
|
browser_window_destroy(gw->bw);
|
|
|
|
if (--open_windows <= 0) {
|
|
|
|
win32_set_quit(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-01 14:27:21 +03:00
|
|
|
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
static void destroy_page_info_bitmaps(struct gui_window *gw)
|
|
|
|
{
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_UNKNOWN]);
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_INTERNAL]);
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_LOCAL]);
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_INSECURE]);
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_SECURE_OVERRIDE]);
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_SECURE_ISSUES]);
|
|
|
|
DeleteObject(gw->hPageInfo[PAGE_STATE_SECURE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void load_page_info_bitmaps(HINSTANCE hInstance, struct gui_window *gw)
|
|
|
|
{
|
|
|
|
gw->hPageInfo[PAGE_STATE_UNKNOWN] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_INTERNAL),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
gw->hPageInfo[PAGE_STATE_INTERNAL] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_INTERNAL),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
gw->hPageInfo[PAGE_STATE_LOCAL] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_LOCAL),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
gw->hPageInfo[PAGE_STATE_INSECURE] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_INSECURE),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
gw->hPageInfo[PAGE_STATE_SECURE_OVERRIDE] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_WARNING),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
gw->hPageInfo[PAGE_STATE_SECURE_ISSUES] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_WARNING),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
gw->hPageInfo[PAGE_STATE_SECURE] = LoadImage(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDB_PAGEINFO_SECURE),
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
}
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* create a new gui_window to contain a browser_window.
|
|
|
|
*
|
|
|
|
* \param bw the browser_window to connect to the new gui_window
|
|
|
|
* \param existing An existing window.
|
|
|
|
* \param flags The flags controlling the construction.
|
|
|
|
* \return The new win32 gui window or NULL on error.
|
|
|
|
*/
|
|
|
|
static struct gui_window *
|
|
|
|
win32_window_create(struct browser_window *bw,
|
2016-10-27 01:19:43 +03:00
|
|
|
struct gui_window *existing,
|
|
|
|
gui_window_create_flags flags)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Creating gui window for browser window %p", bw);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
gw = calloc(1, sizeof(struct gui_window));
|
|
|
|
if (gw == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* connect gui window to browser window */
|
|
|
|
gw->bw = bw;
|
|
|
|
|
|
|
|
gw->width = 800;
|
|
|
|
gw->height = 600;
|
|
|
|
gw->toolbuttonsize = 24;
|
|
|
|
gw->requestscrollx = 0;
|
|
|
|
gw->requestscrolly = 0;
|
|
|
|
gw->localhistory = NULL;
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
load_page_info_bitmaps(hinst, gw);
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
gw->mouse = malloc(sizeof(struct browser_mouse));
|
|
|
|
if (gw->mouse == NULL) {
|
|
|
|
free(gw);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Unable to allocate mouse state");
|
2015-03-13 02:48:53 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
gw->mouse->gui = gw;
|
|
|
|
gw->mouse->state = 0;
|
|
|
|
gw->mouse->pressed_x = 0;
|
|
|
|
gw->mouse->pressed_y = 0;
|
|
|
|
|
|
|
|
/* add window to list */
|
2016-10-27 01:19:43 +03:00
|
|
|
if (window_list != NULL) {
|
2015-03-13 02:48:53 +03:00
|
|
|
window_list->prev = gw;
|
2016-10-27 01:19:43 +03:00
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
gw->next = window_list;
|
|
|
|
window_list = gw;
|
|
|
|
|
2016-10-30 15:58:43 +03:00
|
|
|
gw->main = nsws_window_create(hinst, gw);
|
|
|
|
gw->toolbar = nsws_window_create_toolbar(hinst, gw->main, gw);
|
|
|
|
gw->statusbar = nsws_window_create_statusbar(hinst, gw->main, gw);
|
|
|
|
gw->drawingarea = nsws_window_create_drawable(hinst, gw->main, gw);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"new window: main:%p toolbar:%p statusbar %p drawingarea %p",
|
|
|
|
gw->main,
|
|
|
|
gw->toolbar,
|
|
|
|
gw->statusbar,
|
|
|
|
gw->drawingarea);
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
font_hwnd = gw->drawingarea;
|
|
|
|
open_windows++;
|
|
|
|
ShowWindow(gw->main, SW_SHOWNORMAL);
|
|
|
|
|
|
|
|
return gw;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* Destroy previously created win32 window
|
|
|
|
*
|
|
|
|
* \param w The gui window to destroy.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static void win32_window_destroy(struct gui_window *w)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (w->prev != NULL)
|
|
|
|
w->prev->next = w->next;
|
|
|
|
else
|
|
|
|
window_list = w->next;
|
|
|
|
|
|
|
|
if (w->next != NULL)
|
|
|
|
w->next->prev = w->prev;
|
|
|
|
|
|
|
|
DestroyAcceleratorTable(w->acceltable);
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
destroy_page_info_bitmaps(w);
|
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
free(w);
|
|
|
|
w = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
/**
|
|
|
|
* Find the current dimensions of a win32 browser window's content area.
|
|
|
|
*
|
|
|
|
* \param gw gui_window to measure
|
|
|
|
* \param width receives width of window
|
|
|
|
* \param height receives height of window
|
2019-08-02 14:25:35 +03:00
|
|
|
* \return NSERROR_OK and width and height updated
|
2016-10-27 01:19:43 +03:00
|
|
|
*/
|
2017-04-26 11:55:36 +03:00
|
|
|
static nserror
|
2019-08-02 14:25:35 +03:00
|
|
|
win32_window_get_dimensions(struct gui_window *gw, int *width, int *height)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2016-03-18 00:55:12 +03:00
|
|
|
*width = gw->width;
|
|
|
|
*height = gw->height;
|
2017-04-26 11:55:36 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "gw:%p w=%d h=%d", gw, *width, *height);
|
2017-04-26 11:55:36 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the extent of the inside of a browser window to that of the
|
|
|
|
* current content.
|
|
|
|
*
|
|
|
|
* \param w gui_window to update the extent of
|
|
|
|
*/
|
2019-08-03 17:53:07 +03:00
|
|
|
static void win32_window_update_extent(struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2019-08-03 17:53:07 +03:00
|
|
|
struct rect rect;
|
|
|
|
rect.x0 = rect.x1 = gw->scrollx;
|
|
|
|
rect.y0 = rect.y1 = gw->scrolly;
|
|
|
|
win32_window_set_scroll(gw, &rect);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* set win32 browser window title
|
2015-03-13 02:48:53 +03:00
|
|
|
*
|
2016-10-27 01:19:43 +03:00
|
|
|
* \param w the win32 gui window.
|
2015-03-13 02:48:53 +03:00
|
|
|
* \param title to set on window
|
|
|
|
*/
|
|
|
|
static void win32_window_set_title(struct gui_window *w, const char *title)
|
|
|
|
{
|
2017-02-17 23:44:37 +03:00
|
|
|
char *fulltitle;
|
2019-12-01 14:27:21 +03:00
|
|
|
int wlen;
|
|
|
|
LPWSTR enctitle;
|
2017-02-17 23:44:37 +03:00
|
|
|
|
|
|
|
if (w == NULL) {
|
2015-03-13 02:48:53 +03:00
|
|
|
return;
|
2017-02-17 23:44:37 +03:00
|
|
|
}
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "%p, title %s", w, title);
|
2017-02-17 23:44:37 +03:00
|
|
|
fulltitle = malloc(strlen(title) + SLEN(" - NetSurf") + 1);
|
2015-03-13 02:48:53 +03:00
|
|
|
if (fulltitle == NULL) {
|
2019-12-01 14:27:21 +03:00
|
|
|
NSLOG(netsurf, ERROR, "%s",
|
|
|
|
messages_get_errorcode(NSERROR_NOMEM));
|
2015-03-13 02:48:53 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-02-17 23:44:37 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
strcpy(fulltitle, title);
|
|
|
|
strcat(fulltitle, " - NetSurf");
|
2017-02-17 23:44:37 +03:00
|
|
|
|
2019-12-01 14:27:21 +03:00
|
|
|
wlen = MultiByteToWideChar(CP_UTF8, 0, fulltitle, -1, NULL, 0);
|
|
|
|
if (wlen == 0) {
|
|
|
|
NSLOG(netsurf, ERROR, "failed encoding \"%s\"", fulltitle);
|
|
|
|
free(fulltitle);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
enctitle = malloc(2 * (wlen + 1));
|
|
|
|
if (enctitle == NULL) {
|
|
|
|
NSLOG(netsurf, ERROR, "%s encoding \"%s\" len %d",
|
|
|
|
messages_get_errorcode(NSERROR_NOMEM), fulltitle, wlen);
|
|
|
|
free(fulltitle);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, fulltitle, -1, enctitle, wlen);
|
|
|
|
SetWindowTextW(w->main, enctitle);
|
|
|
|
free(enctitle);
|
2015-03-13 02:48:53 +03:00
|
|
|
free(fulltitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
/**
|
2017-02-17 23:44:37 +03:00
|
|
|
* Set the navigation url in a win32 browser window.
|
2016-10-27 01:19:43 +03:00
|
|
|
*
|
|
|
|
* \param gw window to update.
|
|
|
|
* \param url The url to use as icon.
|
|
|
|
*/
|
|
|
|
static nserror win32_window_set_url(struct gui_window *gw, nsurl *url)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2016-10-27 01:19:43 +03:00
|
|
|
SendMessage(gw->urlbar, WM_SETTEXT, 0, (LPARAM) nsurl_access(url));
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* Set the status bar of a win32 browser window.
|
|
|
|
*
|
|
|
|
* \param w gui_window to update
|
|
|
|
* \param text new status text
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
|
|
|
static void win32_window_set_status(struct gui_window *w, const char *text)
|
|
|
|
{
|
2016-10-27 01:19:43 +03:00
|
|
|
if (w == NULL) {
|
2015-03-13 02:48:53 +03:00
|
|
|
return;
|
2016-10-27 01:19:43 +03:00
|
|
|
}
|
2015-03-13 02:48:53 +03:00
|
|
|
SendMessage(w->statusbar, WM_SETTEXT, 0, (LPARAM)text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* Change the win32 mouse pointer shape
|
|
|
|
*
|
|
|
|
* \param w The gui window to change pointer shape in.
|
|
|
|
* \param shape The new shape to change to.
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2016-10-27 01:19:43 +03:00
|
|
|
static void
|
|
|
|
win32_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2015-03-13 17:32:06 +03:00
|
|
|
SetCursor(nsws_get_pointer(shape));
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* Give the win32 input focus to a window
|
|
|
|
*
|
|
|
|
* \param w window with caret
|
|
|
|
* \param x coordinates of caret
|
|
|
|
* \param y coordinates of caret
|
|
|
|
* \param height height of caret
|
|
|
|
* \param clip rectangle to clip caret or NULL if none
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2016-10-27 01:19:43 +03:00
|
|
|
static void
|
|
|
|
win32_window_place_caret(struct gui_window *w, int x, int y,
|
|
|
|
int height, const struct rect *clip)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2016-10-27 01:19:43 +03:00
|
|
|
if (w == NULL) {
|
2015-03-13 02:48:53 +03:00
|
|
|
return;
|
2016-10-27 01:19:43 +03:00
|
|
|
}
|
|
|
|
|
2019-08-04 13:23:35 +03:00
|
|
|
CreateCaret(w->drawingarea, (HBITMAP)NULL, 1, height );
|
|
|
|
SetCaretPos(x - w->scrollx, y - w->scrolly);
|
2015-03-13 02:48:53 +03:00
|
|
|
ShowCaret(w->drawingarea);
|
|
|
|
}
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
/**
|
2016-10-27 01:19:43 +03:00
|
|
|
* Remove the win32 input focus from window
|
|
|
|
*
|
2017-02-22 11:30:58 +03:00
|
|
|
* \param gw window with caret
|
2015-03-13 02:48:53 +03:00
|
|
|
*/
|
2017-02-22 11:30:58 +03:00
|
|
|
static void win32_window_remove_caret(struct gui_window *gw)
|
2015-03-13 02:48:53 +03:00
|
|
|
{
|
2017-02-22 11:30:58 +03:00
|
|
|
if (gw == NULL)
|
2015-03-13 02:48:53 +03:00
|
|
|
return;
|
2017-02-22 11:30:58 +03:00
|
|
|
HideCaret(gw->drawingarea);
|
2015-03-13 02:48:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
/**
|
|
|
|
* start a win32 navigation throbber.
|
|
|
|
*
|
|
|
|
* \param w window in which to start throbber.
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static void win32_window_start_throbber(struct gui_window *w)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
nsws_window_update_forward_back(w);
|
|
|
|
|
|
|
|
if (w->mainmenu != NULL) {
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_NAV_STOP, MF_ENABLED);
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_NAV_RELOAD, MF_GRAYED);
|
|
|
|
}
|
|
|
|
if (w->rclick != NULL) {
|
|
|
|
EnableMenuItem(w->rclick, IDM_NAV_STOP, MF_ENABLED);
|
|
|
|
EnableMenuItem(w->rclick, IDM_NAV_RELOAD, MF_GRAYED);
|
|
|
|
}
|
|
|
|
if (w->toolbar != NULL) {
|
|
|
|
SendMessage(w->toolbar, TB_SETSTATE, (WPARAM) IDM_NAV_STOP,
|
|
|
|
MAKELONG(TBSTATE_ENABLED, 0));
|
|
|
|
SendMessage(w->toolbar, TB_SETSTATE,
|
|
|
|
(WPARAM) IDM_NAV_RELOAD,
|
|
|
|
MAKELONG(TBSTATE_INDETERMINATE, 0));
|
|
|
|
}
|
|
|
|
w->throbbing = true;
|
|
|
|
Animate_Play(w->throbber, 0, -1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
/**
|
|
|
|
* stop a win32 navigation throbber.
|
|
|
|
*
|
|
|
|
* \param w window with throbber to stop
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static void win32_window_stop_throbber(struct gui_window *w)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsws_window_update_forward_back(w);
|
|
|
|
if (w->mainmenu != NULL) {
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_NAV_STOP, MF_GRAYED);
|
|
|
|
EnableMenuItem(w->mainmenu, IDM_NAV_RELOAD, MF_ENABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w->rclick != NULL) {
|
|
|
|
EnableMenuItem(w->rclick, IDM_NAV_STOP, MF_GRAYED);
|
|
|
|
EnableMenuItem(w->rclick, IDM_NAV_RELOAD, MF_ENABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w->toolbar != NULL) {
|
|
|
|
SendMessage(w->toolbar, TB_SETSTATE, (WPARAM) IDM_NAV_STOP,
|
|
|
|
MAKELONG(TBSTATE_INDETERMINATE, 0));
|
|
|
|
SendMessage(w->toolbar, TB_SETSTATE,
|
|
|
|
(WPARAM) IDM_NAV_RELOAD,
|
|
|
|
MAKELONG(TBSTATE_ENABLED, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
w->throbbing = false;
|
|
|
|
Animate_Stop(w->throbber);
|
|
|
|
Animate_Seek(w->throbber, 0);
|
|
|
|
}
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
/**
|
|
|
|
* win32 page info change.
|
|
|
|
*
|
|
|
|
* \param gw window to chnage info on
|
|
|
|
*/
|
|
|
|
static void win32_window_page_info_change(struct gui_window *gw)
|
|
|
|
{
|
|
|
|
HWND hbutton;
|
|
|
|
browser_window_page_info_state pistate;
|
|
|
|
|
|
|
|
hbutton = GetProp(gw->toolbar, TEXT("hPGIbutton"));
|
|
|
|
|
|
|
|
pistate = browser_window_get_page_info_state(gw->bw);
|
|
|
|
|
|
|
|
SendMessageW(hbutton, BM_SETIMAGE, IMAGE_BITMAP,
|
|
|
|
(LPARAM)gw->hPageInfo[pistate]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-20 02:16:52 +03:00
|
|
|
/**
|
|
|
|
* process miscellaneous window events
|
|
|
|
*
|
|
|
|
* \param gw The window receiving the event.
|
|
|
|
* \param event The event code.
|
|
|
|
* \return NSERROR_OK when processed ok
|
|
|
|
*/
|
|
|
|
static nserror
|
|
|
|
win32_window_event(struct gui_window *gw, enum gui_window_event event)
|
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case GW_EVENT_UPDATE_EXTENT:
|
|
|
|
win32_window_update_extent(gw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GW_EVENT_REMOVE_CARET:
|
|
|
|
win32_window_remove_caret(gw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GW_EVENT_START_THROBBER:
|
|
|
|
win32_window_start_throbber(gw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GW_EVENT_STOP_THROBBER:
|
|
|
|
win32_window_stop_throbber(gw);
|
|
|
|
break;
|
|
|
|
|
2019-12-16 03:31:48 +03:00
|
|
|
case GW_EVENT_PAGE_INFO_CHANGE:
|
|
|
|
win32_window_page_info_change(gw);
|
|
|
|
break;
|
|
|
|
|
2019-08-20 02:16:52 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
/**
|
|
|
|
* win32 frontend browser window handling operation table
|
|
|
|
*/
|
2015-03-13 02:48:53 +03:00
|
|
|
static struct gui_window_table window_table = {
|
|
|
|
.create = win32_window_create,
|
|
|
|
.destroy = win32_window_destroy,
|
2017-04-23 14:04:07 +03:00
|
|
|
.invalidate = win32_window_invalidate_area,
|
2015-03-13 02:48:53 +03:00
|
|
|
.get_scroll = win32_window_get_scroll,
|
|
|
|
.set_scroll = win32_window_set_scroll,
|
|
|
|
.get_dimensions = win32_window_get_dimensions,
|
2019-08-20 02:16:52 +03:00
|
|
|
.event = win32_window_event,
|
2015-03-13 02:48:53 +03:00
|
|
|
|
|
|
|
.set_title = win32_window_set_title,
|
|
|
|
.set_url = win32_window_set_url,
|
|
|
|
.set_status = win32_window_set_status,
|
|
|
|
.set_pointer = win32_window_set_pointer,
|
|
|
|
.place_caret = win32_window_place_caret,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gui_window_table *win32_window_table = &window_table;
|
|
|
|
|
2016-10-27 01:19:43 +03:00
|
|
|
|
2015-03-13 02:48:53 +03:00
|
|
|
/* exported interface documented in windows/window.h */
|
|
|
|
struct gui_window *nsws_get_gui_window(HWND hwnd)
|
2011-04-04 02:01:37 +04:00
|
|
|
{
|
|
|
|
struct gui_window *gw = NULL;
|
|
|
|
HWND phwnd = hwnd;
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
/* scan the window hierarchy for gui window */
|
2011-04-04 02:01:37 +04:00
|
|
|
while (phwnd != NULL) {
|
|
|
|
gw = GetProp(phwnd, TEXT("GuiWnd"));
|
|
|
|
if (gw != NULL)
|
|
|
|
break;
|
|
|
|
phwnd = GetParent(phwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gw == NULL) {
|
|
|
|
/* try again looking for owner windows instead */
|
|
|
|
phwnd = hwnd;
|
|
|
|
while (phwnd != NULL) {
|
|
|
|
gw = GetProp(phwnd, TEXT("GuiWnd"));
|
|
|
|
if (gw != NULL)
|
|
|
|
break;
|
|
|
|
phwnd = GetWindow(phwnd, GW_OWNER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return gw;
|
|
|
|
}
|
2015-03-13 17:32:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in windows/window.h */
|
|
|
|
bool nsws_window_go(HWND hwnd, const char *urltxt)
|
|
|
|
{
|
|
|
|
struct gui_window *gw;
|
|
|
|
nsurl *url;
|
2020-02-24 15:10:35 +03:00
|
|
|
nserror ret;
|
2015-03-13 17:32:06 +03:00
|
|
|
|
|
|
|
gw = nsws_get_gui_window(hwnd);
|
|
|
|
if (gw == NULL)
|
|
|
|
return false;
|
2020-02-24 15:10:35 +03:00
|
|
|
ret = nsurl_create(urltxt, &url);
|
2015-03-13 17:32:06 +03:00
|
|
|
|
2020-02-24 15:10:35 +03:00
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
win32_report_nserror(ret, 0);
|
2015-03-13 17:32:06 +03:00
|
|
|
} else {
|
|
|
|
browser_window_navigate(gw->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
BW_NAVIGATE_HISTORY,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-29 19:24:31 +03:00
|
|
|
/* exported interface documented in windows/window.h */
|
2017-04-27 00:27:49 +03:00
|
|
|
nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect)
|
2016-10-29 19:24:31 +03:00
|
|
|
{
|
|
|
|
SCROLLINFO si;
|
2017-04-27 00:27:49 +03:00
|
|
|
nserror res;
|
2016-10-29 19:24:31 +03:00
|
|
|
int height;
|
|
|
|
int width;
|
|
|
|
POINT p;
|
|
|
|
|
2017-04-27 00:27:49 +03:00
|
|
|
if ((gw == NULL) || (gw->bw == NULL)) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
2016-10-29 19:24:31 +03:00
|
|
|
}
|
|
|
|
|
2017-04-27 00:27:49 +03:00
|
|
|
res = browser_window_get_extents(gw->bw, true, &width, &height);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return res;
|
|
|
|
}
|
2016-10-29 19:24:31 +03:00
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
/* The resulting gui window scroll must remain within the
|
2016-10-29 19:24:31 +03:00
|
|
|
* windows bounding box.
|
|
|
|
*/
|
2017-04-27 00:27:49 +03:00
|
|
|
if (rect->x0 < 0) {
|
|
|
|
gw->requestscrollx = -gw->scrollx;
|
|
|
|
} else if (rect->x0 > (width - gw->width)) {
|
|
|
|
gw->requestscrollx = (width - gw->width) - gw->scrollx;
|
2016-10-29 19:24:31 +03:00
|
|
|
} else {
|
2017-04-27 00:27:49 +03:00
|
|
|
gw->requestscrollx = rect->x0 - gw->scrollx;
|
2016-10-29 19:24:31 +03:00
|
|
|
}
|
2017-04-27 00:27:49 +03:00
|
|
|
if (rect->y0 < 0) {
|
|
|
|
gw->requestscrolly = -gw->scrolly;
|
|
|
|
} else if (rect->y0 > (height - gw->height)) {
|
|
|
|
gw->requestscrolly = (height - gw->height) - gw->scrolly;
|
2016-10-29 19:24:31 +03:00
|
|
|
} else {
|
2017-04-27 00:27:49 +03:00
|
|
|
gw->requestscrolly = rect->y0 - gw->scrolly;
|
2016-10-29 19:24:31 +03:00
|
|
|
}
|
|
|
|
|
2017-09-07 20:12:09 +03:00
|
|
|
NSLOG(netsurf, DEEPDEBUG,
|
|
|
|
"requestscroll x,y:%d,%d",
|
2017-09-08 21:46:29 +03:00
|
|
|
gw->requestscrollx, gw->requestscrolly);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
|
|
|
/* set the vertical scroll offset */
|
|
|
|
si.cbSize = sizeof(si);
|
|
|
|
si.fMask = SIF_ALL;
|
|
|
|
si.nMin = 0;
|
|
|
|
si.nMax = height - 1;
|
2017-04-27 00:27:49 +03:00
|
|
|
si.nPage = gw->height;
|
|
|
|
si.nPos = max(gw->scrolly + gw->requestscrolly, 0);
|
|
|
|
si.nPos = min(si.nPos, height - gw->height);
|
|
|
|
SetScrollInfo(gw->drawingarea, SB_VERT, &si, TRUE);
|
2017-09-07 20:12:09 +03:00
|
|
|
NSLOG(netsurf, DEEPDEBUG,
|
|
|
|
"SetScrollInfo VERT min:%d max:%d page:%d pos:%d",
|
|
|
|
si.nMin, si.nMax, si.nPage, si.nPos);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
|
|
|
/* set the horizontal scroll offset */
|
|
|
|
si.cbSize = sizeof(si);
|
|
|
|
si.fMask = SIF_ALL;
|
|
|
|
si.nMin = 0;
|
|
|
|
si.nMax = width -1;
|
2017-04-27 00:27:49 +03:00
|
|
|
si.nPage = gw->width;
|
|
|
|
si.nPos = max(gw->scrollx + gw->requestscrollx, 0);
|
|
|
|
si.nPos = min(si.nPos, width - gw->width);
|
|
|
|
SetScrollInfo(gw->drawingarea, SB_HORZ, &si, TRUE);
|
2017-09-07 20:12:09 +03:00
|
|
|
NSLOG(netsurf, DEEPDEBUG,
|
|
|
|
"SetScrollInfo HORZ min:%d max:%d page:%d pos:%d",
|
|
|
|
si.nMin, si.nMax, si.nPage, si.nPos);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
|
|
|
/* Set caret position */
|
|
|
|
GetCaretPos(&p);
|
2017-04-27 00:27:49 +03:00
|
|
|
HideCaret(gw->drawingarea);
|
|
|
|
SetCaretPos(p.x - gw->requestscrollx, p.y - gw->requestscrolly);
|
|
|
|
ShowCaret(gw->drawingarea);
|
2016-10-29 19:24:31 +03:00
|
|
|
|
|
|
|
RECT r, redraw;
|
|
|
|
r.top = 0;
|
2017-04-27 00:27:49 +03:00
|
|
|
r.bottom = gw->height + 1;
|
2016-10-29 19:24:31 +03:00
|
|
|
r.left = 0;
|
2017-04-27 00:27:49 +03:00
|
|
|
r.right = gw->width + 1;
|
2017-09-08 22:42:12 +03:00
|
|
|
ScrollWindowEx(gw->drawingarea,
|
|
|
|
- gw->requestscrollx,
|
|
|
|
- gw->requestscrolly,
|
|
|
|
&r,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&redraw,
|
|
|
|
SW_INVALIDATE);
|
2017-09-07 20:12:09 +03:00
|
|
|
NSLOG(netsurf, DEEPDEBUG,
|
|
|
|
"ScrollWindowEx %d, %d",
|
2017-09-08 22:42:12 +03:00
|
|
|
- gw->requestscrollx,
|
|
|
|
- gw->requestscrolly);
|
|
|
|
|
2017-04-27 00:27:49 +03:00
|
|
|
gw->scrolly += gw->requestscrolly;
|
|
|
|
gw->scrollx += gw->requestscrollx;
|
|
|
|
gw->requestscrollx = 0;
|
|
|
|
gw->requestscrolly = 0;
|
2016-10-29 19:24:31 +03:00
|
|
|
|
2017-04-27 00:27:49 +03:00
|
|
|
return NSERROR_OK;
|
2016-10-29 19:24:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in windows/window.h */
|
|
|
|
nserror
|
2016-10-30 15:58:43 +03:00
|
|
|
nsws_create_main_class(HINSTANCE hinstance)
|
|
|
|
{
|
2016-10-29 19:24:31 +03:00
|
|
|
nserror ret = NSERROR_OK;
|
2019-12-01 14:27:21 +03:00
|
|
|
WNDCLASSEXW wc;
|
2016-10-29 19:24:31 +03:00
|
|
|
|
|
|
|
/* main window */
|
2016-10-30 15:58:43 +03:00
|
|
|
wc.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wc.style = 0;
|
|
|
|
wc.lpfnWndProc = nsws_window_event_callback;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = hinstance;
|
|
|
|
wc.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDR_NETSURF_ICON));
|
|
|
|
wc.hCursor = NULL;
|
|
|
|
wc.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = windowclassname_main;
|
|
|
|
wc.hIconSm = LoadIcon(hinstance, MAKEINTRESOURCE(IDR_NETSURF_ICON));
|
|
|
|
|
2019-12-01 14:27:21 +03:00
|
|
|
if (RegisterClassExW(&wc) == 0) {
|
2016-10-30 15:58:43 +03:00
|
|
|
win_perror("MainWindowClass");
|
2016-10-29 19:24:31 +03:00
|
|
|
ret = NSERROR_INIT_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-13 17:32:06 +03:00
|
|
|
/* exported interface documented in windows/window.h */
|
|
|
|
HWND gui_window_main_window(struct gui_window *w)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return NULL;
|
|
|
|
return w->main;
|
|
|
|
}
|