diff options
Diffstat (limited to 'frontends/windows/corewindow.c')
-rw-r--r-- | frontends/windows/corewindow.c | 154 |
1 files changed, 135 insertions, 19 deletions
diff --git a/frontends/windows/corewindow.c b/frontends/windows/corewindow.c index 754e0e561..7d88ce7c4 100644 --- a/frontends/windows/corewindow.c +++ b/frontends/windows/corewindow.c @@ -155,7 +155,7 @@ nsw32_corewindow_vscroll(struct nsw32_corewindow *nsw32_cw, SCROLLINFO si; /* current scroll information */ SCROLLINFO usi; /* updated scroll infomation for scrollwindowex */ - LOG("VSCROLL"); + NSLOG(netsurf, INFO, "VSCROLL"); si.cbSize = sizeof(si); si.fMask = SIF_ALL; @@ -221,20 +221,105 @@ nsw32_corewindow_vscroll(struct nsw32_corewindow *nsw32_cw, return 0; } + +static LRESULT +nsw32_corewindow_hscroll(struct nsw32_corewindow *nsw32_cw, + HWND hwnd, + WPARAM wparam) +{ + SCROLLINFO si; /* current scroll information */ + SCROLLINFO usi; /* updated scroll infomation for scrollwindowex */ + + NSLOG(netsurf, INFO, "VSCROLL"); + + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_HORZ, &si); + usi = si; + + switch (LOWORD(wparam)) { + case SB_LINELEFT: + usi.nPos -= 30; + break; + + case SB_LINERIGHT: + usi.nPos += 30; + break; + + case SB_PAGELEFT: + usi.nPos -= si.nPage; + break; + + case SB_PAGERIGHT: + usi.nPos += si.nPage; + break; + + case SB_THUMBTRACK: + usi.nPos = si.nTrackPos; + break; + + default: + break; + } + + if (usi.nPos < si.nMin) { + usi.nPos = si.nMin; + } + if (usi.nPos > si.nMax) { + usi.nPos = si.nMax; + } + + SetScrollInfo(hwnd, SB_HORZ, &usi, TRUE); + + ScrollWindowEx(hwnd, + si.nPos - usi.nPos, + 0, + NULL, + NULL, + NULL, + NULL, + SW_INVALIDATE); + + return 0; +} + + static LRESULT nsw32_corewindow_mousedown(struct nsw32_corewindow *nsw32_cw, + HWND hwnd, int x, int y, browser_mouse_state button) { + SCROLLINFO si; /* scroll information */ + + /* get scroll positions */ + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + GetScrollInfo(hwnd, SB_HORZ, &si); + x += si.nPos; + GetScrollInfo(hwnd, SB_VERT, &si); + y += si.nPos; + nsw32_cw->mouse(nsw32_cw, button, x, y); return 0; } static LRESULT nsw32_corewindow_mouseup(struct nsw32_corewindow *nsw32_cw, + HWND hwnd, int x, int y, browser_mouse_state button) { + SCROLLINFO si; /* scroll information */ + + /* get scroll positions */ + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + GetScrollInfo(hwnd, SB_HORZ, &si); + x += si.nPos; + GetScrollInfo(hwnd, SB_VERT, &si); + y += si.nPos; + nsw32_cw->mouse(nsw32_cw, button, x, y); return 0; } @@ -275,26 +360,29 @@ nsw32_window_corewindow_event_callback(HWND hwnd, case WM_VSCROLL: return nsw32_corewindow_vscroll(nsw32_cw, hwnd, wparam); + case WM_HSCROLL: + return nsw32_corewindow_hscroll(nsw32_cw, hwnd, wparam); + case WM_LBUTTONDOWN: - return nsw32_corewindow_mousedown(nsw32_cw, + return nsw32_corewindow_mousedown(nsw32_cw, hwnd, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), BROWSER_MOUSE_PRESS_1); case WM_RBUTTONDOWN: - return nsw32_corewindow_mousedown(nsw32_cw, + return nsw32_corewindow_mousedown(nsw32_cw, hwnd, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), BROWSER_MOUSE_PRESS_2); case WM_LBUTTONUP: - return nsw32_corewindow_mouseup(nsw32_cw, + return nsw32_corewindow_mouseup(nsw32_cw, hwnd, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), BROWSER_MOUSE_CLICK_1); case WM_RBUTTONUP: - return nsw32_corewindow_mouseup(nsw32_cw, + return nsw32_corewindow_mouseup(nsw32_cw, hwnd, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), BROWSER_MOUSE_CLICK_2); @@ -307,21 +395,48 @@ nsw32_window_corewindow_event_callback(HWND hwnd, return DefWindowProc(hwnd, msg, wparam, lparam); } + /** - * callback from core to request a redraw + * callback from core to request an invalidation of a window area. + * + * The specified area of the window should now be considered + * out of date. If the area is NULL the entire window must be + * invalidated. + * + * \param[in] cw The core window to invalidate. + * \param[in] rect area to redraw or NULL for the entire window area. + * \return NSERROR_OK on success or appropriate error code. */ -static void -nsw32_cw_redraw_request(struct core_window *cw, const struct rect *r) +static nserror +nsw32_cw_invalidate_area(struct core_window *cw, const struct rect *rect) { struct nsw32_corewindow *nsw32_cw = (struct nsw32_corewindow *)cw; - RECT wr; + RECT *redrawrectp = NULL; + RECT redrawrect; + + if (rect != NULL) { + SCROLLINFO si; /* scroll information */ - wr.left = r->x0; - wr.top = r->y0; - wr.right = r->x1; - wr.bottom = r->y1; + /* get scroll positions */ + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + GetScrollInfo(nsw32_cw->hWnd, SB_HORZ, &si); + redrawrect.left = (long)rect->x0 - si.nPos; + redrawrect.right = (long)rect->x1 - si.nPos; - RedrawWindow(nsw32_cw->hWnd, &wr, NULL, RDW_INVALIDATE | RDW_NOERASE); + GetScrollInfo(nsw32_cw->hWnd, SB_VERT, &si); + redrawrect.top = (long)rect->y0 - si.nPos; + redrawrect.bottom = (long)rect->y1 - si.nPos; + + redrawrectp = &redrawrect; + } + + RedrawWindow(nsw32_cw->hWnd, + redrawrectp, + NULL, + RDW_INVALIDATE | RDW_NOERASE); + + return NSERROR_OK; } @@ -335,7 +450,7 @@ nsw32_cw_update_size(struct core_window *cw, int width, int height) nsw32_cw->content_width = width; nsw32_cw->content_height = height; - LOG("new content size w:%d h:%d", width, height); + NSLOG(netsurf, INFO, "new content size w:%d h:%d", width, height); update_scrollbars(nsw32_cw); } @@ -371,12 +486,12 @@ static void nsw32_cw_drag_status(struct core_window *cw, core_window_drag_status ds) { struct nsw32_corewindow *nsw32_cw = (struct nsw32_corewindow *)cw; - nsw32_cw->drag_staus = ds; + nsw32_cw->drag_status = ds; } struct core_window_callback_table nsw32_cw_cb_table = { - .redraw_request = nsw32_cw_redraw_request, + .invalidate = nsw32_cw_invalidate_area, .update_size = nsw32_cw_update_size, .scroll_visible = nsw32_cw_scroll_visible, .get_window_dimensions = nsw32_cw_get_window_dimensions, @@ -393,6 +508,7 @@ nsw32_corewindow_init(HINSTANCE hInstance, /* setup the core window callback table */ nsw32_cw->cb_table = &nsw32_cw_cb_table; + nsw32_cw->drag_status = CORE_WINDOW_DRAG_NONE; /* start with the content area being as small as possible */ nsw32_cw->content_width = -1; @@ -411,7 +527,7 @@ nsw32_corewindow_init(HINSTANCE hInstance, CS_DBLCLKS; } - LOG("creating hInstance %p core window", hInstance); + NSLOG(netsurf, INFO, "creating hInstance %p core window", hInstance); nsw32_cw->hWnd = CreateWindowEx(0, windowclassname_corewindow, nsw32_cw->title, @@ -425,7 +541,7 @@ nsw32_corewindow_init(HINSTANCE hInstance, hInstance, NULL); if (nsw32_cw->hWnd == NULL) { - LOG("Window create failed"); + NSLOG(netsurf, INFO, "Window create failed"); return NSERROR_NOMEM; } |