arosc.library: Centralized exit handling code in __arosc_startup.c
[AROS.git] / rom / intuition / changescreenbuffer.c
blob50b302a859a97e606b19b3716fbb7df6e1c5505e
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include "intuition_intern.h"
9 #include "inputhandler.h"
10 #include "menus.h"
12 /*****************************************************************************
14 NAME */
15 #include <intuition/screens.h>
16 #include <proto/intuition.h>
18 AROS_LH2(ULONG, ChangeScreenBuffer,
20 /* SYNOPSIS */
21 AROS_LHA(struct Screen * , screen, A0),
22 AROS_LHA(struct ScreenBuffer *, screenbuffer, A1),
24 /* LOCATION */
25 struct IntuitionBase *, IntuitionBase, 130, Intuition)
27 /* FUNCTION
28 Do double or multiple buffering on an intuition screen in an
29 intuition-cooperative way.
30 The ScreenBuffer's BitMap will be installed on the specifies screen,
31 if possible.
32 After a signal from graphics.library, the previously installed
33 BitMap will be available for re-use.
34 Consult graphics.library/AllocDBufInfo() and
35 graphics.library/ChangeVPBitMap() for further information.
37 INPUTS
38 screen - The screen this screenbuffer belongs to
39 screenbuffer - The screenbuffer obtained by AllocScreenBuffer()
41 RESULT
42 Non-zero if fuction succeeded, or zero if operation could not be
43 performed, eg. if user selects menus or gadgets.
45 NOTES
46 You need not re-install the original ScreenBuffer before closing
47 a screen. Just FreeScreenBuffer() all buffers used for that screen.
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 AllocScreenBuffer(), FreeScreenBuffer(),
55 graphics.library/ChangeVPBitMap()
57 INTERNALS
59 HISTORY
61 *****************************************************************************/
63 AROS_LIBFUNC_INIT
65 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
66 struct IIHData *iihdata;
67 ULONG lock;
69 if (!screen) return 0;
70 if (!screenbuffer) return 0;
72 if (MENUS_ACTIVE) return 0;
73 iihdata = (struct IIHData *)((struct IntIntuitionBase *)(IntuitionBase))->InputHandler->is_Data;
74 if (iihdata->ActiveGadget) return 0;
76 ChangeVPBitMap(&screen->ViewPort,screenbuffer->sb_BitMap,screenbuffer->sb_DBufInfo);
78 lock = LockIBase(0);
80 screen->BitMap = *screenbuffer->sb_BitMap;
81 screen->RastPort.BitMap = screenbuffer->sb_BitMap;
83 UnlockIBase(lock);
85 return TRUE;
87 AROS_LIBFUNC_EXIT
88 } /* ChangeScreenBuffer */