Changes for asynchronous printing. Currently disabled, as NetSurf window doesn't

redraw while printing in progress

svn path=/trunk/netsurf/; revision=9495
This commit is contained in:
Chris Young 2009-08-29 14:00:57 +00:00
parent 4e9480e6c7
commit 0b6f91dd61
8 changed files with 89 additions and 26 deletions

View File

@ -591,7 +591,7 @@ PrintErrorRO2:Der Drucker scheint beschäftigt zu sein.
AWNotSeen:Please locate the AWViewer application and try again.
# Error messages for Amiga version only
NoMode:No matching mode in screens database
CompError:Unable to open
# Queries
# =======

View File

@ -596,7 +596,7 @@ AWNotSeen:Please locate the AWViewer application and try again.
EncNotRec:Encoding type not recognised.
# Error messages for Amiga version only
NoMode:No matching mode in screens database
CompError:Unable to open
# Queries
# =======

View File

@ -591,7 +591,7 @@ PrintErrorRO2:Il semble que l'imprimante soit occupée.
AWNotSeen:Localisez l'application AMViewer SVP puis réessayez.
# Error messages for Amiga version only
NoMode:No matching mode in screens database
CompError:Unable to open
# Queries
# =======

View File

@ -598,7 +598,7 @@ AWNotSeen:Per favore imposta l'applicazione AWViewer e riprova ancora.
EncNotRec:Tipo di codifica sconosciuta.
# Error messages for Amiga version only
NoMode:Questa modalità non coincide nel database degli schermi
CompError:Unable to open
# Queries
# =======

View File

@ -591,7 +591,7 @@ PrintErrorRO2:De printer lijkt al bezig te zijn.
AWNotSeen:Please locate the AWViewer application and try again.
# Error messages for Amiga version only
NoMode:No matching mode in screens database
CompError:Unable to open
# Queries
# =======

View File

@ -262,6 +262,8 @@ void gui_init(int argc, char** argv)
ASO_NoTrack,FALSE,
TAG_DONE))) die(messages_get("NoMemory"));
ami_print_init();
if(PopupMenuBase = OpenLibrary("popupmenu.class",0))
{
IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase,"main",1,NULL);
@ -1406,9 +1408,11 @@ void ami_get_msg(void)
ULONG winsignal = 1L << sport->mp_SigBit;
ULONG appsig = 1L << appport->mp_SigBit;
ULONG schedulesig = 1L << msgport->mp_SigBit;
ULONG signalmask = winsignal | appsig | schedulesig | rxsig;
ULONG signal;
struct Message *timermsg = NULL;
struct MsgPort *printmsgport = ami_print_get_msgport();
ULONG printsig = 1L << printmsgport->mp_SigBit;
ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig;
signal = Wait(signalmask);
@ -1424,6 +1428,11 @@ void ami_get_msg(void)
{
ami_arexx_handle();
}
else if(signal & printsig)
{
while(GetMsg(printmsgport)); //ReplyMsg
ami_print_cont();
}
else if(signal & schedulesig)
{
while(GetMsg(msgport))
@ -1582,6 +1591,7 @@ void gui_quit(void)
}
ami_clipboard_free();
ami_print_free();
FreeSysObject(ASOT_PORT,appport);
FreeSysObject(ASOT_PORT,sport);
@ -2382,6 +2392,7 @@ void ami_do_redraw_limits(struct gui_window *g, struct content *c,int x0, int y0
yoffset=bbox->Top;
plot=amiplot;
glob = &browserglob;
if((y1<sy) || (y0>sy+height)) return;
if((x1<sx) || (x0>sx+width)) return;
@ -2481,6 +2492,7 @@ void ami_do_redraw(struct gui_window_2 *g)
xoffset=bbox->Left;
yoffset=bbox->Top;
plot = amiplot;
glob = &browserglob;
if(g->bw->reformat_pending)
{

View File

@ -21,8 +21,8 @@
#include "render/font.h"
#include "amiga/gui.h"
#include "amiga/options.h"
#include "amiga/print.h"
#include <proto/exec.h>
#include <proto/Picasso96API.h>
#include <devices/printer.h>
#include <devices/prtbase.h>
@ -46,18 +46,19 @@ struct ami_printer_info
struct PrinterData *PD;
struct PrinterExtendedData *PED;
struct MsgPort *msgport;
struct content *c;
struct print_settings *ps;
int page;
int pages;
};
struct ami_printer_info ami_print_info;
void ami_print(struct content *c)
{
struct print_settings *ps;
double height, print_height;
if(!(ami_print_info.msgport = AllocSysObjectTags(ASOT_PORT,
ASO_NoTrack,FALSE,
TAG_DONE))) return;
if(!ami_print_info.msgport) return;
if(!(ami_print_info.PReq =
(struct IODRPTagsReq *)AllocSysObjectTags(ASOT_IOREQUEST,
@ -67,23 +68,69 @@ void ami_print(struct content *c)
TAG_DONE))) return;
if(OpenDevice("printer.device", option_printer_unit,
(struct IORequest *)ami_print_info.PReq, 0)) return;
(struct IORequest *)ami_print_info.PReq, 0))
{
warn_user("CompError","printer.device");
return;
}
ami_print_info.PD = (struct PrinterData *)ami_print_info.PReq->io_Device;
ami_print_info.PED = &ami_print_info.PD->pd_SegmentData->ps_PED;
ps = print_make_settings(PRINT_DEFAULT, c->url, &nsfont);
ps->page_width = ami_print_info.PED->ped_MaxXDots;
ps->page_height = ami_print_info.PED->ped_MaxYDots;
ps->scale = 1.0;
ami_print_info.ps = print_make_settings(PRINT_DEFAULT, c->url, &nsfont);
ami_print_info.ps->page_width = ami_print_info.PED->ped_MaxXDots;
ami_print_info.ps->page_height = ami_print_info.PED->ped_MaxYDots;
ami_print_info.ps->scale = 1.0;
print_basic_run(c, &amiprinter, ps);
print_set_up(c, &amiprinter, ami_print_info.ps, &height);
CloseDevice(ami_print_info.PReq);
FreeSysObject(ASOT_IOREQUEST,ami_print_info.PReq);
height *= ami_print_info.ps->scale;
ami_print_info.pages = height / ami_print_info.ps->page_height;
ami_print_info.c = c;
while(ami_print_cont()); /* remove while() for async printing */
}
bool ami_print_cont(void)
{
bool ret = false;
if(ami_print_info.page <= ami_print_info.pages)
{
glob = ami_print_info.gg;
print_draw_next_page(&amiprinter, ami_print_info.ps);
ami_print_dump();
glob = &browserglob;
ret = true;
}
else
{
print_cleanup(ami_print_info.c, &amiprinter, ami_print_info.ps);
ret = false;
}
return ret;
}
struct MsgPort *ami_print_init(void)
{
ami_print_info.msgport = AllocSysObjectTags(ASOT_PORT,
ASO_NoTrack,FALSE,
TAG_DONE);
return ami_print_info.msgport;
}
void ami_print_free(void)
{
FreeSysObject(ASOT_PORT,ami_print_info.msgport);
}
struct MsgPort *ami_print_get_msgport(void)
{
return ami_print_info.msgport;
}
bool ami_print_begin(struct print_settings *ps)
{
ami_print_info.gg = AllocVec(sizeof(struct gui_globals),
@ -94,7 +141,6 @@ bool ami_print_begin(struct print_settings *ps)
ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots);
glob = ami_print_info.gg;
ami_print_info.page = 0;
return true;
@ -102,20 +148,19 @@ bool ami_print_begin(struct print_settings *ps)
bool ami_print_next_page(void)
{
bool ret = true;
if(ami_print_info.page > 0) ret = ami_print_dump();
ami_print_info.page++;
return ret;
return true;
}
void ami_print_end(void)
{
ami_print_dump();
ami_free_layers(ami_print_info.gg);
FreeVec(ami_print_info.gg);
glob = &browserglob;
CloseDevice(ami_print_info.PReq);
FreeSysObject(ASOT_IOREQUEST,ami_print_info.PReq);
}
bool ami_print_dump(void)
@ -134,7 +179,7 @@ bool ami_print_dump(void)
ami_print_info.PReq->io_DestRows = ami_print_info.PED->ped_MaxYDots;
ami_print_info.PReq->io_Special = 0;
DoIO(ami_print_info.PReq);
DoIO(ami_print_info.PReq); /* SendIO for async printing */
return true;
}

View File

@ -18,7 +18,13 @@
#ifndef AMIGA_PRINT_H
#define AMIGA_PRINT_H
#include <proto/exec.h>
struct content;
void ami_print(struct content *c);
bool ami_print_cont(void);
struct MsgPort *ami_print_init(void);
void ami_print_free(void);
struct MsgPort *ami_print_get_msgport(void);
#endif