some fixes to accented characters
[tangerine.git] / rom / intuition / rethinkdisplay.c
blob3d8b61cb596aa04062992abbf5452b4618d62d9e
1 /*
2 Copyright © 1995-2007, 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"
11 /*****************************************************************************
13 NAME */
14 #include <proto/intuition.h>
16 AROS_LH0(LONG, RethinkDisplay,
18 /* SYNOPSIS */
20 /* LOCATION */
21 struct IntuitionBase *, IntuitionBase, 65, Intuition)
23 /* FUNCTION
24 Check and update, ie. redisplay the whole Intuition display.
26 INPUTS
27 None.
29 RESULT
30 Zero for success, non-zero for failure.
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
39 RemakeDisplay(), MakeScreen(), graphics.library/MakeVPort(),
40 graphics.library/MrgCop(), graphics.library/LoadView()
42 INTERNALS
44 HISTORY
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 #ifdef __MORPHOS__
51 struct Screen *screen;
52 struct ViewPort *viewport;
53 struct ViewPort **viewportptr;
54 UWORD modes;
55 LONG failure = 0;
56 ULONG ilock = LockIBase(0);
58 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay:\n"));
60 screen = IntuitionBase->FirstScreen;
62 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: screen 0x%lx\n",screen));
64 if (screen == NULL)
66 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: LoadView(NULL)\n"));
67 IntuitionBase->ViewLord.ViewPort = NULL;
68 LoadView(NULL);
70 else if (IntuitionBase->ViewLord.ViewPort == &screen->ViewPort)
72 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: ViewLord.Viewport == screen->ViewPort,does nothing\n"));
74 else
76 #warning FIXME: only the first screen is made visible
78 /* Find visible screens */
80 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: Find visible screens\n"));
82 screen->ViewPort.Modes |= SPRITES;
84 screen->ViewPort.Modes &= ~VP_HIDE;
86 while ((screen = screen->NextScreen))
88 screen->ViewPort.Modes |= VP_HIDE;
91 /* Build the list of viewports in the view */
93 viewportptr = &IntuitionBase->ViewLord.ViewPort;
94 for (screen = IntuitionBase->FirstScreen; screen; screen = screen->NextScreen)
96 if ((screen->ViewPort.Modes & VP_HIDE) == 0)
98 *viewportptr = &screen->ViewPort;
99 viewportptr = &screen->ViewPort.Next;
102 *viewportptr = NULL;
104 /* Find view mode */
106 modes = (IntuitionBase->ViewLord.Modes & ~LACE) | SPRITES;
107 for (viewport = IntuitionBase->ViewLord.ViewPort; viewport; viewport = viewport->Next)
108 modes |= screen->ViewPort.Modes & LACE;
110 /* Reinitialize the view */
112 FreeSprite(GetPrivIBase(IntuitionBase)->SpriteNum);
113 GetPrivIBase(IntuitionBase)->SpriteNum = -1;
115 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: LoadView(NULL)\n"));
117 LoadView(NULL);
119 if (IntuitionBase->ViewLord.LOFCprList)
120 FreeCprList(IntuitionBase->ViewLord.LOFCprList);
122 if (IntuitionBase->ViewLord.SHFCprList)
123 FreeCprList(IntuitionBase->ViewLord.SHFCprList);
125 IntuitionBase->ViewLord.LOFCprList = NULL;
126 IntuitionBase->ViewLord.SHFCprList = NULL;
128 IntuitionBase->ViewLord.DxOffset = 0; /***/
129 IntuitionBase->ViewLord.DyOffset = 0; /***/
130 IntuitionBase->ViewLord.Modes = modes;
131 screen = IntuitionBase->FirstScreen;
132 GetPrivIBase(IntuitionBase)->ViewLordExtra->Monitor = GetPrivScreen(screen)->Monitor;
134 /* Rebuild copper lists for screens needing a mode change */
136 for (viewport = IntuitionBase->ViewLord.ViewPort; viewport; viewport = viewport->Next)
138 if ((viewport->Modes ^ modes) & LACE)
140 LONG error;
142 viewport->Modes = (viewport->Modes & ~LACE) | (modes & LACE);
143 error = MakeVPort(&IntuitionBase->ViewLord, viewport);
145 if (error)
146 failure = error;
150 if (!failure)
152 failure = MrgCop(&IntuitionBase->ViewLord);
154 if (!failure)
156 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: LoadView ViewLord 0x%lx\n",&IntuitionBase->ViewLord));
157 LoadView(&IntuitionBase->ViewLord);
159 DEBUG_INIT(dprintf("RethinkDisplay: SpriteNum %ld ActiveScreen %p Pointer %p Sprite %p\n",
160 GetPrivIBase(IntuitionBase)->SpriteNum,
161 IntuitionBase->ActiveScreen,
162 GetPrivScreen(IntuitionBase->ActiveScreen)->Pointer,
163 GetPrivScreen(IntuitionBase->ActiveScreen)->Pointer->sprite));
165 if (GetPrivIBase(IntuitionBase)->SpriteNum == -1 &&
166 IntuitionBase->FirstScreen &&
167 GetPrivScreen(IntuitionBase->FirstScreen)->Pointer &&
168 GetPrivScreen(IntuitionBase->FirstScreen)->Pointer->sprite)
170 struct IIHData *iihd = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data;
171 WORD xpos,ypos;
173 xpos = iihd->LastMouseX; ypos = iihd->LastMouseY;
174 GetPrivIBase(IntuitionBase)->SpriteNum = GetExtSpriteA(GetPrivScreen(IntuitionBase->FirstScreen)->Pointer->sprite, NULL);
176 DEBUG_INIT(dprintf("RethinkDisplay: Sprite num %ld\n", GetPrivIBase(IntuitionBase)->SpriteNum));
178 if (xpos >= IntuitionBase->FirstScreen->Width) xpos = IntuitionBase->FirstScreen->Width - 1;
179 if (ypos >= IntuitionBase->FirstScreen->Height) ypos = IntuitionBase->FirstScreen->Height - 1;
181 MySetPointerPos(IntuitionBase, xpos, ypos);
182 IntuitionBase->FirstScreen->MouseX = xpos;
183 IntuitionBase->FirstScreen->MouseY = ypos;
189 UnlockIBase(ilock);
191 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: failure 0x%lx\n",failure));
193 return failure;
195 #else
196 return 0;
197 #endif
198 AROS_LIBFUNC_EXIT
199 } /* RethinkDisplay */