2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/graphics.h>
8 #include "intuition_intern.h"
9 #include "inputhandler.h"
11 /*****************************************************************************
14 #include <proto/intuition.h>
16 AROS_LH0(LONG
, RethinkDisplay
,
21 struct IntuitionBase
*, IntuitionBase
, 65, Intuition
)
24 Check and update, ie. redisplay the whole Intuition display.
30 Zero for success, non-zero for failure.
39 RemakeDisplay(), MakeScreen(), graphics.library/MakeVPort(),
40 graphics.library/MrgCop(), graphics.library/LoadView()
46 *****************************************************************************/
51 struct Screen
*screen
;
52 struct ViewPort
*viewport
;
53 struct ViewPort
**viewportptr
;
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
));
66 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: LoadView(NULL)\n"));
67 IntuitionBase
->ViewLord
.ViewPort
= NULL
;
70 else if (IntuitionBase
->ViewLord
.ViewPort
== &screen
->ViewPort
)
72 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: ViewLord.Viewport == screen->ViewPort,does nothing\n"));
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
;
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"));
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
)
142 viewport
->Modes
= (viewport
->Modes
& ~LACE
) | (modes
& LACE
);
143 error
= MakeVPort(&IntuitionBase
->ViewLord
, viewport
);
152 failure
= MrgCop(&IntuitionBase
->ViewLord
);
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
;
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
;
191 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: failure 0x%lx\n",failure
));
199 } /* RethinkDisplay */