From c4ff284514e627e9a7a200ecee378b3a0e77fd9b Mon Sep 17 00:00:00 2001 From: NicJA Date: Sun, 30 Aug 2015 23:44:35 +0000 Subject: [PATCH] defer creating the ScreenModePrefs until they are needed so that we can query the gfx subsystem for nominal values to use. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@51051 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/intuition/intuition.conf | 2 +- rom/intuition/intuition_init.c | 3 +- rom/intuition/intuition_intern.h | 6 ++-- rom/intuition/intuition_misc.c | 67 +++++++++++++++++++++++++++++++++------- rom/intuition/openscreen.c | 15 +++++---- rom/intuition/openworkbench.c | 28 ++++++++++------- rom/intuition/setiprefs.c | 25 +++++++-------- 7 files changed, 101 insertions(+), 45 deletions(-) diff --git a/rom/intuition/intuition.conf b/rom/intuition/intuition.conf index 1b01007500..e76cc5c791 100644 --- a/rom/intuition/intuition.conf +++ b/rom/intuition/intuition.conf @@ -1,5 +1,5 @@ ##begin config -version 50.3 +version 50.4 residentpri 15 libbasetype struct IntIntuitionBase libbasetypeextern struct IntuitionBase diff --git a/rom/intuition/intuition_init.c b/rom/intuition/intuition_init.c index 983f8f2750..9d69051a8c 100644 --- a/rom/intuition/intuition_init.c +++ b/rom/intuition/intuition_init.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. Copyright © 2001-2013, The MorphOS Development Team. All Rights Reserved. $Id$ */ @@ -84,6 +84,7 @@ static int IntuitionInit(LIBBASETYPEPTR LIBBASE) struct OOP_ABDescr attrbases[] = { {IID_Hidd , &GetPrivIBase(LIBBASE)->HiddAttrBase }, {IID_Hidd_Gfx , &GetPrivIBase(LIBBASE)->HiddGfxAttrBase }, + {IID_Hidd_Sync , &GetPrivIBase(LIBBASE)->HiddSyncAttrBase }, {IID_Hidd_BitMap, &GetPrivIBase(LIBBASE)->HiddBitMapAttrBase}, {IID_Hidd_PixFmt, &GetPrivIBase(LIBBASE)->HiddPixFmtAttrBase}, {NULL , NULL } diff --git a/rom/intuition/intuition_intern.h b/rom/intuition/intuition_intern.h index 73c2cde7bb..1018bc3e35 100644 --- a/rom/intuition/intuition_intern.h +++ b/rom/intuition/intuition_intern.h @@ -2,7 +2,7 @@ #define INTUITION_INTERN_H /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. Copyright © 2001-2013, The MorphOS Development Team. All Rights Reserved. $Id$ */ @@ -542,7 +542,7 @@ struct IntIntuitionBase #endif ULONG *IDCMPPool; - struct IScreenModePrefs ScreenModePrefs; + struct IScreenModePrefs *ScreenModePrefs; struct IIControlPrefs IControlPrefs; #ifdef SKINS struct IAction *IControlActions; @@ -622,6 +622,7 @@ struct IntIntuitionBase OOP_AttrBase HiddGfxAttrBase; OOP_AttrBase HiddBitMapAttrBase; OOP_AttrBase HiddPixFmtAttrBase; + OOP_AttrBase HiddSyncAttrBase; OOP_MethodID ib_HiddGfxBase; OOP_MethodID ib_HiddBitMapBase; @@ -1067,6 +1068,7 @@ ULONG TellWBTaskToCloseWindows(struct IntuitionBase *IntuitionBase); ULONG TellWBTaskToOpenWindows(struct IntuitionBase *IntuitionBase); /* intuition_misc protos */ +extern void SetDisplayDefaults(struct IntuitionBase * IntuitionBase); extern void LoadDefaultPreferences(struct IntuitionBase * IntuitionBase); Object* CreateStdSysImage(WORD which, WORD preferred_height, struct Screen *scr, struct DrawInfo *dri, struct IntuitionBase *IntuitionBase); diff --git a/rom/intuition/intuition_misc.c b/rom/intuition/intuition_misc.c index 6ed1611c98..57bc6c28bb 100644 --- a/rom/intuition/intuition_misc.c +++ b/rom/intuition/intuition_misc.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. Copyright © 2001-2013, The MorphOS Development Team. All Rights Reserved. $Id$ */ @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ #include #include #include +#include #ifdef SKINS # include "intuition_customize.h" @@ -48,6 +50,59 @@ extern IPTR HookEntry(); /**********************************************************************************/ +void SetDisplayDefaults(struct IntuitionBase * IntuitionBase) +{ + struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase; + struct MonitorSpec *defmon; + BOOL done = FALSE; + + D(bug("[Intuition] %s()\n", __PRETTY_FUNCTION__, defmon)); + + if (!GetPrivIBase(IntuitionBase)->ScreenModePrefs) + GetPrivIBase(IntuitionBase)->ScreenModePrefs = AllocMem(sizeof(struct IScreenModePrefs), MEMF_ANY); + + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_DisplayID = INVALID_ID; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Control = 0; + + if ((defmon = OpenMonitor(NULL, INVALID_ID)) != NULL) + { + OOP_Object *sync = (OOP_Object *)defmon->ms_Object, *drv = NULL; + + D(bug("[Intuition] %s: default monitor @ 0x%p\n", __PRETTY_FUNCTION__, defmon)); + + if (sync) + { + OOP_AttrBase HiddSyncAttrBase = GetPrivIBase(IntuitionBase)->HiddSyncAttrBase; + struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase; + + D(bug("[Intuition] %s: monitor sync obj @ 0x%p\n", __PRETTY_FUNCTION__, sync)); + + OOP_GetAttr(sync, aHidd_Sync_GfxHidd, &drv); + if (drv) + { + OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase; + UBYTE depth; + + HIDD_Gfx_NominalDimensions(drv, + &GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Width, + &GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Height, + &depth); + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Depth = depth; + done = TRUE; + } + } + CloseMonitor(defmon); + } + if (!done) + { + D(bug("[Intuition] %s: using system defaults..\n", __PRETTY_FUNCTION__)); + + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Width = GfxBase->NormalDisplayColumns; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Height = GfxBase->NormalDisplayRows; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Depth = AROS_NOMINAL_DEPTH; + } +} + void LoadDefaultPreferences(struct IntuitionBase * IntuitionBase) { # ifdef SKINS @@ -57,16 +112,6 @@ void LoadDefaultPreferences(struct IntuitionBase * IntuitionBase) static CONST UWORD DriPens2[NUMDRIPENS] = { 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1}; static CONST UWORD DriPens4[NUMDRIPENS] = { 1, 0, 1, 2, 1, 3, 1, 0, 2, 1, 2, 1}; # endif /* SKINS */ - - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_DisplayID = INVALID_ID; - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Width = GetPrivIBase(IntuitionBase)->GfxBase->NormalDisplayColumns; -#ifdef __mc68000 - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height = (GetPrivIBase(IntuitionBase)->GfxBase->DisplayFlags & NTSC) ? 200 : 256; -#else - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height = GetPrivIBase(IntuitionBase)->GfxBase->NormalDisplayRows; -#endif - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Depth = AROS_NOMINAL_DEPTH; - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Control = 0; /* Default IControl prefs are AROS addition. Keep while backporting. */ GetPrivIBase(IntuitionBase)->IControlPrefs.ic_TimeOut = 50; diff --git a/rom/intuition/openscreen.c b/rom/intuition/openscreen.c index 30f51df6c4..455eab0561 100644 --- a/rom/intuition/openscreen.c +++ b/rom/intuition/openscreen.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2014, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. Copyright © 2001-2013, The MorphOS Development Team. All Rights Reserved. $Id$ @@ -320,12 +320,15 @@ static const char THIS_FILE[] = __FILE__; * AROS: Use oldstyle ScreenModePrefs structure. * CHECKME: Can we merge better ? */ - ns.Width = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Width; - ns.Height = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height; - ns.Depth = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Depth; - modeid = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_DisplayID; + if (!GetPrivIBase(IntuitionBase)->ScreenModePrefs) + SetDisplayDefaults(IntuitionBase); - if (GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Control & SMF_AUTOSCROLL) + ns.Width = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Width; + ns.Height = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Height; + ns.Depth = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Depth; + modeid = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_DisplayID; + + if (GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Control & SMF_AUTOSCROLL) { /* need to mark autoscroll */ ns.Type |= AUTOSCROLL; diff --git a/rom/intuition/openworkbench.c b/rom/intuition/openworkbench.c index 43958eb11c..0addf43fd9 100644 --- a/rom/intuition/openworkbench.c +++ b/rom/intuition/openworkbench.c @@ -1,9 +1,10 @@ /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved. $Id$ */ +#define DEBUG 0 #include #include #include @@ -107,18 +108,15 @@ static ULONG FindMode(ULONG width, ULONG height, ULONG depth, struct IntuitionBa else { /* Open the Workbench screen if we don't have one. */ - - WORD width = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Width; - WORD height = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height; - WORD depth = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Depth; - ULONG modeid = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_DisplayID; + WORD width, height, depth; + ULONG modeid; APTR disphandle; struct TagItem screenTags[] = { { SA_Width, 0 }, /* 0 */ { SA_Height, 0 }, /* 1 */ - { SA_Depth, depth }, /* 2 */ + { SA_Depth, 0 }, /* 2 */ { SA_DisplayID, 0 }, /* 3 */ { SA_LikeWorkbench, TRUE }, /* 4 */ { SA_Type, WBENCHSCREEN }, /* 5 */ @@ -128,6 +126,14 @@ static ULONG FindMode(ULONG width, ULONG height, ULONG depth, struct IntuitionBa { TAG_END, 0 } }; + if (!GetPrivIBase(IntuitionBase)->ScreenModePrefs) + SetDisplayDefaults(IntuitionBase); + + width = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Width; + height = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Height; + depth = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Depth; + modeid = GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_DisplayID; + D(bug("[OpenWorkbench] Requested size: %dx%d, depth: %d, ModeID: 0x%08lX\n", width, height, depth, modeid)); /* First check if the specified ModeID exists in the system */ @@ -225,16 +231,16 @@ static ULONG FindMode(ULONG width, ULONG height, ULONG depth, struct IntuitionBa depth = BOUND(0, depth, dim.MaxDepth); D(bug("[OpenWorkbench] Corrected size: %dx%d %dbpp\n", width, height, depth)); - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Width = width; - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height = height; - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Depth = depth; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Width = width; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Height = height; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_Depth = depth; } /* * Remember this ModeID because OpenScreen() with SA_LikeWorkbench set to TRUE * looks at this field. We MUST have something valid here. */ - GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_DisplayID = modeid; + GetPrivIBase(IntuitionBase)->ScreenModePrefs->smp_DisplayID = modeid; screenTags[0].ti_Data = width; screenTags[1].ti_Data = height; diff --git a/rom/intuition/setiprefs.c b/rom/intuition/setiprefs.c index b891f3d1c9..06a560168a 100644 --- a/rom/intuition/setiprefs.c +++ b/rom/intuition/setiprefs.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved. $Id$ */ @@ -70,18 +70,16 @@ case IPREFS_TYPE_SCREENMODE_V37: { - struct IScreenModePrefs old_prefs; - DEBUG_SETIPREFS(bug("SetIPrefs: IP_SCREENMODE_V37\n")); if (length > sizeof(struct IScreenModePrefs)) length = sizeof(struct IScreenModePrefs); - if (memcmp(&GetPrivIBase(IntuitionBase)->ScreenModePrefs, data, + if (!GetPrivIBase(IntuitionBase)->ScreenModePrefs) + GetPrivIBase(IntuitionBase)->ScreenModePrefs = AllocMem(sizeof(struct IScreenModePrefs), MEMF_ANY); + + if (memcmp(GetPrivIBase(IntuitionBase)->ScreenModePrefs, data, sizeof(struct IScreenModePrefs)) == 0) break; - - old_prefs = GetPrivIBase(IntuitionBase)->ScreenModePrefs; - GetPrivIBase(IntuitionBase)->ScreenModePrefs = *(struct IScreenModePrefs *)data; if (GetPrivIBase(IntuitionBase)->WorkBench) { @@ -105,18 +103,19 @@ } if (closed) + { + CopyMem(data, GetPrivIBase(IntuitionBase)->ScreenModePrefs, sizeof(struct IScreenModePrefs *)); /* FIXME: handle the error condition if OpenWorkBench() fails */ /* What to do if OpenWorkBench() fails? Try until it succeeds? Try for a finite amount of times? Don't try and do nothing at all? */ - OpenWorkBench(); + if (!OpenWorkBench()) + { + + } + } else - { - lock = LockIBase(0); - GetPrivIBase(IntuitionBase)->ScreenModePrefs = old_prefs; - UnlockIBase(lock); Result = FALSE; - } return Result; -- 2.11.4.GIT