2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <intuition/pointerclass.h>
8 #include <proto/graphics.h>
10 #include "intuition_intern.h"
11 #include "inputhandler.h"
12 #include "monitorclass_private.h"
14 /*****************************************************************************
17 #include <proto/intuition.h>
19 AROS_LH0(LONG
, RethinkDisplay
,
24 struct IntuitionBase
*, IntuitionBase
, 65, Intuition
)
27 Check and update, i.e. redisplay the whole Intuition display.
33 Zero for success, non-zero for failure.
42 RemakeDisplay(), MakeScreen(), graphics.library/MakeVPort(),
43 graphics.library/MrgCop(), graphics.library/LoadView()
47 *****************************************************************************/
51 struct RethinkDisplayActionMsg msg
;
54 DoSyncAction((APTR
)int_RethinkDisplay
, &msg
.msg
, IntuitionBase
);
59 } /* RethinkDisplay */
62 void int_RethinkDisplay(struct RethinkDisplayActionMsg
*msg
,struct IntuitionBase
*IntuitionBase
)
64 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
65 struct Screen
*screen
;
66 struct ViewPort
*viewport
;
67 struct ViewPort
**viewportptr
;
75 screen
= IntuitionBase
->FirstScreen
;
77 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: screen 0x%lx\n",screen
));
81 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: LoadView(NULL)\n"));
82 IntuitionBase
->ViewLord
.ViewPort
= NULL
;
87 /* Find visible screens */
88 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: Find visible screens\n"));
90 screen
->ViewPort
.Modes
|= SPRITES
;
91 screen
->ViewPort
.Modes
&= ~VP_HIDE
;
93 /* Not needed. Perhaps... Pavel Fedin <pavel_fedin@mail.ru>
94 if (!(GetPrivScreen(screen)->SpecialFlags & SF_Compose)) {
95 while ((screen = screen->NextScreen))
96 screen->ViewPort.Modes |= VP_HIDE;
99 /* Build the list of viewports in the view */
100 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: Building viewports list\n"));
101 viewportptr
= &IntuitionBase
->ViewLord
.ViewPort
;
102 for (screen
= IntuitionBase
->FirstScreen
; screen
; screen
= screen
->NextScreen
)
104 GetPrivScreen(screen
)->GammaControl
.Active
= FALSE
;
106 if ((screen
->ViewPort
.Modes
& VP_HIDE
) == 0)
108 DEBUG_RETHINKDISPLAY(bug("RethinkDisplay: Adding ViewPort 0x%p for screen 0x%p\n", &screen
->ViewPort
, screen
));
109 *viewportptr
= &screen
->ViewPort
;
110 viewportptr
= &screen
->ViewPort
.Next
;
116 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: Find view mode\n"));
117 modes
= (IntuitionBase
->ViewLord
.Modes
& ~LACE
) | SPRITES
;
118 for (viewport
= IntuitionBase
->ViewLord
.ViewPort
; viewport
; viewport
= viewport
->Next
) {
119 modes
|= viewport
->Modes
& LACE
;
122 /* Reinitialize the view */
123 IntuitionBase
->ViewLord
.DxOffset
= 0; /***/
124 IntuitionBase
->ViewLord
.DyOffset
= 0; /***/
125 IntuitionBase
->ViewLord
.Modes
= modes
;
126 screen
= IntuitionBase
->FirstScreen
;
128 GetPrivIBase(IntuitionBase
)->ViewLordExtra
->Monitor
= GetPrivScreen(screen
)->Monitor
;
130 /* Rebuild copper lists for screens needing a mode change */
132 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: Making viewports\n"));
133 for (viewport
= IntuitionBase
->ViewLord
.ViewPort
; viewport
; viewport
= viewport
->Next
)
135 if ((viewport
->Modes
^ modes
) & LACE
)
139 viewport
->Modes
= (viewport
->Modes
& ~LACE
) | (modes
& LACE
);
140 error
= MakeVPort(&IntuitionBase
->ViewLord
, viewport
);
149 failure
= MrgCop(&IntuitionBase
->ViewLord
);
155 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: LoadView ViewLord 0x%lx\n",&IntuitionBase
->ViewLord
));
157 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
158 LoadView(&IntuitionBase
->ViewLord
);
161 * Set gamma correction for all displays.
162 * We do it after LoadView() because some video chipsets reuse the
163 * same registers for both LUT palette and gamma table. Consequently,
164 * we may need to reload gamma table after the mode has been changed.
166 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
168 for (m
= GetPrivIBase(IntuitionBase
)->MonitorList
.mlh_Head
;
169 m
->mln_Succ
; m
= m
->mln_Succ
)
171 screen
= FindFirstScreen((Object
*)m
, IntuitionBase
);
175 GetPrivScreen(screen
)->GammaControl
.Active
= TRUE
;
176 DoMethod((Object
*)m
, MM_SetScreenGamma
, &GetPrivScreen(screen
)->GammaControl
, TRUE
);
180 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
181 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
183 DEBUG_INIT(dprintf("RethinkDisplay: ActiveScreen %p Pointer %p Sprite %p\n",
184 IntuitionBase
->ActiveScreen
,
185 GetPrivScreen(IntuitionBase
->ActiveScreen
)->Pointer
,
186 GetPrivScreen(IntuitionBase
->ActiveScreen
)->Pointer
->sprite
));
193 /* validate screen positions, scrolling limits are not necessarily same anymore. */
194 for (screen
= IntuitionBase
->FirstScreen
; screen
; screen
= screen
->NextScreen
)
196 if ((screen
->ViewPort
.Modes
& VP_HIDE
) == 0)
198 ScreenPosition( screen
, SPOS_RELATIVE
, 0,0,0,0 );
201 /* Ensure that empty displays get normal pointer */
202 ResetPointer(IntuitionBase
);
208 DEBUG_RETHINKDISPLAY(dprintf("RethinkDisplay: failure 0x%lx\n",failure
));
210 msg
->failure
= failure
;