r9490 chris_y - in /trunk/netsurf/amiga: gui.c gui.h
by netsurf@semichrome.net
Author: chris_y
Date: Fri Aug 28 18:12:18 2009
New Revision: 9490
URL: http://source.netsurf-browser.org?rev=9490&view=rev
Log:
Move status bar to bottom window border, as per NetSurf standard. Thanks to Thomas
Rapp and others for info on how to do this.
Currently there seems to be a glitch which is cancelling events, making typing in
gadgets very difficult and mouse dragging almost impossible.
Modified:
trunk/netsurf/amiga/gui.c
trunk/netsurf/amiga/gui.h
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=9490&r1=9...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Fri Aug 28 18:12:18 2009
@@ -133,6 +133,7 @@
static Object *mouseptrobj[AMI_LASTPOINTER+1];
static struct BitMap *mouseptrbm[AMI_LASTPOINTER+1];
static int mouseptrcurrent=0;
+static struct DrawInfo *dri;
char *ptrs[AMI_LASTPOINTER+1] = {
"ptr_default",
@@ -187,6 +188,9 @@
void ami_init_mouse_pointers(void);
void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
static void *myrealloc(void *ptr, size_t len, void *pw);
+void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs);
+ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin);
+ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2);
STRPTR ami_locale_langs(void)
{
@@ -573,6 +577,7 @@
scrn = LockPubScreen("Workbench");
}
}
+ dri = GetScreenDrawInfo(scrn);
}
void gui_init2(int argc, char** argv)
@@ -805,7 +810,7 @@
case WMHI_MOUSEMOVE:
GetAttr(SPACE_AreaBox,gwin->gadgets[GID_BROWSER],(ULONG *)&bbox);
- GetAttr(SCROLLER_Top,gwin->objects[OID_HSCROLL],(ULONG *)&xs);
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
x = gwin->win->MouseX - bbox->Left +xs; // mousex should be in intuimessage
GetAttr(SCROLLER_Top,gwin->objects[OID_VSCROLL],(ULONG *)&ys);
@@ -856,7 +861,7 @@
case WMHI_MOUSEBUTTONS:
GetAttr(SPACE_AreaBox,gwin->gadgets[GID_BROWSER],(ULONG *)&bbox);
- GetAttr(SCROLLER_Top,gwin->objects[OID_HSCROLL],(ULONG *)&xs);
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
x = gwin->win->MouseX - bbox->Left +xs;
GetAttr(SCROLLER_Top,gwin->objects[OID_VSCROLL],(ULONG *)&ys);
y = gwin->win->MouseY - bbox->Top + ys;
@@ -931,6 +936,12 @@
case WMHI_GADGETUP:
switch(result & WMHI_GADGETMASK) //gadaddr->GadgetID) //result & WMHI_GADGETMASK)
{
+ case GID_HSCROLL:
+ if(option_faster_scroll)
+ gwin->redraw_scroll = true;
+ gwin->redraw_required = true;
+ break;
+
case GID_TABS:
ami_switch_tab(gwin,true);
break;
@@ -1153,6 +1164,7 @@
switch(node->Type)
{
case AMINS_WINDOW:
+ ami_set_border_gadget_balance(gwin);
ami_update_throbber(gwin,true);
// fall through
case AMINS_FRAME:
@@ -1281,7 +1293,7 @@
{
GetAttr(SPACE_AreaBox,gwin->gadgets[GID_BROWSER],(ULONG *)&bbox);
- GetAttr(SCROLLER_Top,gwin->objects[OID_HSCROLL],(ULONG *)&xs);
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
x = (appmsg->am_MouseX) - (bbox->Left) +xs;
GetAttr(SCROLLER_Top,gwin->objects[OID_VSCROLL],(ULONG *)&ys);
@@ -1540,6 +1552,7 @@
ami_arexx_cleanup();
ami_free_layers(&browserglob);
+ FreeScreenDrawInfo(scrn, dri);
ami_close_fonts();
@@ -1869,6 +1882,7 @@
WA_CustomScreen,scrn,
WA_ReportMouse,TRUE,
WA_SmartRefresh,TRUE,
+ WA_SizeBBottom, TRUE,
WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_RAWKEY | IDCMP_SIZEVERIFY |
@@ -1877,7 +1891,7 @@
IDCMP_EXTENDEDMOUSE,
// WINDOW_IconifyGadget, TRUE,
WINDOW_NewMenu,menu,
- WINDOW_HorizProp,1,
+ // WINDOW_HorizProp,1,
WINDOW_VertProp,1,
WINDOW_IDCMPHook,&gwin->shared->scrollerhook,
WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE |
@@ -2021,11 +2035,6 @@
GA_ID,GID_BROWSER,
SPACE_Transparent,TRUE,
SpaceEnd,
- LAYOUT_AddChild, gwin->shared->gadgets[GID_STATUS] = StringObject,
- GA_ID,GID_STATUS,
- GA_ReadOnly,TRUE,
- StringEnd,
- CHILD_WeightedHeight,0,
EndGroup,
EndWindow;
}
@@ -2087,22 +2096,71 @@
return NULL;
}
+ GetAttr(WINDOW_VertObject, gwin->shared->objects[OID_MAIN],
+ (ULONG *)&gwin->shared->objects[OID_VSCROLL]);
+
+ RefreshSetGadgetAttrs((APTR)gwin->shared->objects[OID_VSCROLL],
+ gwin->shared->win, NULL,
+ GA_ID, OID_VSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+
+ if(bw->browser_window_type == BROWSER_WINDOW_NORMAL)
+ {
+ ULONG sz, size1, size2;
+
+ sz = ami_get_border_gadget_balance(gwin->shared,
+ (ULONG *)&size1, (ULONG *)&size2);
+
+ gwin->shared->gadgets[GID_HSCROLL] = (struct Gadget *)NewObject(
+ NULL,
+ "scrollergclass",
+ GA_ID, GID_HSCROLL,
+ PGA_Freedom, FREEHORIZ,
+ ICA_TARGET, ICTARGET_IDCMP,
+ // GA_Left, size1,
+ GA_RelRight, - size2 - sz,
+ GA_Width, size2,
+ GA_BottomBorder, TRUE,
+ GA_RelVerify, TRUE,
+ GA_DrawInfo, dri,
+ TAG_DONE);
+
+ GetAttr(GA_Height, gwin->shared->gadgets[GID_HSCROLL],
+ (ULONG *)&sz);
+
+ gwin->shared->gadgets[GID_STATUS] = (struct Gadget *)NewObject(
+ NULL,
+ "frbuttonclass",
+ GA_ID, GID_STATUS,
+ GA_Left, scrn->WBorLeft,
+ GA_RelBottom, -((1 + sz - scrn->RastPort.TxHeight)/2),
+ GA_Width, size1,
+ GA_DrawInfo, dri,
+ GA_BottomBorder, TRUE,
+ GA_RelVerify, TRUE,
+ GA_Next, gwin->shared->gadgets[GID_HSCROLL],
+ TAG_DONE);
+
+ AddGList(gwin->shared->win, gwin->shared->gadgets[GID_STATUS],
+ (UWORD)~0, -1, NULL);
+
+ RefreshGadgets((APTR)gwin->shared->gadgets[GID_STATUS],
+ gwin->shared->win, NULL);
+ }
+ else
+ {
+ GetAttr(WINDOW_HorizObject, gwin->shared->objects[OID_MAIN],
+ (ULONG *)&gwin->shared->objects[OID_HSCROLL]);
+
+ RefreshSetGadgetAttrs((APTR)gwin->shared->objects[OID_HSCROLL],
+ gwin->shared->win, NULL,
+ GA_ID, OID_HSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+ }
+
gwin->shared->bw = bw;
-
- GetAttr(WINDOW_HorizObject,gwin->shared->objects[OID_MAIN],(ULONG *)&gwin->shared->objects[OID_HSCROLL]);
- GetAttr(WINDOW_VertObject,gwin->shared->objects[OID_MAIN],(ULONG *)&gwin->shared->objects[OID_VSCROLL]);
-
-
- RefreshSetGadgetAttrs((APTR)gwin->shared->objects[OID_VSCROLL],gwin->shared->win,NULL,
- GA_ID,OID_VSCROLL,
- ICA_TARGET,ICTARGET_IDCMP,
- TAG_DONE);
-
- RefreshSetGadgetAttrs((APTR)gwin->shared->objects[OID_HSCROLL],gwin->shared->win,NULL,
- GA_ID,OID_HSCROLL,
- ICA_TARGET,ICTARGET_IDCMP,
- TAG_DONE);
-
curbw = bw;
gwin->shared->node = AddObject(window_list,AMINS_WINDOW);
@@ -2111,6 +2169,49 @@
glob = &browserglob;
return gwin;
+}
+
+ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin)
+{
+ /* Reset gadget widths according to new calculation */
+ ULONG size1, size2, sz;
+
+ sz = ami_get_border_gadget_balance(gwin, &size1, &size2);
+
+ RefreshSetGadgetAttrs((APTR)gwin->gadgets[GID_HSCROLL],
+ gwin->win, NULL,
+ // GA_Left, size1,
+ GA_RelRight, - size2 - sz,
+ GA_Width, size2,
+ TAG_DONE);
+
+ RefreshSetGadgetAttrs((APTR)gwin->gadgets[GID_STATUS],
+ gwin->win, NULL,
+ GA_Width, size1,
+ TAG_DONE);
+}
+
+ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2)
+{
+ /* Get the sizes that border gadget 1 (status) and 2 (hscroller) need to be.
+ ** Returns the width of the vertical scroller (right-hand window border) as
+ ** a convenience.
+ */
+
+ ULONG sz;
+ ULONG available_width;
+ float gad1percent;
+
+ GetAttr(GA_Width, gwin->objects[OID_VSCROLL], (ULONG *)&sz);
+
+ available_width = gwin->win->Width - scrn->WBorLeft - sz;
+
+ gad1percent = option_toolbar_status_width / 10000.0;
+
+ *size1 = (ULONG)available_width * gad1percent;
+ *size2 = (ULONG)available_width * (1 - gad1percent);
+
+ return sz;
}
void ami_close_all_tabs(struct gui_window_2 *gwin)
@@ -2317,7 +2418,7 @@
struct content *c;
c = g->shared->bw->current_content;
- GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],(ULONG *)&sx);
+ ami_get_hscroll_pos(g->shared, (ULONG *)&sx);
GetAttr(SCROLLER_Top,g->shared->objects[OID_VSCROLL],(ULONG *)&sy);
ami_do_redraw_limits(g,c,x0,y0,x1,y1,sx,sy);
@@ -2342,7 +2443,7 @@
if(!g) return;
- GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],(ULONG *)&sx);
+ ami_get_hscroll_pos(g->shared, (ULONG *)&sx);
GetAttr(SCROLLER_Top,g->shared->objects[OID_VSCROLL],(ULONG *)&sy);
ami_do_redraw_limits(g,g->shared->bw->current_content,
@@ -2363,7 +2464,7 @@
bool morescroll = false;
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
- GetAttr(SCROLLER_Top,g->objects[OID_HSCROLL],(ULONG *)&hcurrent);
+ ami_get_hscroll_pos(g, (ULONG *)&hcurrent);
GetAttr(SCROLLER_Top,g->objects[OID_VSCROLL],(ULONG *)&vcurrent);
c = g->bw->current_content;
@@ -2466,9 +2567,21 @@
g->new_content = false;
}
+void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs)
+{
+ if(gwin->gadgets[GID_HSCROLL])
+ {
+ GetAttr(PGA_Top, gwin->gadgets[GID_HSCROLL], xs);
+ }
+ else if(gwin->objects[OID_HSCROLL])
+ {
+ GetAttr(SCROLLER_Top, gwin->objects[OID_HSCROLL], xs);
+ }
+}
+
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
- GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],(ULONG *)sx);
+ ami_get_hscroll_pos(g->shared, (ULONG *)sx);
GetAttr(SCROLLER_Top,g->shared->objects[OID_VSCROLL],(ULONG *)sy);
}
@@ -2491,10 +2604,20 @@
SCROLLER_Top,sy,
TAG_DONE);
- RefreshSetGadgetAttrs((APTR)g->shared->objects[OID_HSCROLL],g->shared->win,NULL,
- SCROLLER_Top,sx,
- TAG_DONE);
-
+ if(g->shared->gadgets[GID_HSCROLL])
+ {
+ RefreshSetGadgetAttrs((APTR)g->shared->gadgets[GID_HSCROLL],
+ g->shared->win, NULL,
+ PGA_Top, sx,
+ TAG_DONE);
+ }
+ else if(g->shared->objects[OID_HSCROLL])
+ {
+ RefreshSetGadgetAttrs((APTR)g->shared->objects[OID_HSCROLL],
+ g->shared->win, NULL,
+ SCROLLER_Top, sx,
+ TAG_DONE);
+ }
g->shared->redraw_required = true;
if(option_faster_scroll) g->shared->redraw_scroll = true;
@@ -2565,10 +2688,23 @@
SCROLLER_Visible,bbox->Height,
TAG_DONE);
- RefreshSetGadgetAttrs((APTR)g->shared->objects[OID_HSCROLL],g->shared->win,NULL,
- SCROLLER_Total,g->shared->bw->current_content->width,
- SCROLLER_Visible,bbox->Width,
- TAG_DONE);
+ if(g->shared->gadgets[GID_HSCROLL])
+ {
+ RefreshSetGadgetAttrs((APTR)g->shared->gadgets[GID_HSCROLL],
+ g->shared->win, NULL,
+ PGA_Total, g->shared->bw->current_content->width,
+ PGA_Visible, bbox->Width,
+ TAG_DONE);
+ }
+ else if(g->shared->objects[OID_HSCROLL])
+ {
+ RefreshSetGadgetAttrs((APTR)g->shared->objects[OID_HSCROLL],
+ g->shared->win, NULL,
+ SCROLLER_Total, g->shared->bw->current_content->width,
+ SCROLLER_Visible, bbox->Width,
+ TAG_DONE);
+ }
+
}
g->shared->new_content = true;
}
@@ -2584,7 +2720,12 @@
if((cur_tab == g->tab) || (g->shared->tabs == 0))
{
- RefreshSetGadgetAttrs(g->shared->gadgets[GID_STATUS],g->shared->win,NULL,STRINGA_TextVal,text,TAG_DONE);
+ SetGadgetAttrs(g->shared->gadgets[GID_STATUS],
+ g->shared->win, NULL,
+ GA_Text, text,
+ TAG_DONE);
+
+ RefreshWindowFrame(g->shared->win);
}
}
@@ -2861,7 +3002,7 @@
gui_window_remove_caret(g);
GetAttr(SPACE_AreaBox,g->shared->gadgets[GID_BROWSER],(ULONG *)&bbox);
- GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],&xs);
+ ami_get_hscroll_pos(g->shared, (ULONG *)&xs);
GetAttr(SCROLLER_Top,g->shared->objects[OID_VSCROLL],&ys);
SetAPen(g->shared->win->RPort,3);
@@ -2889,7 +3030,7 @@
if(!g) return;
GetAttr(SPACE_AreaBox,g->shared->gadgets[GID_BROWSER],(ULONG *)&bbox);
- GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],(ULONG *)&xs);
+ ami_get_hscroll_pos(g->shared, (ULONG *)&xs);
GetAttr(SCROLLER_Top,g->shared->objects[OID_VSCROLL],(ULONG *)&ys);
BltBitMapRastPort(browserglob.bm,g->c_x-xs,g->c_y-ys,g->shared->win->RPort,bbox->Left+g->c_x-xs,bbox->Top+g->c_y-ys,2+1,g->c_h+1,0x0C0);
@@ -3023,7 +3164,7 @@
gid = GetTagData( GA_ID, 0, msg->IAddress );
switch( gid )
- {
+ {
case OID_HSCROLL:
case OID_VSCROLL:
// history_set_current_scroll(gwin->bw->history,
Modified: trunk/netsurf/amiga/gui.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.h?rev=9490&r1=9...
==============================================================================
--- trunk/netsurf/amiga/gui.h (original)
+++ trunk/netsurf/amiga/gui.h Fri Aug 28 18:12:18 2009
@@ -56,6 +56,7 @@
GID_NEXT,
GID_PREV,
GID_SEARCHSTRING,
+ GID_HSCROLL,
GID_LAST
};
@@ -65,7 +66,7 @@
OID_VSCROLL,
OID_HSCROLL,
OID_MENU,
- OID_LAST
+ OID_LAST
};
#define AMI_GUI_POINTER_BLANK GUI_POINTER_PROGRESS+1
13 years, 7 months
r9489 MarkieB - /branches/MarkieB/windows/windows/localhistory.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 12:59:39 2009
New Revision: 9489
URL: http://source.netsurf-browser.org?rev=9489&view=rev
Log:
history_redraw_rectangle simplifies matters :o)
Modified:
branches/MarkieB/windows/windows/localhistory.c
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Fri Aug 28 12:59:39 2009
@@ -40,8 +40,6 @@
struct nsws_localhistory {
HWND hwnd; /**< the window handle */
- HDC bufferdc; /**< the buffer dc */
- HBITMAP bufferbm; /**< the buffer bitmap */
int width; /**< the width of the memory history */
int height; /**< the height of the memory history */
int guiwidth; /**< the width of the history window */
@@ -239,17 +237,11 @@
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
HDC hdc = GetDC(hwnd);
+ ScrollWindowEx(hwnd, 0, mem - si.nPos, NULL, NULL, NULL,
+ NULL, 0);
localhistory.vscroll += si.nPos - mem;
- if (localhistory.bufferbm != NULL)
- BitBlt(hdc, 0, 0, MIN(localhistory.guiwidth,
- localhistory.width - localhistory.hscroll),
- MIN(localhistory.guiheight,
- localhistory.height -
- localhistory.vscroll),
- localhistory.bufferdc,
- localhistory.hscroll,
- localhistory.vscroll,
- SRCCOPY);
+/* history_redraw_rectangle();
+*/
ReleaseDC(hwnd, hdc);
}
break;
@@ -290,38 +282,20 @@
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
- HDC hdc = GetDC(hwnd);
+ ScrollWindowEx(hwnd, mem - si.nPos, 0, NULL, NULL, NULL,
+ NULL, 0);
localhistory.hscroll += si.nPos - mem;
- if (localhistory.bufferbm != NULL)
- BitBlt(hdc, 0, 0, MIN(localhistory.guiwidth,
- localhistory.width - localhistory.hscroll),
- MIN(localhistory.guiheight,
- localhistory.height -
- localhistory.vscroll),
- localhistory.bufferdc,
- localhistory.hscroll,
- localhistory.vscroll,
- SRCCOPY);
- ReleaseDC(hwnd, hdc);
+/* history_redraw_rectangle();
+*/
}
break;
}
case WM_PAINT: {
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
- if (bw != NULL)
- history_redraw(bw->history);
- if (localhistory.bufferbm != NULL)
- BitBlt(ps.hdc, 0, 0, MIN(localhistory.guiwidth,
- localhistory.width - localhistory.hscroll),
- MIN(localhistory.guiheight,
- localhistory.height -
- localhistory.vscroll),
- localhistory.bufferdc,
- localhistory.hscroll,
- localhistory.vscroll,
- SRCCOPY);
- EndPaint(hwnd, &ps);
+/* if (bw != NULL)
+ history_redraw_rectangle(bw->history);
+*/ EndPaint(hwnd, &ps);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
}
@@ -348,19 +322,8 @@
localhistory.vscroll = 0;
localhistory.hscroll = 0;
- hdc = GetDC(localhistory.hwnd);
- localhistory.bufferdc = CreateCompatibleDC(hdc);
- localhistory.bufferbm = CreateCompatibleBitmap(hdc, localhistory.width,
- localhistory.height);
- SelectObject(localhistory.bufferdc, localhistory.bufferbm);
-
- doublebuffering = true;
- bufferdc = localhistory.bufferdc;
if (bw != NULL)
history_redraw(bw->history);
- doublebuffering = false;
- BitBlt(hdc, 0, 0, localhistory.guiwidth, localhistory.guiheight,
- localhistory.bufferdc, 0, 0, SRCCOPY);
ReleaseDC(localhistory.hwnd, hdc);
}
@@ -419,7 +382,5 @@
{
if (w != NULL)
gui_window_set_localhistory(w, NULL);
- DeleteDC(localhistory.bufferdc);
- DeleteObject(localhistory.bufferbm);
-}
-
+}
+
13 years, 7 months
r9488 MarkieB - /branches/MarkieB/windows/windows/localhistory.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 12:46:12 2009
New Revision: 9488
URL: http://source.netsurf-browser.org?rev=9488&view=rev
Log:
more local history scrolling
Modified:
branches/MarkieB/windows/windows/localhistory.c
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Fri Aug 28 12:46:12 2009
@@ -148,9 +148,9 @@
nsws_localhistory_scroll_check(w);
break;
case WM_SIZE:
- nsws_localhistory_scroll_check(w);
localhistory.guiheight = HIWORD(lparam);
localhistory.guiwidth = LOWORD(lparam);
+ nsws_localhistory_scroll_check(w);
break;
case WM_MOVE: {
RECT r, rmain;
@@ -239,8 +239,6 @@
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
HDC hdc = GetDC(hwnd);
- ScrollWindowEx(hwnd, 0, mem - si.nPos, NULL, NULL, NULL,
- NULL, 0);
localhistory.vscroll += si.nPos - mem;
if (localhistory.bufferbm != NULL)
BitBlt(hdc, 0, 0, MIN(localhistory.guiwidth,
@@ -293,8 +291,6 @@
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
HDC hdc = GetDC(hwnd);
- ScrollWindowEx(hwnd, mem - si.nPos, 0, NULL, NULL, NULL,
- NULL, 0);
localhistory.hscroll += si.nPos - mem;
if (localhistory.bufferbm != NULL)
BitBlt(hdc, 0, 0, MIN(localhistory.guiwidth,
@@ -316,8 +312,11 @@
if (bw != NULL)
history_redraw(bw->history);
if (localhistory.bufferbm != NULL)
- BitBlt(ps.hdc, 0, 0, localhistory.guiwidth,
- localhistory.guiheight,
+ BitBlt(ps.hdc, 0, 0, MIN(localhistory.guiwidth,
+ localhistory.width - localhistory.hscroll),
+ MIN(localhistory.guiheight,
+ localhistory.height -
+ localhistory.vscroll),
localhistory.bufferdc,
localhistory.hscroll,
localhistory.vscroll,
@@ -371,24 +370,27 @@
if (w == NULL)
return;
struct browser_window *bw = gui_window_browser_window(w);
- RECT r;
- int width, height;
if ((bw == NULL) || (localhistory.hwnd == NULL))
return;
- history_size(bw->history, &width, &height);
- GetClientRect(localhistory.hwnd, &r);
+ history_size(bw->history, &(localhistory.width), &(localhistory.height));
+
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
si.nMin = 0;
- si.nMax = height;
- si.nPage = r.bottom - r.top;
+ si.nMax = localhistory.height;
+ si.nPage = localhistory.guiheight;
si.nPos = 0;
SetScrollInfo(localhistory.hwnd, SB_VERT, &si, TRUE);
- si.nMax = width;
- si.nPage = r.right - r.left;
+ si.nMax = localhistory.width;
+ si.nPage = localhistory.guiwidth;
SetScrollInfo(localhistory.hwnd, SB_HORZ, &si, TRUE);
+ if (localhistory.guiheight >= localhistory.height)
+ localhistory.vscroll = 0;
+ if (localhistory.guiwidth >= localhistory.width)
+ localhistory.hscroll = 0;
+ SendMessage(localhistory.hwnd, WM_PAINT, 0, 0);
}
void history_gui_set_pointer(gui_pointer_shape shape, void *p)
13 years, 7 months
r9487 MarkieB - /branches/MarkieB/windows/windows/localhistory.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 12:16:29 2009
New Revision: 9487
URL: http://source.netsurf-browser.org?rev=9487&view=rev
Log:
improve local history scrolling behaviour
Modified:
branches/MarkieB/windows/windows/localhistory.c
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Fri Aug 28 12:16:29 2009
@@ -133,7 +133,7 @@
struct gui_window *w = window_list;
struct browser_window *bw = NULL;
struct nsws_localhistory *local;
- while (w) {
+ while (w != NULL) {
local = gui_window_localhistory(w);
if ((local != NULL) && (local->hwnd == hwnd)) {
match = true;
@@ -141,18 +141,14 @@
}
w = gui_window_iterate(w);
}
- if (match == false) /* during initial window creation */
- w = NULL;
- else
+ if (match)
bw = gui_window_browser_window(w);
switch(msg) {
case WM_CREATE:
- if (w != NULL)
- nsws_localhistory_scroll_check(w);
+ nsws_localhistory_scroll_check(w);
break;
case WM_SIZE:
- if (w != NULL)
- nsws_localhistory_scroll_check(w);
+ nsws_localhistory_scroll_check(w);
localhistory.guiheight = HIWORD(lparam);
localhistory.guiwidth = LOWORD(lparam);
break;
@@ -212,17 +208,23 @@
mem = si.nPos;
switch (LOWORD(wparam))
{
- case SB_LINELEFT:
+ case SB_TOP:
+ si.nPos = si.nMin;
+ break;
+ case SB_BOTTOM:
+ si.nPos = si.nMax;
+ break;
+ case SB_LINEUP:
si.nPos -= 30;
break;
- case SB_LINERIGHT:
+ case SB_LINEDOWN:
si.nPos += 30;
break;
- case SB_PAGELEFT:
- si.nPos -= localhistory.guiwidth;
- break;
- case SB_PAGERIGHT:
- si.nPos += localhistory.guiwidth;
+ case SB_PAGEUP:
+ si.nPos -= localhistory.guiheight;
+ break;
+ case SB_PAGEDOWN:
+ si.nPos += localhistory.guiheight;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos;
@@ -239,10 +241,13 @@
HDC hdc = GetDC(hwnd);
ScrollWindowEx(hwnd, 0, mem - si.nPos, NULL, NULL, NULL,
NULL, 0);
- localhistory.hscroll += si.nPos - mem;
+ localhistory.vscroll += si.nPos - mem;
if (localhistory.bufferbm != NULL)
- BitBlt(hdc, 0, 0, localhistory.guiwidth,
- localhistory.guiheight,
+ BitBlt(hdc, 0, 0, MIN(localhistory.guiwidth,
+ localhistory.width - localhistory.hscroll),
+ MIN(localhistory.guiheight,
+ localhistory.height -
+ localhistory.vscroll),
localhistory.bufferdc,
localhistory.hscroll,
localhistory.vscroll,
@@ -259,27 +264,21 @@
int mem;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
- GetScrollInfo(hwnd, SB_VERT, &si);
+ GetScrollInfo(hwnd, SB_HORZ, &si);
mem = si.nPos;
switch (LOWORD(wparam))
{
- case SB_TOP:
- si.nPos = si.nMin;
- break;
- case SB_BOTTOM:
- si.nPos = si.nMax;
- break;
- case SB_LINEUP:
+ case SB_LINELEFT:
si.nPos -= 30;
break;
- case SB_LINEDOWN:
+ case SB_LINERIGHT:
si.nPos += 30;
break;
- case SB_PAGEUP:
- si.nPos -= localhistory.guiheight;
- break;
- case SB_PAGEDOWN:
- si.nPos += localhistory.guiheight;
+ case SB_PAGELEFT:
+ si.nPos -= localhistory.guiwidth;
+ break;
+ case SB_PAGERIGHT:
+ si.nPos += localhistory.guiwidth;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos;
@@ -296,10 +295,13 @@
HDC hdc = GetDC(hwnd);
ScrollWindowEx(hwnd, mem - si.nPos, 0, NULL, NULL, NULL,
NULL, 0);
- localhistory.vscroll += si.nPos - mem;
+ localhistory.hscroll += si.nPos - mem;
if (localhistory.bufferbm != NULL)
- BitBlt(hdc, 0, 0, localhistory.guiwidth,
- localhistory.guiheight,
+ BitBlt(hdc, 0, 0, MIN(localhistory.guiwidth,
+ localhistory.width - localhistory.hscroll),
+ MIN(localhistory.guiheight,
+ localhistory.height -
+ localhistory.vscroll),
localhistory.bufferdc,
localhistory.hscroll,
localhistory.vscroll,
@@ -366,6 +368,8 @@
void nsws_localhistory_scroll_check(struct gui_window *w)
{
+ if (w == NULL)
+ return;
struct browser_window *bw = gui_window_browser_window(w);
RECT r;
int width, height;
13 years, 7 months
r9486 MarkieB - /branches/MarkieB/windows/windows/gui.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 11:34:58 2009
New Revision: 9486
URL: http://source.netsurf-browser.org?rev=9486&view=rev
Log:
more checking structs
Modified:
branches/MarkieB/windows/windows/gui.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Fri Aug 28 11:34:58 2009
@@ -404,18 +404,18 @@
w->requestscrolly = 0;
w->localhistory = NULL;
- switch(bw->browser_window_type) {
- case BROWSER_WINDOW_NORMAL:
- break;
-
- case BROWSER_WINDOW_FRAME:
- LOG(("create frame"));
- break;
-
- default:
- LOG(("unhandled type"));
-
- }
+ if (bw != NULL)
+ switch(bw->browser_window_type) {
+ case BROWSER_WINDOW_NORMAL:
+ break;
+
+ case BROWSER_WINDOW_FRAME:
+ LOG(("create frame"));
+ break;
+
+ default:
+ LOG(("unhandled type"));
+ }
if (window_list != NULL)
window_list->prev = w;
@@ -456,7 +456,7 @@
{
bool match = false;
struct gui_window *w = window_list;
- while (w) {
+ while (w != NULL) {
if (w->toolbar == hwnd) {
match = true;
break;
@@ -465,7 +465,7 @@
}
if (match == false) { /* during initial window creation */
w = window_list;
- while (w) {
+ while (w != NULL) {
if (w->toolbar == NULL) {
w->toolbar = hwnd;
break;
@@ -479,8 +479,8 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if ((x > w->ntoolbuttons * w->toolbuttondimension) &&
- (y < w->voffset)) {
+ if ((w != NULL) && (x > w->ntoolbuttons * w->toolbuttondimension)
+ && (y < w->voffset)) {
if (msg == WM_LBUTTONDOWN)
SetFocus(w->urlbar);
return CallWindowProc((WNDPROC)
@@ -502,7 +502,7 @@
bool match = false;
bool historyactive = false;
struct gui_window *w = window_list;
- while (w) {
+ while (w != NULL) {
if (w->main == hwnd) {
match = true;
break;
@@ -511,7 +511,7 @@
}
if (!match) { /* during initial window creation */
w = window_list;
- while (w) {
+ while (w != NULL) {
if (w->main == NULL) {
w->main = hwnd;
break;
@@ -595,14 +595,15 @@
/* shift down */ && ((GetKeyState(VK_SHIFT) & 0x8000)
== 0x8000))))
i += 'a' - 'A';
- browser_window_key_press(w->bw, i);
+ if (w != NULL)
+ browser_window_key_press(w->bw, i);
break;
}
case WM_MOUSEMOVE: {
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (y > w->voffset)
+ if ((w != NULL) && (w->bw != NULL) && (y > w->voffset))
browser_window_mouse_track(w->bw, 0,
(x + w->scrollx) / w->bw->scale ,
(y - w->voffset + w->scrolly) /
@@ -614,7 +615,7 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (y > w->voffset) {
+ if ((w != NULL) && (w->bw != NULL) && (y > w->voffset)) {
SetFocus(hwnd);
browser_window_mouse_click(w->bw,
BROWSER_MOUSE_PRESS_1,
@@ -630,7 +631,7 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (y > w->voffset) {
+ if ((w != NULL) && (w->bw != NULL) && (y > w->voffset)) {
SetFocus(hwnd);
browser_window_mouse_click(w->bw,
BROWSER_MOUSE_PRESS_2,
@@ -645,7 +646,7 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (y > w->voffset)
+ if ((w != NULL) && (w->bw != NULL) && (y > w->voffset))
browser_window_mouse_click(w->bw,
BROWSER_MOUSE_CLICK_1,
(x + w->scrollx) / w->bw->scale,
@@ -658,7 +659,7 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (y > w->voffset)
+ if ((w != NULL) && (w->bw != NULL) && (y > w->voffset))
browser_window_mouse_click(w->bw,
BROWSER_MOUSE_CLICK_2,
(x + w->scrollx)/ w->bw->scale ,
@@ -671,7 +672,7 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (y > w->voffset)
+ if ((w != NULL) && (w->bw != NULL) && (y > w->voffset))
browser_window_mouse_click(w->bw,
BROWSER_MOUSE_DOUBLE_CLICK,
(x + w->scrollx) / w->bw->scale,
@@ -692,7 +693,7 @@
switch(LOWORD(wparam)) {
case NSWS_ID_FILE_QUIT:
w = window_list;
- while (w) {
+ while (w != NULL) {
PostMessage(w->main, WM_CLOSE, 0, 0);
w = w->next;
}
@@ -736,13 +737,15 @@
nsws_prefs_dialog_init(w->main);
break;
case NSWS_ID_NAV_BACK:
- if (history_back_available(w->bw->history)) {
+ if ((w->bw != NULL) && (history_back_available(
+ w->bw->history))) {
history_back(w->bw, w->bw->history);
}
nsws_window_update_forward_back(w);
break;
case NSWS_ID_NAV_FORWARD:
- if (history_forward_available(w->bw->history)) {
+ if ((w->bw != NULL) && (history_forward_available(
+ w->bw->history))) {
history_forward(w->bw, w->bw->history);
}
nsws_window_update_forward_back(w);
@@ -754,10 +757,8 @@
browser_window_stop(w->bw);
break;
case NSWS_ID_NAV_RELOAD:
- {
browser_window_reload(w->bw, true);
break;
- }
case NSWS_ID_NAV_LOCALHISTORY:
nsws_localhistory_init(w);
break;
@@ -766,7 +767,7 @@
case NSWS_ID_VIEW_ZOOMPLUS: {
int x, y;
gui_window_get_scroll(w, &x, &y);
- if (w->bw) {
+ if (w->bw != NULL) {
browser_window_set_scale(w->bw,
w->bw->scale * 1.1, true);
browser_window_reformat(w->bw, w->width,
@@ -779,7 +780,7 @@
case NSWS_ID_VIEW_ZOOMMINUS: {
int x, y;
gui_window_get_scroll(w, &x, &y);
- if (w->bw) {
+ if (w->bw != NULL) {
browser_window_set_scale(w->bw,
w->bw->scale * 0.9, true);
browser_window_reformat(w->bw, w->width,
@@ -792,7 +793,7 @@
case NSWS_ID_VIEW_ZOOMNORMAL: {
int x, y;
gui_window_get_scroll(w, &x, &y);
- if (w->bw) {
+ if (w->bw != NULL) {
browser_window_set_scale(w->bw,
1.0, true);
browser_window_reformat(w->bw, w->width,
@@ -856,7 +857,7 @@
break;
case NSWS_ID_VIEW_TOGGLE_DEBUG_RENDERING:
html_redraw_debug = !html_redraw_debug;
- if (w->bw) {
+ if (w->bw != NULL) {
browser_window_reformat(
w->bw, w->width, w->height);
redraw();
@@ -925,9 +926,10 @@
break;
}
si.fMask = SIF_POS;
- si.nPos = MIN(si.nPos,
- w->bw->current_content->width * w->bw->scale
- - w->width);
+ if ((w->bw != NULL) && (w->bw->current_content != NULL))
+ si.nPos = MIN(si.nPos,
+ w->bw->current_content->width *
+ w->bw->scale - w->width);
si.nPos = MAX(si.nPos, 0);
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
GetScrollInfo(hwnd, SB_HORZ, &si);
@@ -971,9 +973,10 @@
break;
}
si.fMask = SIF_POS;
- si.nPos = MIN(si.nPos,
- w->bw->current_content->height * w->bw->scale
- - w->height);
+ if ((w->bw != NULL) && (w->bw->current_content != NULL))
+ si.nPos = MIN(si.nPos,
+ w->bw->current_content->height *
+ w->bw->scale - w->height);
si.nPos = MAX(si.nPos, 0);
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
GetScrollInfo(hwnd, SB_VERT, &si);
@@ -1021,8 +1024,9 @@
}
case WM_PAINT:
{
- if (!(w->toolbar) || !(w->urlbar) || !(w->statusbar) ||
- !(w->vscroll) || !(w->hscroll))
+ if ((w->toolbar == NULL) || (w->urlbar == NULL) ||
+ (w->statusbar == NULL) || (w->vscroll == NULL)
+ || (w->hscroll == NULL))
break;
HWND focuswnd = GetFocus();
SetFocus(w->urlbar);
@@ -1078,7 +1082,8 @@
break;
case WM_SIZE:
{
- if (!(w->toolbar) || !(w->urlbar) || !(w->statusbar))
+ if ((w->toolbar == NULL) || (w->urlbar == NULL) ||
+ (w->statusbar == NULL))
break;
int x, y;
RECT rmain, rstatus, rtool;
@@ -1103,7 +1108,7 @@
w->urlbarwidth = w->width - w->ntoolbuttons *
w->toolbuttondimension - 8 -
NSWS_THROBBER_WIDTH;
- if (w->bw) {
+ if (w->bw != NULL) {
browser_window_reformat(
w->bw, w->width, w->height);
redraw();
@@ -1153,6 +1158,8 @@
*/
void nsws_window_create(struct gui_window *gw)
{
+ if (gw == NULL)
+ return;
LOG(("nsws_window_create %p", gw));
const char windowclassname[] = "nsws_window";
WNDCLASSEX w;
@@ -1580,42 +1587,57 @@
HWND gui_window_main_window(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return w->main;
}
HWND gui_window_toolbar(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return w->toolbar;
}
HWND gui_window_urlbar(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return w->urlbar;
}
HWND gui_window_statusbar(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return w->statusbar;
}
HWND gui_window_drawingarea(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return w->drawingarea;
}
struct nsws_localhistory *gui_window_localhistory(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return w->localhistory;
}
void gui_window_set_localhistory(struct gui_window *w,
struct nsws_localhistory *l)
{
- w->localhistory = l;
+ if (w != NULL)
+ w->localhistory = l;
}
RECT *gui_window_redraw_rect(struct gui_window *w)
{
+ if (w == NULL)
+ return NULL;
return &(w->redraw);
}
@@ -1680,17 +1702,20 @@
*/
void gui_window_destroy(struct gui_window *w)
{
- if (w->prev)
+ if (w == NULL)
+ return;
+ if (w->prev != NULL)
w->prev->next = w->next;
else
window_list = w->next;
- if (w->next)
+ if (w->next != NULL)
w->next->prev = w->prev;
DestroyAcceleratorTable(w->acceltable);
free(w);
+ w = NULL;
}
/**
@@ -1699,6 +1724,8 @@
*/
void gui_window_set_title(struct gui_window *w, const char *title)
{
+ if (w == NULL)
+ return;
LOG(("%p, title %s", w, title));
char *fulltitle = malloc(strlen(title) +
SLEN(" - NetSurf") + 1);
@@ -1718,6 +1745,8 @@
void gui_window_redraw(struct gui_window *w, int x0, int y0, int x1, int y1)
{
LOG(("redraw %p %d,%d %d,%d", w, x0, y0, x1, y1));
+ if (w == NULL)
+ return;
w->redraw.left = x0;
w->redraw.top = y0;
w->redraw.right = x1;
@@ -1731,6 +1760,8 @@
void gui_window_redraw_window(struct gui_window *w)
{
LOG(("redraw window %p w=%d,h=%d", w, w->width, w->height));
+ if (w == NULL)
+ return;
w->redraw.left = 0;
w->redraw.top = 0;
w->redraw.right = w->width;
@@ -1744,6 +1775,8 @@
LOG(("redraw %p from %.1f,%.1f w=%.1f,h=%.1f", w, data->redraw.x,
data->redraw.y, data->redraw.width,
data->redraw.height));
+ if (w == NULL)
+ return;
w->redraw.left = data->redraw.x;
w->redraw.top = data->redraw.y;
w->redraw.right = data->redraw.x + data->redraw.width;
@@ -1754,6 +1787,8 @@
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
{
LOG(("get scroll"));
+ if (w == NULL)
+ return false;
*sx = w->scrollx;
*sy = w->scrolly;
@@ -1767,11 +1802,10 @@
*/
void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
+ if ((w == NULL) || (w->bw == NULL) || (w->bw->current_content == NULL))
+ return;
w->requestscrollx = sx - w->scrollx;
w->requestscrolly = sy - w->scrolly;
-
- if (w->bw->current_content == NULL)
- return;
SCROLLINFO si;
si.cbSize = sizeof(si);
@@ -1827,6 +1861,8 @@
bool scaled)
{
LOG(("get dimensions %p w=%d h=%d", w, w->width, w->height));
+ if (w == NULL)
+ return;
*width = w->width;
*height = w->height;
}
@@ -1841,6 +1877,8 @@
*/
void gui_window_set_status(struct gui_window *w, const char *text)
{
+ if (w == NULL)
+ return;
SendMessage(w->statusbar, WM_SETTEXT, 0, (LPARAM)text);
}
@@ -1849,6 +1887,8 @@
*/
void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
{
+ if (w == NULL)
+ return;
switch (shape) {
case GUI_POINTER_POINT: /* link */
case GUI_POINTER_MENU:
@@ -1921,12 +1961,16 @@
void gui_window_set_url(struct gui_window *w, const char *url)
{
+ if (w == NULL)
+ return;
SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) url);
}
void gui_window_start_throbber(struct gui_window *w)
{
+ if (w == NULL)
+ return;
nsws_window_update_forward_back(w);
if (w->mainmenu != NULL) {
@@ -1946,6 +1990,8 @@
void gui_window_stop_throbber(struct gui_window *w)
{
+ if (w == NULL)
+ return;
nsws_window_update_forward_back(w);
if (w->mainmenu != NULL) {
EnableMenuItem(w->mainmenu, NSWS_ID_NAV_STOP, MF_GRAYED);
@@ -1968,6 +2014,8 @@
*/
void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
{
+ if (w == NULL)
+ return;
CreateCaret(w->main, (HBITMAP)NULL, 1, height * w->bw->scale);
SetCaretPos(x * w->bw->scale - w->scrollx,
y * w->bw->scale + w->voffset - w->scrolly);
@@ -1979,6 +2027,8 @@
*/
void gui_window_remove_caret(struct gui_window *w)
{
+ if (w == NULL)
+ return;
HideCaret(w->main);
}
@@ -2009,6 +2059,8 @@
void gui_window_set_scale(struct gui_window *w, float scale)
{
+ if (w == NULL)
+ return;
w->scale = scale;
LOG(("%.2f\n", scale));
}
13 years, 7 months
r9485 MarkieB - in /branches/MarkieB/windows/windows: gui.c localhistory.c plot.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 11:05:48 2009
New Revision: 9485
URL: http://source.netsurf-browser.org?rev=9485&view=rev
Log:
protect structs
Modified:
branches/MarkieB/windows/windows/gui.c
branches/MarkieB/windows/windows/localhistory.c
branches/MarkieB/windows/windows/plot.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Fri Aug 28 11:05:48 2009
@@ -325,7 +325,8 @@
doublebuffering = true;
hdc = GetDC(w->main);
- if ((w->bufferbm == NULL) || (w->bufferdc == NULL))
+ if ((w->bufferbm == NULL) || (w->bufferdc == NULL) ||
+ (hdc == NULL))
doublebuffering = false;
if (doublebuffering)
bufferdc = w->bufferdc;
@@ -401,6 +402,7 @@
- 8 - NSWS_THROBBER_WIDTH;
w->requestscrollx = 0;
w->requestscrolly = 0;
+ w->localhistory = NULL;
switch(bw->browser_window_type) {
case BROWSER_WINDOW_NORMAL:
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Fri Aug 28 11:05:48 2009
@@ -73,7 +73,7 @@
current_gui = NULL;
current_hwnd = NULL;
doublebuffering = false;
- if (bw->history != NULL)
+ if ((bw != NULL) && (bw->history != NULL))
history_size(bw->history, &(localhistory.width),
&(localhistory.height));
@@ -184,7 +184,7 @@
break;
current_hwnd = gui_window_main_window(w);
current_gui = w;
- if (history_click(bw, bw->history, x, y, false))
+ if ((bw != NULL) && (history_click(bw, bw->history, x, y, false)))
DestroyWindow(hwnd);
else {
current_hwnd = hwnd;
@@ -236,9 +236,18 @@
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
+ HDC hdc = GetDC(hwnd);
ScrollWindowEx(hwnd, 0, mem - si.nPos, NULL, NULL, NULL,
NULL, 0);
- history_redraw(bw->history);
+ localhistory.hscroll += si.nPos - mem;
+ if (localhistory.bufferbm != NULL)
+ BitBlt(hdc, 0, 0, localhistory.guiwidth,
+ localhistory.guiheight,
+ localhistory.bufferdc,
+ localhistory.hscroll,
+ localhistory.vscroll,
+ SRCCOPY);
+ ReleaseDC(hwnd, hdc);
}
break;
}
@@ -284,9 +293,18 @@
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
+ HDC hdc = GetDC(hwnd);
ScrollWindowEx(hwnd, mem - si.nPos, 0, NULL, NULL, NULL,
NULL, 0);
- history_redraw(bw->history);
+ localhistory.vscroll += si.nPos - mem;
+ if (localhistory.bufferbm != NULL)
+ BitBlt(hdc, 0, 0, localhistory.guiwidth,
+ localhistory.guiheight,
+ localhistory.bufferdc,
+ localhistory.hscroll,
+ localhistory.vscroll,
+ SRCCOPY);
+ ReleaseDC(hwnd, hdc);
}
break;
}
@@ -295,9 +313,14 @@
BeginPaint(hwnd, &ps);
if (bw != NULL)
history_redraw(bw->history);
-/*
- BitBlt();
-*/ EndPaint(hwnd, &ps);
+ if (localhistory.bufferbm != NULL)
+ BitBlt(ps.hdc, 0, 0, localhistory.guiwidth,
+ localhistory.guiheight,
+ localhistory.bufferdc,
+ localhistory.hscroll,
+ localhistory.vscroll,
+ SRCCOPY);
+ EndPaint(hwnd, &ps);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
}
@@ -320,6 +343,9 @@
LOG(("gui window %p", w));
HDC hdc;
struct browser_window *bw = gui_window_browser_window(w);
+
+ localhistory.vscroll = 0;
+ localhistory.hscroll = 0;
hdc = GetDC(localhistory.hwnd);
localhistory.bufferdc = CreateCompatibleDC(hdc);
@@ -364,6 +390,8 @@
void history_gui_set_pointer(gui_pointer_shape shape, void *p)
{
struct nsws_pointers *pointers = nsws_get_pointers();
+ if (pointers == NULL)
+ return;
switch(shape) {
case GUI_POINTER_POINT:
SetCursor(pointers->hand);
@@ -376,7 +404,9 @@
void nsws_localhistory_close(struct gui_window *w)
{
- DestroyWindow(gui_window_localhistory(w)->hwnd);
+ struct nsws_localhistory *l = gui_window_localhistory(w);
+ if (l != NULL)
+ DestroyWindow(l->hwnd);
}
void nsws_localhistory_clear(struct gui_window *w)
Modified: branches/MarkieB/windows/windows/plot.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/plot.c...
==============================================================================
--- branches/MarkieB/windows/windows/plot.c (original)
+++ branches/MarkieB/windows/windows/plot.c Fri Aug 28 11:05:48 2009
@@ -295,7 +295,7 @@
SetPolyFillMode(hdc, WINDING);
for (i = 0; i < n; i++) {
points[i].x = (long) p[2 * i];
- points[i].y = (long) (p[2 * i + 1]
+ points[i].y = (long) (p[2 * i + 1]
+ (thumbnail ? 0 :
gui_window_voffset(current_gui)));
13 years, 7 months
r9484 MarkieB - in /branches/MarkieB/windows/windows: gui.c gui.h localhistory.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 10:36:53 2009
New Revision: 9484
URL: http://source.netsurf-browser.org?rev=9484&view=rev
Log:
local history double buffering / improve scrolling
Modified:
branches/MarkieB/windows/windows/gui.c
branches/MarkieB/windows/windows/gui.h
branches/MarkieB/windows/windows/localhistory.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Fri Aug 28 10:36:53 2009
@@ -87,10 +87,11 @@
HWND statusbar; /**< status bar handle */
HWND vscroll; /**< vertical scrollbar handle */
HWND hscroll; /**< horizontal scrollbar handle */
- HWND localhistory; /**< handle to local history window */
HMENU mainmenu; /**< the main menu */
HDC bufferdc; /**< the screen buffer */
HBITMAP bufferbm; /**< the buffer bitmap */
+ struct nsws_localhistory *localhistory;
+ /**< handle to local history window */
int width; /**< width of window */
int height; /**< height of drawing area */
int urlbarwidth; /**< width of url bar */
@@ -1600,14 +1601,15 @@
return w->drawingarea;
}
-HWND gui_window_localhistory(struct gui_window *w)
+struct nsws_localhistory *gui_window_localhistory(struct gui_window *w)
{
return w->localhistory;
}
-void gui_window_set_localhistory(struct gui_window *w, HWND localhistory)
-{
- w->localhistory = localhistory;
+void gui_window_set_localhistory(struct gui_window *w,
+ struct nsws_localhistory *l)
+{
+ w->localhistory = l;
}
RECT *gui_window_redraw_rect(struct gui_window *w)
Modified: branches/MarkieB/windows/windows/gui.h
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.h?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.h (original)
+++ branches/MarkieB/windows/windows/gui.h Fri Aug 28 10:36:53 2009
@@ -22,6 +22,7 @@
#include <windows.h>
#include "desktop/gui.h"
+#include "windows/localhistory.h"
/* bounding box */
typedef struct bbox_s {
@@ -55,8 +56,9 @@
HWND gui_window_urlbar(struct gui_window *);
HWND gui_window_statusbar(struct gui_window *);
HWND gui_window_drawingarea(struct gui_window *);
-HWND gui_window_localhistory(struct gui_window *);
-void gui_window_set_localhistory(struct gui_window *, HWND);
+struct nsws_localhistory *gui_window_localhistory(struct gui_window *);
+void gui_window_set_localhistory(struct gui_window *,
+ struct nsws_localhistory *);
RECT *gui_window_redraw_rect(struct gui_window *);
RECT *gui_window_clip_rect(struct gui_window *w);
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Fri Aug 28 10:36:53 2009
@@ -59,16 +59,32 @@
void nsws_localhistory_init(struct gui_window *w)
{
- LOG(("%p", w));
- const char localhistorywindowclassname[] = "nsws_localhistory_window";
+ LOG(("gui window %p", w));
+ static const char localhistorywindowclassname[] = "nsws_localhistory_window";
WNDCLASSEX we;
- HWND hwnd;
+ HWND hwnd, mainhwnd = gui_window_main_window(w);
INITCOMMONCONTROLSEX icc;
HICON hIcon = nsws_window_get_ico(true);
HICON hIconS = nsws_window_get_ico(false);
+ struct browser_window *bw = gui_window_browser_window(w);
+ int margin = 50;
+ RECT r;
+
current_gui = NULL;
current_hwnd = NULL;
doublebuffering = false;
+ if (bw->history != NULL)
+ history_size(bw->history, &(localhistory.width),
+ &(localhistory.height));
+
+ GetWindowRect(mainhwnd, &r);
+ SetWindowPos(mainhwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+
+ localhistory.guiwidth = MIN(r.right - r.left - margin,
+ localhistory.width + margin);
+ localhistory.guiheight = MIN(r.bottom - r.top - margin,
+ localhistory.height + margin);
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
@@ -93,15 +109,20 @@
LoadIcon(NULL, IDI_APPLICATION) : hIconS;
RegisterClassEx(&we);
LOG(("creating local history window for hInstance %p", hinstance));
- current_hwnd = CreateWindow(localhistorywindowclassname, "NetSurf History",
- WS_THICKFRAME | WS_HSCROLL | WS_VSCROLL |
- WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CS_DBLCLKS,
- CW_USEDEFAULT, CW_USEDEFAULT, 300,
- 400, NULL, NULL, hinstance, NULL);
- hwnd = current_hwnd;
+ hwnd = CreateWindow(localhistorywindowclassname,
+ "NetSurf History", WS_OVERLAPPEDWINDOW /*WS_THICKFRAME | WS_HSCROLL |
+ WS_VSCROLL | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
+ CS_DBLCLKS */ , r.left + margin/2, r.top + margin/2,
+ localhistory.guiwidth, localhistory.guiheight, NULL,
+ NULL, hinstance, NULL);
+ LOG(("gui_window %p width %d height %d hwnd %p", w,
+ localhistory.guiwidth, localhistory.guiheight,
+ localhistory.hwnd));
+ current_hwnd = hwnd;
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
- gui_window_set_localhistory(w, hwnd);
+ localhistory.hwnd = hwnd;
+ gui_window_set_localhistory(w, &localhistory);
nsws_localhistory_up(w);
}
@@ -111,8 +132,10 @@
bool match = false;
struct gui_window *w = window_list;
struct browser_window *bw = NULL;
+ struct nsws_localhistory *local;
while (w) {
- if (gui_window_localhistory(w) == hwnd) {
+ local = gui_window_localhistory(w);
+ if ((local != NULL) && (local->hwnd == hwnd)) {
match = true;
break;
}
@@ -130,6 +153,8 @@
case WM_SIZE:
if (w != NULL)
nsws_localhistory_scroll_check(w);
+ localhistory.guiheight = HIWORD(lparam);
+ localhistory.guiwidth = LOWORD(lparam);
break;
case WM_MOVE: {
RECT r, rmain;
@@ -155,15 +180,15 @@
int x,y;
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (bw != NULL) {
- current_hwnd = gui_window_main_window(w);
- current_gui = w;
- if (history_click(bw, bw->history, x, y, false))
- DestroyWindow(hwnd);
- else {
- current_hwnd = hwnd;
- current_gui = NULL;
- }
+ if (bw == NULL)
+ break;
+ current_hwnd = gui_window_main_window(w);
+ current_gui = w;
+ if (history_click(bw, bw->history, x, y, false))
+ DestroyWindow(hwnd);
+ else {
+ current_hwnd = hwnd;
+ current_gui = NULL;
}
}
case WM_MOUSEMOVE: {
@@ -174,13 +199,105 @@
history_hover(bw->history, x, y, (void *)hwnd);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
+ }
+ case WM_VSCROLL:
+ {
+ if ((w == NULL) || (bw == NULL))
+ break;
+ SCROLLINFO si;
+ int mem;
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_VERT, &si);
+ mem = si.nPos;
+ switch (LOWORD(wparam))
+ {
+ case SB_LINELEFT:
+ si.nPos -= 30;
+ break;
+ case SB_LINERIGHT:
+ si.nPos += 30;
+ break;
+ case SB_PAGELEFT:
+ si.nPos -= localhistory.guiwidth;
+ break;
+ case SB_PAGERIGHT:
+ si.nPos += localhistory.guiwidth;
+ break;
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+ default:
+ break;
+ }
+ si.nPos = MIN(si.nPos, localhistory.width);
+ si.nPos = MAX(si.nPos, 0);
+ si.fMask = SIF_POS;
+ SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ GetScrollInfo(hwnd, SB_VERT, &si);
+ if (si.nPos != mem) {
+ ScrollWindowEx(hwnd, 0, mem - si.nPos, NULL, NULL, NULL,
+ NULL, 0);
+ history_redraw(bw->history);
+ }
+ break;
+ }
+ case WM_HSCROLL:
+ {
+ if ((w == NULL) || (bw == NULL))
+ break;
+ SCROLLINFO si;
+ int mem;
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_VERT, &si);
+ mem = si.nPos;
+ switch (LOWORD(wparam))
+ {
+ case SB_TOP:
+ si.nPos = si.nMin;
+ break;
+ case SB_BOTTOM:
+ si.nPos = si.nMax;
+ break;
+ case SB_LINEUP:
+ si.nPos -= 30;
+ break;
+ case SB_LINEDOWN:
+ si.nPos += 30;
+ break;
+ case SB_PAGEUP:
+ si.nPos -= localhistory.guiheight;
+ break;
+ case SB_PAGEDOWN:
+ si.nPos += localhistory.guiheight;
+ break;
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+ default:
+ break;
+ }
+ si.nPos = MIN(si.nPos, localhistory.height);
+ si.nPos = MAX(si.nPos, 0);
+ si.fMask = SIF_POS;
+ SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+ if (si.nPos != mem) {
+ ScrollWindowEx(hwnd, mem - si.nPos, 0, NULL, NULL, NULL,
+ NULL, 0);
+ history_redraw(bw->history);
+ }
+ break;
}
case WM_PAINT: {
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
if (bw != NULL)
history_redraw(bw->history);
- EndPaint(hwnd, &ps);
+/*
+ BitBlt();
+*/ EndPaint(hwnd, &ps);
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
}
@@ -200,41 +317,36 @@
void nsws_localhistory_up(struct gui_window *w)
{
- HWND hwnd = gui_window_localhistory(w);
- HWND mainhwnd = gui_window_main_window(w);
+ LOG(("gui window %p", w));
+ HDC hdc;
+ struct browser_window *bw = gui_window_browser_window(w);
+
+ hdc = GetDC(localhistory.hwnd);
+ localhistory.bufferdc = CreateCompatibleDC(hdc);
+ localhistory.bufferbm = CreateCompatibleBitmap(hdc, localhistory.width,
+ localhistory.height);
+ SelectObject(localhistory.bufferdc, localhistory.bufferbm);
+
+ doublebuffering = true;
+ bufferdc = localhistory.bufferdc;
+ if (bw != NULL)
+ history_redraw(bw->history);
+ doublebuffering = false;
+ BitBlt(hdc, 0, 0, localhistory.guiwidth, localhistory.guiheight,
+ localhistory.bufferdc, 0, 0, SRCCOPY);
+
+ ReleaseDC(localhistory.hwnd, hdc);
+}
+
+void nsws_localhistory_scroll_check(struct gui_window *w)
+{
struct browser_window *bw = gui_window_browser_window(w);
RECT r;
- int width = 400, height = 300, margin = 50;
- if ((hwnd == NULL) || (mainhwnd == NULL) || (bw == NULL))
- return;
- if (bw->history != NULL)
- history_size(bw->history, &width, &height);
-
- GetWindowRect(mainhwnd, &r);
-
- width = MIN(r.right - r.left - margin, width + margin);
- height = MIN(r.bottom - r.top - margin, height + margin);
- LOG(("gui_window %p width %d height %d hwnd %p", w, width, height,
- hwnd));
- SetWindowPos(mainhwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
- SetWindowPos(hwnd, HWND_TOPMOST, r.left + margin/2, r.top + margin/2,
- width, height, SWP_SHOWWINDOW);
-
- history_redraw(bw->history);
-
-}
-
-void nsws_localhistory_scroll_check(struct gui_window *w)
-{
- struct browser_window *bw = gui_window_browser_window(w);
- HWND hwnd = gui_window_localhistory(w);
- RECT r;
int width, height;
- if (bw == NULL)
+ if ((bw == NULL) || (localhistory.hwnd == NULL))
return;
history_size(bw->history, &width, &height);
- GetClientRect(hwnd, &r);
+ GetClientRect(localhistory.hwnd, &r);
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
@@ -242,11 +354,11 @@
si.nMax = height;
si.nPage = r.bottom - r.top;
si.nPos = 0;
- SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ SetScrollInfo(localhistory.hwnd, SB_VERT, &si, TRUE);
si.nMax = width;
si.nPage = r.right - r.left;
- SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
+ SetScrollInfo(localhistory.hwnd, SB_HORZ, &si, TRUE);
}
void history_gui_set_pointer(gui_pointer_shape shape, void *p)
@@ -264,15 +376,14 @@
void nsws_localhistory_close(struct gui_window *w)
{
- DestroyWindow(gui_window_localhistory(w));
+ DestroyWindow(gui_window_localhistory(w)->hwnd);
}
void nsws_localhistory_clear(struct gui_window *w)
{
if (w != NULL)
gui_window_set_localhistory(w, NULL);
-/* DeleteDC(localhistory.bufferdc);
+ DeleteDC(localhistory.bufferdc);
DeleteObject(localhistory.bufferbm);
-*/
-}
-
+}
+
13 years, 7 months
r9483 MarkieB - in /branches/MarkieB/windows/windows: gui.c localhistory.c localhistory.h
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Aug 28 09:50:35 2009
New Revision: 9483
URL: http://source.netsurf-browser.org?rev=9483&view=rev
Log:
code tidying; +1s; preparation for more advanced local history scroll handling
Modified:
branches/MarkieB/windows/windows/gui.c
branches/MarkieB/windows/windows/localhistory.c
branches/MarkieB/windows/windows/localhistory.h
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Fri Aug 28 09:50:35 2009
@@ -98,7 +98,7 @@
int toolbuttondimension; /**< width, height of buttons */
int voffset; /**< height of toolbar */
bool throbbing; /**< whether currently throbbing */
- TBBUTTON buttons[NTOOLBUTTONS + 1]; /* url bar, throbber */
+ TBBUTTON buttons[NTOOLBUTTONS + 1]; /* 1 = url bar */
HBITMAP hbmp[NTOOLBUTTONS]; /**< tool button images */
HACCEL acceltable; /**< accelerators */
@@ -1499,16 +1499,11 @@
*/
void nsws_window_throbber_create(struct gui_window *w)
{
- HWND hwnd = Animate_Create(w->main, NSWS_ID_THROBBER,
- WS_CHILD | WS_VISIBLE, hinstance);
- SetWindowPos(hwnd, HWND_TOPMOST, w->width - NSWS_THROBBER_WIDTH - 4, 8,
- NSWS_THROBBER_WIDTH, NSWS_THROBBER_WIDTH,
- SWP_SHOWWINDOW);
-
- /* CreateWindow(ANIMATE_CLASS, "", WS_CHILD | WS_VISIBLE |
- ACS_AUTOPLAY, w->width - NSWS_THROBBER_WIDTH, 4,
+ HWND hwnd =
+ CreateWindow(ANIMATE_CLASS, "", WS_CHILD | WS_VISIBLE,
+ w->width - NSWS_THROBBER_WIDTH - 4, 8,
NSWS_THROBBER_WIDTH, NSWS_THROBBER_WIDTH, w->main,
- (HMENU) NSWS_ID_THROBBER, hinstance, NULL); */
+ (HMENU) NSWS_ID_THROBBER, hinstance, NULL);
char avi[PATH_MAX];
nsws_find_resource(avi, "throbber.avi", "windows/res/throbber.avi");
LOG(("setting throbber avi as %s", avi));
@@ -1800,13 +1795,13 @@
HideCaret(w->main);
SetCaretPos(p.x - w->requestscrollx, p.y - w->requestscrolly);
ShowCaret(w->main);
- RECT r, redraw;
- r.top = w->voffset;
- r.bottom = w->voffset + w->height;
+ RECT r;
+ r.top = w->voffset - 1;
+ r.bottom = w->voffset + w->height + 1;
r.left = 0;
- r.right = w->width;
+ r.right = w->width + 1;
ScrollWindowEx(w->main, - w->requestscrollx, - w->requestscrolly, &r,
- NULL, NULL, &redraw, SW_INVALIDATE);
+ NULL, NULL, NULL, SW_INVALIDATE);
}
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0,
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Fri Aug 28 09:50:35 2009
@@ -38,9 +38,24 @@
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
+struct nsws_localhistory {
+ HWND hwnd; /**< the window handle */
+ HDC bufferdc; /**< the buffer dc */
+ HBITMAP bufferbm; /**< the buffer bitmap */
+ int width; /**< the width of the memory history */
+ int height; /**< the height of the memory history */
+ int guiwidth; /**< the width of the history window */
+ int guiheight; /**< the height of the history window */
+ int vscroll; /**< the vertical scroll location */
+ int hscroll; /**< the horizontal scroll location */
+};
+
+static struct nsws_localhistory localhistory;
+
LRESULT CALLBACK nsws_localhistory_event_callback(HWND hwnd, UINT msg,
WPARAM wparam, LPARAM lparam);
-void nsws_localhistory_scroll_check(struct gui_window *w);
+static void nsws_localhistory_scroll_check(struct gui_window *w);
+static void nsws_localhistory_clear(struct gui_window *w);
void nsws_localhistory_init(struct gui_window *w)
{
@@ -57,9 +72,9 @@
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
- #if WINVER > 0x0501
+#if WINVER > 0x0501
icc.dwICC |= ICC_STANDARD_CLASSES;
- #endif
+#endif
InitCommonControlsEx(&icc);
we.cbSize = sizeof(WNDCLASSEX);
@@ -170,9 +185,11 @@
break;
}
case WM_CLOSE:
+ nsws_localhistory_clear(w);
DestroyWindow(hwnd);
break;
case WM_DESTROY:
+ nsws_localhistory_clear(w);
PostQuitMessage(0);
break;
default:
@@ -248,4 +265,14 @@
void nsws_localhistory_close(struct gui_window *w)
{
DestroyWindow(gui_window_localhistory(w));
-}
+}
+
+void nsws_localhistory_clear(struct gui_window *w)
+{
+ if (w != NULL)
+ gui_window_set_localhistory(w, NULL);
+/* DeleteDC(localhistory.bufferdc);
+ DeleteObject(localhistory.bufferbm);
+*/
+}
+
Modified: branches/MarkieB/windows/windows/localhistory.h
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.h (original)
+++ branches/MarkieB/windows/windows/localhistory.h Fri Aug 28 09:50:35 2009
@@ -16,8 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef _NETSURF_WINDOWS_LOCALHISTORY_H_
+#define _NETSURF_WINDOWS_LOCALHISTORY_H_
+
#include "desktop/browser.h"
+
+struct nsws_localhistory;
void nsws_localhistory_init(struct gui_window *);
void nsws_localhistory_up(struct gui_window *);
void nsws_localhistory_close(struct gui_window *);
+
+#endif
13 years, 7 months
r9482 jmb - in /trunk/tools/heapview/utils: ./ hist.pl
by netsurf@semichrome.net
Author: jmb
Date: Fri Aug 28 06:36:14 2009
New Revision: 9482
URL: http://source.netsurf-browser.org?rev=9482&view=rev
Log:
Hacky perl script that counts allocation size frequency.
Added:
trunk/tools/heapview/utils/
trunk/tools/heapview/utils/hist.pl (with props)
Added: trunk/tools/heapview/utils/hist.pl
URL: http://source.netsurf-browser.org/trunk/tools/heapview/utils/hist.pl?rev=...
==============================================================================
--- trunk/tools/heapview/utils/hist.pl (added)
+++ trunk/tools/heapview/utils/hist.pl Fri Aug 28 06:36:14 2009
@@ -1,0 +1,73 @@
+#!/usr/bin/env perl
+#
+# Example input:
+#
+# MEM mprintf.c:1094 malloc(32) = e5718
+# MEM mprintf.c:1103 realloc(e5718, 64) = e6118
+# MEM sendf.c:232 free(f6520)
+
+use warnings;
+use strict;
+
+my %sizemap;
+
+my $file = $ARGV[0];
+
+if(! -f $file) {
+ print "Usage: hist.pl <dump file>\n";
+ exit;
+}
+
+open(FILE, "<$file");
+
+while(<FILE>) {
+ chomp $_;
+ my $line = $_;
+
+ if($line =~ /^MEM ([^ ]*):(\d*) (.*)/) {
+ # generic match for the filename+linenumber
+ my $source = $1;
+ my $linenum = $2;
+ my $function = $3;
+
+ if($function =~ /free\(0x([0-9a-f]*)/) {
+ }
+ elsif($function =~ /malloc\((\d*)\) = 0x([0-9a-f]*)/) {
+ my $size = $1;
+
+ $sizemap{$size}++;
+ }
+ elsif($function =~ /calloc\((\d*),(\d*)\) = 0x([0-9a-f]*)/) {
+ my $size = $1*$2;
+
+ $sizemap{$size}++;
+ }
+ elsif($function =~ /realloc\(0x([0-9a-f]*), (\d*)\) = 0x([0-9a-f]*)/) {
+ my $newsize = $2;
+
+ $sizemap{$newsize}++;
+ }
+ elsif($function =~ /strdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) {
+ my $size = $2;
+
+ $sizemap{$size}++;
+ }
+ elsif($function =~ /strndup\(0x([0-9a-f]*), (\d*)\) \((\d*)\) = 0x([0-9a-f]*)/) {
+ # strndup(a5b50, 20) (8) = df7c0
+
+ my $size = $3;
+
+ $sizemap{$size}++;
+ }
+ else {
+ print "Not recognized input line: $function\n";
+ }
+ }
+ else {
+ }
+}
+close(FILE);
+
+foreach my $size (sort { $a <=> $b } keys %sizemap) {
+ print "$size,$sizemap{$size}\n";
+}
Propchange: trunk/tools/heapview/utils/hist.pl
------------------------------------------------------------------------------
svn:executable = *
13 years, 7 months
r9481 jmb - in /trunk/tools/heapview/src: heap.h ui.h
by netsurf@semichrome.net
Author: jmb
Date: Fri Aug 28 06:22:00 2009
New Revision: 9481
URL: http://source.netsurf-browser.org?rev=9481&view=rev
Log:
Clearly, G++ 4.3 doesn't like me forward-declaring classes.
Modified:
trunk/tools/heapview/src/heap.h
trunk/tools/heapview/src/ui.h
Modified: trunk/tools/heapview/src/heap.h
URL: http://source.netsurf-browser.org/trunk/tools/heapview/src/heap.h?rev=948...
==============================================================================
--- trunk/tools/heapview/src/heap.h (original)
+++ trunk/tools/heapview/src/heap.h Fri Aug 28 06:22:00 2009
@@ -1,3 +1,6 @@
+#ifndef heapview_heap_h_
+#define heapview_heap_h_
+
#include <set>
#include <vector>
@@ -72,3 +75,5 @@
void processEvent(const Op &op);
void dispatchModified(Client::Type type, const Chunk &chunk);
};
+
+#endif
Modified: trunk/tools/heapview/src/ui.h
URL: http://source.netsurf-browser.org/trunk/tools/heapview/src/ui.h?rev=9481&...
==============================================================================
--- trunk/tools/heapview/src/ui.h (original)
+++ trunk/tools/heapview/src/ui.h Fri Aug 28 06:22:00 2009
@@ -1,11 +1,13 @@
+#ifndef heapview_ui_h_
+#define heapview_ui_h_
+
#include <bitset>
#include <set>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
-class Heap::Client;
-class Heap::Chunk;
+#include "heap.h"
class UI : public Heap::Client
{
@@ -67,3 +69,5 @@
static void bytesForChunk(const Heap::Chunk &chunk, uint64_t rowbase,
size_t &first, size_t &last);
};
+
+#endif
13 years, 7 months