]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Window resize realtime updating etc.
authorToni Wilen <twilen@winuae.net>
Sat, 29 Jul 2023 14:28:49 +0000 (17:28 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 29 Jul 2023 14:28:49 +0000 (17:28 +0300)
od-win32/direct3d11.cpp
od-win32/gdirender.cpp
od-win32/picasso96_win.cpp
od-win32/picasso96_win.h
od-win32/resources/winuae.rc
od-win32/win32.cpp
od-win32/win32_scaler.cpp
od-win32/win32gfx.cpp
od-win32/win32gui.cpp
od-win32/win32gui_extra.cpp

index 128b8e16a3893cb8e80c6885033cf7745a28e6e1..2695bf7f9a63394ba8de7580866d8363ab576fb3 100644 (file)
@@ -3414,6 +3414,18 @@ static float xD3D_getrefreshrate(int monid)
        return d3d->vblank;
 }
 
+static void xD3D11_initvals(HWND ahwnd, int monid, int w_w, int w_h, int t_w, int t_h, int depth, int *freq, int mmulth, int mmultv)
+{
+       struct d3d11struct *d3d = &d3d11data[monid];
+
+       d3d->m_bitmapWidth = t_w;
+       d3d->m_bitmapHeight = t_h;
+       d3d->m_screenWidth = w_w;
+       d3d->m_screenHeight = w_h;
+       d3d->dmultxh = mmulth;
+       d3d->dmultxv = mmultv;
+}
+
 static int xxD3D11_init2(HWND ahwnd, int monid, int w_w, int w_h, int t_w, int t_h, int depth, int *freq, int mmulth, int mmultv)
 {
        struct d3d11struct *d3d = &d3d11data[monid];
@@ -3449,15 +3461,12 @@ static int xxD3D11_init2(HWND ahwnd, int monid, int w_w, int w_h, int t_w, int t
                return 0;
        }
 
-       d3d->m_bitmapWidth = t_w;
-       d3d->m_bitmapHeight = t_h;
-       d3d->m_screenWidth = w_w;
-       d3d->m_screenHeight = w_h;
+       xD3D11_initvals(ahwnd, monid, w_w, w_h, t_w, t_h, depth, freq, mmulth, mmultv);
+
        d3d->ahwnd = ahwnd;
+
        d3d->texformat = DXGI_FORMAT_B8G8R8A8_UNORM;
        d3d->scrformat = DXGI_FORMAT_B8G8R8A8_UNORM;
-       d3d->dmultxh = mmulth;
-       d3d->dmultxv = mmultv;
 
        HMONITOR winmon;
        struct MultiDisplay *md = NULL;
@@ -4137,16 +4146,23 @@ static const TCHAR *xD3D11_init(HWND ahwnd, int monid, int w_w, int w_h, int dep
                *errp = 1;
                return _T("D3D11 FAILED TO INIT");
        }
-       int v = xxD3D11_init(ahwnd, monid, w_w, w_h, depth, freq, mmulth, mmultv);
-       if (v > 0) {
+       if (!D3D_isenabled(monid)) {
+               int v = xxD3D11_init(ahwnd, monid, w_w, w_h, depth, freq, mmulth, mmultv);
+               if (v > 0) {
+                       return NULL;
+               }
+               xD3D11_free(monid, true);
+               *errp = 1;
+               if (v <= 0) {
+                       return _T("");
+               }
+               return _T("D3D11 INITIALIZATION ERROR");
+       } else {
+               struct d3d11struct *d3d = &d3d11data[monid];
+               xD3D11_initvals(ahwnd, monid, w_w, w_h, w_w, w_h, depth, freq, mmulth, mmultv);
+               d3d->fsresizedo = true;
                return NULL;
        }
-       xD3D11_free(monid, true);
-       *errp = 1;
-       if (v <= 0) {
-               return _T("");
-       }
-       return _T("D3D11 INITIALIZATION ERROR");
 }
 
 static void setpsbuffer(struct d3d11struct *d3d, ID3D11Buffer *psbuffer)
index f1313673b596077f7fa7904aa575c6d29c01a8f6..0a548e0417bd538cea3676d8f4fa580051e13ec4 100644 (file)
@@ -327,7 +327,9 @@ static bool gdi_renderframe(int monid, int mode, bool immediate)
 {
        struct gdistruct *gdi = &gdidata[monid];
 
-       setupscenecoords(gdi, monid);
+       if (gdi->bm.hbm) {
+               setupscenecoords(gdi, monid);
+       }
        return gdi->bm.hbm != NULL;
 }
 
index ef20225fa3884f30e1b01c9f3441db7b7f679976..a2e7a5807a7a04f144d78983ae9b90037c6bc2c1 100644 (file)
@@ -1088,6 +1088,9 @@ static void setconvert(int monid)
        if (vidinfo->host_mode != vidinfo->ohost_mode || state->RGBFormat != vidinfo->orgbformat) {
                write_log (_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d/%d\n"),
                        picasso_vidinfo[monid].pixbytes, vidinfo->host_mode, state->RGBFormat, vidinfo->picasso_convert[0], vidinfo->picasso_convert[1]);
+               if (vidinfo->host_mode != vidinfo->ohost_mode && currprefs.win32_rtgmatchdepth) {
+                       state->ModeChanged = true;
+               }
                vidinfo->ohost_mode = vidinfo->host_mode;
                vidinfo->orgbformat = state->RGBFormat;
        }
@@ -3082,6 +3085,7 @@ static void init_picasso_screen(int monid)
                gfx_set_picasso_modeinfo(monid, state->RGBFormat);
                set_gc_called = 0;
        }
+
        if((vidinfo->width == state->Width) &&
                (vidinfo->height == state->Height) &&
                (vidinfo->depth == (state->GC_Depth >> 3)) &&
@@ -3119,13 +3123,25 @@ static uae_u32 REGPARAM2 picasso_SetGC (TrapContext *ctx)
        trap_put_long(ctx, AmigaBoardInfo + PSSO_BoardInfo_ModeInfo, modeinfo);
        trap_put_word(ctx, AmigaBoardInfo + PSSO_BoardInfo_Border, border);
 
-       state->Width = trap_get_word(ctx, modeinfo + PSSO_ModeInfo_Width);
+       uae_u16 w = trap_get_word(ctx, modeinfo + PSSO_ModeInfo_Width);
+       if (w != state->Width) {
+               state->ModeChanged = true;
+       }
+       state->Width = w;
        state->VirtualWidth = state->Width; /* in case SetPanning doesn't get called */
 
-       state->Height = trap_get_word(ctx, modeinfo + PSSO_ModeInfo_Height);
+       uae_u16 h = trap_get_word(ctx, modeinfo + PSSO_ModeInfo_Height);
+       if (h != state->Height) {
+               state->ModeChanged = true;
+       }
+       state->Height = h;
        state->VirtualHeight = state->Height; /* in case SetPanning doesn't get called */
 
-       state->GC_Depth = trap_get_byte(ctx, modeinfo + PSSO_ModeInfo_Depth);
+       uae_u8 d = trap_get_byte(ctx, modeinfo + PSSO_ModeInfo_Depth);
+       if (d != state->GC_Depth) {
+               state->ModeChanged = true;
+       }
+       state->GC_Depth = d;
        state->GC_Flags = trap_get_byte(ctx, modeinfo + PSSO_ModeInfo_Flags);
 
        state->HLineDBL = 1;
index 16852068c5b64687c7507ed460ba81e9f3477186..7b635d1e7e2fa83f5fcfafb71f9633e659aee1ba 100644 (file)
@@ -640,6 +640,7 @@ struct picasso96_state_struct
     int         XYOffset;
     bool        dualclut, advDragging;
     int         HLineDBL, VLineDBL;
+    bool        ModeChanged;
 };
 
 extern void InitPicasso96(int monid);
index 05c67a49adfd78070261ec0b5d87495dcf04bc31..a097c04f84456136a6d8ce8812c6d6ef5e83bf3c 100644 (file)
@@ -580,23 +580,23 @@ BEGIN
     COMBOBOX        IDC_PORT3_JOYSSUB,16,190,24,130,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
 END
 
-IDD_CONTRIBUTORS DIALOGEX 0, 0, 530, 345
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION
+IDD_CONTRIBUTORS DIALOGEX 0, 0, 398, 293
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION
 CAPTION "UAE Authors and Contributors..."
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-    DEFPUSHBUTTON   "Ok",ID_OK,238,324,53,14
-    CONTROL         "",IDC_CONTRIBUTORS,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,10,7,510,312
+    DEFPUSHBUTTON   "Ok",ID_OK,172,273,53,14
+    CONTROL         "",IDC_CONTRIBUTORS,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,384,260
 END
 
-IDD_ERRORLOG DIALOGEX 0, 0, 530, 345
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION
+IDD_ERRORLOG DIALOGEX 0, 0, 398, 293
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION
 CAPTION "Configuration error log"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,176,322,65,15
-    PUSHBUTTON      "Clear log",IDC_ERRORLOGCLEAR,288,322,65,15
-    CONTROL         "",IDC_ERRORLOGMESSAGE,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,10,515,306
+    DEFPUSHBUTTON   "OK",IDOK,125,269,65,15
+    PUSHBUTTON      "Clear log",IDC_ERRORLOGCLEAR,208,269,65,15
+    CONTROL         "",IDC_ERRORLOGMESSAGE,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,4,6,389,254
 END
 
 IDD_ABOUT DIALOGEX 0, 0, 396, 316
@@ -649,7 +649,7 @@ BEGIN
 END
 
 IDD_HARDFILE DIALOGEX 0, 0, 397, 292
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 EXSTYLE WS_EX_ACCEPTFILES
 CAPTION "Hardfile Settings"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
@@ -725,8 +725,8 @@ BEGIN
     PUSHBUTTON      "Eject",IDC_FS_SELECT_EJECT,258,90,62,15
 END
 
-IDD_SETINFO DIALOGEX 0, 0, 397, 132
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+IDD_SETINFO DIALOGEX 0, 0, 397, 119
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Additional Information Settings"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
@@ -741,8 +741,8 @@ BEGIN
     EDITTEXT        IDC_CONFIGTAGS,46,74,249,15,ES_AUTOHSCROLL
     CONTROL         "Ignore link",IDC_CONFIGNOLINK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,305,37,58,12
     CONTROL         "Autoload",IDC_CONFIGAUTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,305,56,51,12
-    PUSHBUTTON      "OK",IDOK,146,102,48,15
-    PUSHBUTTON      "Cancel",IDCANCEL,201,102,48,15
+    PUSHBUTTON      "OK",IDOK,147,97,48,15
+    PUSHBUTTON      "Cancel",IDCANCEL,202,97,48,15
 END
 
 IDD_CHIPSET DIALOGEX 0, 0, 396, 316
@@ -980,8 +980,8 @@ BEGIN
     PUSHBUTTON      "Delete",IDC_FILTERPRESETDELETE,325,280,55,14
 END
 
-IDD_HARDDRIVE DIALOGEX 0, 0, 397, 219
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+IDD_HARDDRIVE DIALOGEX 0, 0, 397, 208
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Harddrive Settings"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
@@ -1178,7 +1178,7 @@ BEGIN
 END
 
 IDD_PROGRESSBAR DIALOGEX 0, 0, 396, 58
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Processing..."
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
@@ -1282,39 +1282,39 @@ BEGIN
     COMBOBOX        IDC_RTG_SCALE_ASPECTRATIO,282,227,84,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
 END
 
-IDD_INPUTMAP DIALOGEX 0, 0, 421, 341
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+IDD_INPUTMAP DIALOGEX 0, 0, 421, 293
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Input Remap"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
     DEFPUSHBUTTON   "OK",IDOK,147,51,58,14,NOT WS_VISIBLE
-    CONTROL         "",IDC_INPUTMAPLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,1,1,418,257
-    EDITTEXT        IDC_INPUTMAPOUT,1,261,418,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED
-    EDITTEXT        IDC_INPUTMAPOUTM,1,277,418,29,ES_MULTILINE | ES_READONLY | WS_DISABLED
-    COMBOBOX        IDC_INPUTMAPADD,2,309,247,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
-    PUSHBUTTON      "Add Event",IDC_INPUTMAP_CUSTOM,253,308,79,14
-    PUSHBUTTON      "Autofire",IDC_INPUTMAP_SPECIALS,338,308,79,14
-    PUSHBUTTON      "Test",IDC_INPUTMAP_TEST,1,325,80,14
-    PUSHBUTTON      "Remap",IDC_INPUTMAP_CAPTURE,85,325,80,14
-    PUSHBUTTON      "Delete",IDC_INPUTMAP_DELETE,169,325,80,14
-    PUSHBUTTON      "Delete all",IDC_INPUTMAP_DELETEALL,253,325,80,14
-    PUSHBUTTON      "Exit",IDC_INPUTMAP_EXIT,338,325,79,14
+    CONTROL         "",IDC_INPUTMAPLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,1,1,418,206
+    EDITTEXT        IDC_INPUTMAPOUT,1,211,418,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED
+    EDITTEXT        IDC_INPUTMAPOUTM,1,227,418,29,ES_MULTILINE | ES_READONLY | WS_DISABLED
+    COMBOBOX        IDC_INPUTMAPADD,2,259,247,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+    PUSHBUTTON      "Add Event",IDC_INPUTMAP_CUSTOM,253,258,79,14
+    PUSHBUTTON      "Autofire",IDC_INPUTMAP_SPECIALS,338,258,79,14
+    PUSHBUTTON      "Test",IDC_INPUTMAP_TEST,1,275,80,14
+    PUSHBUTTON      "Remap",IDC_INPUTMAP_CAPTURE,85,275,80,14
+    PUSHBUTTON      "Delete",IDC_INPUTMAP_DELETE,169,275,80,14
+    PUSHBUTTON      "Delete all",IDC_INPUTMAP_DELETEALL,253,275,80,14
+    PUSHBUTTON      "Exit",IDC_INPUTMAP_EXIT,338,275,79,14
 END
 
 IDD_INFOBOX DIALOGEX 0, 0, 420, 68
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Scanning ROM image files..."
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,113,51,58,14,NOT WS_VISIBLE
-    PUSHBUTTON      "Cancel",IDCANCEL,180,51,58,14
+    DEFPUSHBUTTON   "OK",IDOK,147,51,58,14,NOT WS_VISIBLE
+    PUSHBUTTON      "Cancel",IDCANCEL,214,51,58,14
     CTEXT           "",IDC_INFOBOX_TEXT1,4,7,412,11,SS_CENTERIMAGE | SS_SUNKEN | WS_TABSTOP
     CTEXT           "",IDC_INFOBOX_TEXT2,4,21,412,11,SS_CENTERIMAGE | SS_SUNKEN | WS_TABSTOP
     CTEXT           "",IDC_INFOBOX_TEXT3,4,35,412,11,SS_CENTERIMAGE | SS_SUNKEN | WS_TABSTOP
 END
 
 IDD_LIST DIALOGEX 0, 0, 316, 206
-STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Options"
 FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN
@@ -1338,7 +1338,7 @@ BEGIN
 END
 
 IDD_TAPEDRIVE DIALOGEX 0, 0, 395, 97
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Tape Drive Settings"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
@@ -1356,7 +1356,7 @@ BEGIN
 END
 
 IDD_DISKINFO DIALOGEX 0, 0, 491, 323
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Disk image information"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
@@ -1409,7 +1409,7 @@ BEGIN
 END
 
 IDD_CHSQUERY DIALOGEX 0, 0, 396, 85
-STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "CHS Geometry"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
index 63dcafaa57a746202f9c8ae163879985f1c2b16a..04c6008d9c357c0c37c9f5bfe3e102b90ce603c6 100644 (file)
@@ -24,6 +24,7 @@
 #define _WIN32_WINNT 0x0A00
 
 #include <windows.h>
+#include <windowsx.h>
 #include <commctrl.h>
 #include <commdlg.h>
 #include <shellapi.h>
@@ -1810,12 +1811,19 @@ static void processtouch(struct AmigaMonitor *mon, HWND hwnd, WPARAM wParam, LPA
 }
 #endif
 
-static void resizing(struct AmigaMonitor *mon, WPARAM mode, RECT *r)
+static bool hasresizelimit(struct AmigaMonitor *mon)
+{
+       if (!mon->ratio_sizing || !mon->ratio_width || !mon->ratio_height)
+               return false;
+       return true;
+}
+
+static void doresizing(struct AmigaMonitor *mon, WPARAM mode, RECT *r)
 {
        int nw = (r->right - r->left) + mon->ratio_adjust_x;
        int nh = (r->bottom - r->top) + mon->ratio_adjust_y;
 
-       if (!mon->ratio_sizing || !mon->ratio_width || !mon->ratio_height)
+       if (!hasresizelimit(mon))
                return;
 
        if (mode == WMSZ_BOTTOM || mode == WMSZ_TOP) {
@@ -1848,6 +1856,206 @@ static void resizing(struct AmigaMonitor *mon, WPARAM mode, RECT *r)
        }
 }
 
+static int canstretch(struct AmigaMonitor *mon)
+{
+       if (isfullscreen() != 0)
+               return 0;
+       if (!WIN32GFX_IsPicassoScreen(mon)) {
+               if (!currprefs.gfx_windowed_resize)
+                       return 0;
+               if (currprefs.gf[GF_NORMAL].gfx_filter_autoscale == AUTOSCALE_RESIZE)
+                       return 0;
+               return 1;
+       } else {
+               if (currprefs.win32_rtgallowscaling || currprefs.gf[GF_RTG].gfx_filter_autoscale)
+                       return 1;
+       }
+       return 0;
+}
+
+static void getsizemove(AmigaMonitor *mon)
+{
+       mon->ratio_width = mon->amigawin_rect.right - mon->amigawinclip_rect.left;
+       mon->ratio_height = mon->amigawin_rect.bottom - mon->amigawinclip_rect.top;
+       mon->ratio_adjust_x = mon->ratio_width - (mon->mainwin_rect.right - mon->mainwin_rect.left);
+       mon->ratio_adjust_y = mon->ratio_height - (mon->mainwin_rect.bottom - mon->mainwin_rect.top);
+       mon->ratio_sizing = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
+}
+
+static int setsizemove(AmigaMonitor *mon, HWND hWnd)
+{
+       if (isfullscreen() > 0)
+               return 0;
+       if (mon->in_sizemove > 0)
+               return 0;
+       int iconic = IsIconic(hWnd);
+       if (mon->hAmigaWnd && hWnd == mon->hMainWnd && !iconic) {
+               //write_log (_T("WM_WINDOWPOSCHANGED MAIN\n"));
+               GetWindowRect(mon->hMainWnd, &mon->mainwin_rect);
+               updatewinrect(mon, false);
+               updatemouseclip(mon);
+               if (minimized) {
+                       unsetminimized(mon->monitor_id);
+                       winuae_active(mon, mon->hAmigaWnd, minimized);
+               }
+               if (isfullscreen() == 0) {
+                       static int store_xy;
+                       RECT rc2;
+                       if (GetWindowRect(mon->hMainWnd, &rc2)) {
+                               DWORD left = rc2.left - mon->win_x_diff;
+                               DWORD top = rc2.top - mon->win_y_diff;
+                               DWORD width = rc2.right - rc2.left;
+                               DWORD height = rc2.bottom - rc2.top;
+                               if (store_xy++) {
+                                       if (!mon->monitor_id) {
+                                               regsetint(NULL, _T("MainPosX"), left);
+                                               regsetint(NULL, _T("MainPosY"), top);
+                                       } else {
+                                               TCHAR buf[100];
+                                               _stprintf(buf, _T("MainPosX_%d"), mon->monitor_id);
+                                               regsetint(NULL, buf, left);
+                                               _stprintf(buf, _T("MainPosY_%d"), mon->monitor_id);
+                                               regsetint(NULL, buf, top);
+                                       }
+                               }
+                               changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.x = left;
+                               changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.y = top;
+                               if (canstretch(mon)) {
+                                       int w = mon->mainwin_rect.right - mon->mainwin_rect.left;
+                                       int h = mon->mainwin_rect.bottom - mon->mainwin_rect.top;
+                                       if (w != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width + mon->window_extra_width ||
+                                               h != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height + mon->window_extra_height) {
+                                               changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width = w - mon->window_extra_width;
+                                               changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height = h - mon->window_extra_height;
+                                               set_config_changed();
+                                       }
+                                       if (mon->hStatusWnd)
+                                               SendMessage(mon->hStatusWnd, WM_SIZE, SIZE_RESTORED, MAKELONG(w, h));
+                               }
+                       }
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+static int HitTestToSizingEdge(WPARAM wHitTest)
+{
+       switch (wHitTest)
+       {
+               case HTLEFT:        return WMSZ_LEFT;
+               case HTRIGHT:       return WMSZ_RIGHT;
+               case HTTOP:         return WMSZ_TOP;
+               case HTTOPLEFT:     return WMSZ_TOPLEFT;
+               case HTTOPRIGHT:    return WMSZ_TOPRIGHT;
+               case HTBOTTOM:      return WMSZ_BOTTOM;
+               case HTBOTTOMLEFT:  return WMSZ_BOTTOMLEFT;
+               case HTBOTTOMRIGHT: return WMSZ_BOTTOMRIGHT;
+               case HTCAPTION:         return -1;
+       }
+       return 0;
+}
+
+static int inresizing;
+static int nSizingEdge;
+static POINT ptResizePos;
+static RECT rcResizeStartWindowRect;
+
+static void StartCustomResize(AmigaMonitor *mon, HWND hWindow, int nEdge, int x, int y)
+{
+       inresizing = TRUE;
+       SetCapture(hWindow);
+       nSizingEdge = nEdge;
+       ptResizePos.x = x;
+       ptResizePos.y = y;
+       GetWindowRect(hWindow, &rcResizeStartWindowRect);
+       getsizemove(mon);
+}
+
+static void CustomResizeMouseMove(AmigaMonitor *mon, HWND hWindow)
+{
+       POINT pt;
+       GetCursorPos(&pt);
+       if (pt.x != ptResizePos.x || pt.y != ptResizePos.y) {
+               RECT r;
+               GetWindowRect(hWindow, &r);
+               int x = r.left;
+               int y = r.top;
+               int w = r.right - r.left;
+               int h = r.bottom - r.top;
+               int dx = pt.x - ptResizePos.x;
+               int dy = pt.y - ptResizePos.y;
+               bool changed = true;
+               switch (nSizingEdge)
+               {
+                       case WMSZ_TOP:
+                               y = pt.y;
+                               h -= dy;
+                               break;
+                       case WMSZ_BOTTOM:
+                               h += dy;
+                               break;
+                       case WMSZ_LEFT:
+                               x = pt.x;
+                               w -= dx;
+                               break;
+                       case WMSZ_RIGHT:
+                               w += dx;
+                               break;
+                       case WMSZ_TOPLEFT:
+                               x = pt.x;
+                               w -= dx;
+                               y = pt.y;
+                               h -= dy;
+                               break;
+                       case WMSZ_TOPRIGHT:
+                               w += dx;
+                               y = pt.y;
+                               h -= dy;
+                               break;
+                       case WMSZ_BOTTOMLEFT:
+                               x = pt.x;
+                               w -= dx;
+                               h += dy;
+                               break;
+                       case WMSZ_BOTTOMRIGHT:
+                               w += dx;
+                               h += dy;
+                               break;
+                       case -1:
+                               x += dx;
+                               y += dy;
+                               break;
+                       default:
+                               changed = false;
+                               break;
+               }
+               if (changed) {
+                       RECT r2;
+                       r2.left = x;
+                       r2.top = y;
+                       r2.right = x + w;
+                       r2.bottom = y + h;
+                       doresizing(mon, nSizingEdge, &r2);
+                       SetWindowPos(hWindow, NULL, r2.left, r2.top, r2.right - r2.left, r2.bottom - r2.top, 0);
+               }
+               ptResizePos.x = pt.x;
+               ptResizePos.y = pt.y;
+       }
+}
+
+static void EndCustomResize(HWND hWindow, BOOL bCanceled)
+{
+       inresizing = false;
+       ReleaseCapture();
+       if (bCanceled) {
+               SetWindowPos(hWindow, NULL, rcResizeStartWindowRect.left, rcResizeStartWindowRect.top,
+                       rcResizeStartWindowRect.right - rcResizeStartWindowRect.left, rcResizeStartWindowRect.bottom - rcResizeStartWindowRect.top,
+                       SWP_NOZORDER | SWP_NOACTIVATE);
+       }
+}
+
+
 #define MSGDEBUG 1
 
 static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -1940,7 +2148,7 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
                }
                return 0;
        case WM_SIZING:
-               resizing(mon, wParam, (RECT*)lParam);
+               doresizing(mon, wParam, (RECT*)lParam);
                return TRUE;
        case WM_ACTIVATE:
                //write_log(_T("WM_ACTIVATE %p %x\n"), hWnd, wParam);
@@ -1977,8 +2185,15 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
 
        case WM_KEYDOWN:
                if (!hGUIWnd) {
-                       if (dinput_wmkey((uae_u32)lParam)) {
-                               inputdevice_add_inputcode(AKS_ENTERGUI, 1, NULL);
+                       if (inresizing) {
+                               if (wParam == VK_ESCAPE) {
+                                       EndCustomResize(hWnd, TRUE);
+                                       return 0;
+                               }
+                       } else {
+                               if (dinput_wmkey((uae_u32)lParam)) {
+                                       inputdevice_add_inputcode(AKS_ENTERGUI, 1, NULL);
+                               }
                        }
                } else {
                        int scancode = (lParam >> 16) & 0xff;
@@ -1991,14 +2206,20 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
                return 0;
 
        case WM_LBUTTONUP:
-               if (!rp_mouseevent(-32768, -32768, 0, 1)) {
-                       if (dinput_winmouse() >= 0 && isfocus()) {
-                               if (log_winmouse)
-                                       write_log(_T("WM_LBUTTONUP\n"));
-                               setmousebuttonstate(dinput_winmouse(), 0, 0);
+               if (inresizing) {
+                       EndCustomResize(hWnd, FALSE);
+                       return 0;
+               } else {
+                       if (!rp_mouseevent(-32768, -32768, 0, 1)) {
+                               if (dinput_winmouse() >= 0 && isfocus()) {
+                                       if (log_winmouse)
+                                               write_log(_T("WM_LBUTTONUP\n"));
+                                       setmousebuttonstate(dinput_winmouse(), 0, 0);
+                               }
                        }
+                       return 0;
                }
-               return 0;
+               break;
        case WM_LBUTTONDOWN:
        case WM_LBUTTONDBLCLK:
                if (!rp_mouseevent(-32768, -32768, 1, 1)) {
@@ -2255,66 +2476,70 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
 
        case WM_MOUSEMOVE:
        {
-               int wm = dinput_winmouse();
-
-               monitor_off = 0;
-               if (!mouseinside) {
-                       //write_log(_T("mouseinside\n"));
-                       TRACKMOUSEEVENT tme = { 0 };
-                       mouseinside = true;
-                       tme.cbSize = sizeof tme;
-                       tme.dwFlags = TME_LEAVE;
-                       tme.hwndTrack = mon->hAmigaWnd;
-                       TrackMouseEvent(&tme);
-               }
+               if (inresizing) {
+                       CustomResizeMouseMove(mon, hWnd);
+               } else {
+                       int wm = dinput_winmouse();
+
+                       monitor_off = 0;
+                       if (!mouseinside) {
+                               //write_log(_T("mouseinside\n"));
+                               TRACKMOUSEEVENT tme = { 0 };
+                               mouseinside = true;
+                               tme.cbSize = sizeof tme;
+                               tme.dwFlags = TME_LEAVE;
+                               tme.hwndTrack = mon->hAmigaWnd;
+                               TrackMouseEvent(&tme);
+                       }
 
-               mx = (signed short)LOWORD(lParam);
-               my = (signed short)HIWORD(lParam);
+                       mx = (signed short)LOWORD(lParam);
+                       my = (signed short)HIWORD(lParam);
 
-               if (log_winmouse)
-                       write_log (_T("WM_MOUSEMOVE MON=%d NUM=%d ACT=%d FOCUS=%d CLIP=%d FS=%d %dx%d %dx%d\n"),
-                               mon->monitor_id, wm, mouseactive, focus, mon_cursorclipped, isfullscreen (), mx, my, mon->mouseposx, mon->mouseposy);
+                       if (log_winmouse)
+                               write_log (_T("WM_MOUSEMOVE MON=%d NUM=%d ACT=%d FOCUS=%d CLIP=%d FS=%d %dx%d %dx%d\n"),
+                                       mon->monitor_id, wm, mouseactive, focus, mon_cursorclipped, isfullscreen (), mx, my, mon->mouseposx, mon->mouseposy);
 
-               if (rp_mouseevent(mx, my, -1, -1))
-                       return 0;
+                       if (rp_mouseevent(mx, my, -1, -1))
+                               return 0;
 
-               mx -= mon->mouseposx;
-               my -= mon->mouseposy;
+                       mx -= mon->mouseposx;
+                       my -= mon->mouseposy;
 
-               if (recapture && isfullscreen() <= 0) {
-                       enablecapture(mon->monitor_id);
-                       return 0;
-               }
+                       if (recapture && isfullscreen() <= 0) {
+                               enablecapture(mon->monitor_id);
+                               return 0;
+                       }
 
-               if (wm < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) {
-                       /* absolute */
-                       setmousestate(0, 0, mx, 1);
-                       setmousestate(0, 1, my, 1);
-                       return 0;
-               }
-               if (wm >= 0) {
-                       if (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK) {
+                       if (wm < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) {
                                /* absolute */
-                               setmousestate(dinput_winmouse(), 0, mx, 1);
-                               setmousestate(dinput_winmouse(), 1, my, 1);
+                               setmousestate(0, 0, mx, 1);
+                               setmousestate(0, 1, my, 1);
                                return 0;
                        }
-                       if (!focus || !mouseactive)
-                               return DefWindowProc(hWnd, message, wParam, lParam);
-                       /* relative */
-                       int mxx = (mon->amigawinclip_rect.left - mon->amigawin_rect.left) + (mon->amigawinclip_rect.right - mon->amigawinclip_rect.left) / 2;
-                       int myy = (mon->amigawinclip_rect.top - mon->amigawin_rect.top) + (mon->amigawinclip_rect.bottom - mon->amigawinclip_rect.top) / 2;
-                       mx = mx - mxx;
-                       my = my - myy;
-                       setmousestate(dinput_winmouse(), 0, mx, 0);
-                       setmousestate(dinput_winmouse(), 1, my, 0);
-               } else if (isfocus() < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) {
-                       setmousestate(0, 0, mx, 1);
-                       setmousestate(0, 1, my, 1);
-               }
-               if (mon_cursorclipped || mouseactive)
-                       setcursor(mon, LOWORD(lParam), HIWORD(lParam));
-               return 0;
+                       if (wm >= 0) {
+                               if (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK) {
+                                       /* absolute */
+                                       setmousestate(dinput_winmouse(), 0, mx, 1);
+                                       setmousestate(dinput_winmouse(), 1, my, 1);
+                                       return 0;
+                               }
+                               if (!focus || !mouseactive)
+                                       return DefWindowProc(hWnd, message, wParam, lParam);
+                               /* relative */
+                               int mxx = (mon->amigawinclip_rect.left - mon->amigawin_rect.left) + (mon->amigawinclip_rect.right - mon->amigawinclip_rect.left) / 2;
+                               int myy = (mon->amigawinclip_rect.top - mon->amigawin_rect.top) + (mon->amigawinclip_rect.bottom - mon->amigawinclip_rect.top) / 2;
+                               mx = mx - mxx;
+                               my = my - myy;
+                               setmousestate(dinput_winmouse(), 0, mx, 0);
+                               setmousestate(dinput_winmouse(), 1, my, 0);
+                       } else if (isfocus() < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) {
+                               setmousestate(0, 0, mx, 1);
+                               setmousestate(0, 1, my, 1);
+                       }
+                       if (mon_cursorclipped || mouseactive)
+                               setcursor(mon, LOWORD(lParam), HIWORD(lParam));
+                       return 0;
+               }
        }
        break;
 
@@ -2615,23 +2840,6 @@ static LRESULT CALLBACK AmigaWindowProc(HWND hWnd, UINT message, WPARAM wParam,
        return DefWindowProc (hWnd, message, wParam, lParam);
 }
 
-static int canstretch(struct AmigaMonitor *mon)
-{
-       if (isfullscreen () != 0)
-               return 0;
-       if (!WIN32GFX_IsPicassoScreen(mon)) {
-               if (!currprefs.gfx_windowed_resize)
-                       return 0;
-               if (currprefs.gf[GF_NORMAL].gfx_filter_autoscale == AUTOSCALE_RESIZE)
-                       return 0;
-               return 1;
-       } else {
-               if (currprefs.win32_rtgallowscaling || currprefs.gf[GF_RTG].gfx_filter_autoscale)
-                       return 1;
-       }
-       return 0;
-}
-
 static void plot (LPDRAWITEMSTRUCT lpDIS, int x, int y, int dx, int dy, int idx)
 {
        COLORREF rgb;
@@ -2772,11 +2980,7 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
 
        case WM_ENTERSIZEMOVE:
                mon->in_sizemove++;
-               mon->ratio_width = mon->amigawin_rect.right - mon->amigawinclip_rect.left;
-               mon->ratio_height = mon->amigawin_rect.bottom - mon->amigawinclip_rect.top;
-               mon->ratio_adjust_x = mon->ratio_width - (mon->mainwin_rect.right - mon->mainwin_rect.left);
-               mon->ratio_adjust_y = mon->ratio_height - (mon->mainwin_rect.bottom - mon->mainwin_rect.top);
-               mon->ratio_sizing = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
+               getsizemove(mon);
                break;
 
        case WM_EXITSIZEMOVE:
@@ -2785,58 +2989,7 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
 
        case WM_WINDOWPOSCHANGED:
                {
-                       if (isfullscreen () > 0)
-                               break;
-                       if (mon->in_sizemove > 0)
-                               break;
-                       int iconic = IsIconic (hWnd);
-                       if (mon->hAmigaWnd && hWnd == mon->hMainWnd && !iconic) {
-                               //write_log (_T("WM_WINDOWPOSCHANGED MAIN\n"));
-                               GetWindowRect(mon->hMainWnd, &mon->mainwin_rect);
-                               updatewinrect(mon, false);
-                               updatemouseclip(mon);
-                               if (minimized) {
-                                       unsetminimized(mon->monitor_id);
-                                       winuae_active(mon, mon->hAmigaWnd, minimized);
-                               }
-                               if (isfullscreen() == 0) {
-                                       static int store_xy;
-                                       RECT rc2;
-                                       if (GetWindowRect (mon->hMainWnd, &rc2)) {
-                                               DWORD left = rc2.left - mon->win_x_diff;
-                                               DWORD top = rc2.top - mon->win_y_diff;
-                                               DWORD width = rc2.right - rc2.left;
-                                               DWORD height = rc2.bottom - rc2.top;
-                                               if (store_xy++) {
-                                                       if (!mon->monitor_id) {
-                                                               regsetint(NULL, _T("MainPosX"), left);
-                                                               regsetint(NULL, _T("MainPosY"), top);
-                                                       } else {
-                                                               TCHAR buf[100];
-                                                               _stprintf(buf, _T("MainPosX_%d"), mon->monitor_id);
-                                                               regsetint(NULL, buf, left);
-                                                               _stprintf(buf, _T("MainPosY_%d"), mon->monitor_id);
-                                                               regsetint(NULL, buf, top);
-                                                       }
-                                               }
-                                               changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.x = left;
-                                               changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.y = top;
-                                               if (canstretch(mon)) {
-                                                       int w = mon->mainwin_rect.right - mon->mainwin_rect.left;
-                                                       int h = mon->mainwin_rect.bottom - mon->mainwin_rect.top;
-                                                       if (w != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width + mon->window_extra_width ||
-                                                               h != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height + mon->window_extra_height) {
-                                                                       changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width = w - mon->window_extra_width;
-                                                                       changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height = h - mon->window_extra_height;
-                                                                       set_config_changed();
-                                                       }
-                                               }
-                                       }
-                                       if (mon->hStatusWnd)
-                                               SendMessage(mon->hStatusWnd, WM_SIZE, wParam, lParam);
-                                       return 0;
-                               }
-                       }
+                       setsizemove(mon, hWnd);
                }
                break;
 
@@ -2991,7 +3144,35 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
                }
                break;
        }
-       
+
+       case WM_NCLBUTTONDOWN:
+       {
+               switch (wParam)
+               {
+                       case HTLEFT:
+                       case HTRIGHT:
+                       case HTTOP:
+                       case HTTOPLEFT:
+                       case HTTOPRIGHT:
+                       case HTBOTTOM:
+                       case HTBOTTOMLEFT:
+                       case HTBOTTOMRIGHT:
+                       case HTCAPTION:
+                               if (canstretch(mon)) {
+                                       SetForegroundWindow(hWnd);
+                                       StartCustomResize(mon, hWnd, HitTestToSizingEdge(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+                                       return 0;
+                               }
+                               break;
+               }
+               break;
+       }
+       case WM_CANCELMODE:
+               if (inresizing) {
+                       EndCustomResize(hWnd, FALSE);
+               }
+               break;
+
        default:
                break;
 
index c379f286fac2a727309eada0831f53a967c91632..e331f3f6acadd9cf7268ee4fee87b66f0230380e 100644 (file)
@@ -385,8 +385,8 @@ void getfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int
                        }
 
                        if (scalemode == AUTOSCALE_INTEGER || scalemode == AUTOSCALE_INTEGER_AUTOSCALE) {
-                               int maxw = gmc->gfx_size.width;
-                               int maxh = gmc->gfx_size.height;
+                               int maxw = isfullscreen() < 0 ? deskw : gmc->gfx_size.width;
+                               int maxh = isfullscreen() < 0 ? deskh : gmc->gfx_size.height;
                                float mult = 1.0f;
                                bool ok = true;
 
index db96cf6477591f5c30a083d36c76e5622f9ec876..8f98738daa57c8f1809d9bda315297020359bbfc 100644 (file)
@@ -62,6 +62,9 @@
 #endif
 #include "statusline.h"
 #include "devices.h"
+#ifdef WITH_MIDIEMU
+#include "midiemu.h"
+#endif
 
 #include "darkmode.h"
 
@@ -2003,11 +2006,6 @@ static int open_windows(struct AmigaMonitor *mon, bool mousecapture, bool starte
        mon->in_sizemove = 0;
 
        updatewinfsmode(mon->monitor_id, &currprefs);
-#ifdef D3D
-       gfx_lock();
-       D3D_free(mon->monitor_id, false);
-       gfx_unlock();
-#endif
 
        int init_round = 0;
        ret = -2;
@@ -3046,6 +3044,7 @@ static void updatepicasso96(struct AmigaMonitor *mon)
 void gfx_set_picasso_modeinfo(int monid, RGBFTYPE rgbfmt)
 {
        struct AmigaMonitor *mon = &AMonitors[monid];
+       struct picasso96_state_struct *state = &picasso96_state[mon->monitor_id];
        int need;
        if (!mon->screen_is_picasso)
                return;
@@ -3056,13 +3055,12 @@ void gfx_set_picasso_modeinfo(int monid, RGBFTYPE rgbfmt)
        if (need > 0) {
                open_screen(mon);
        } else if (need < 0) {
-               struct picasso96_state_struct *state = &picasso96_state[mon->monitor_id];
                struct winuae_currentmode *wc = &mon->currentmode;
-               if (state->Width != wc->native_width || state->Width != wc->current_width ||
-                       state->Height != wc->native_height || state->Height != wc->current_height) {
+               if (state->ModeChanged) {
                        open_windows(mon, true, true);
                }
        }
+       state->ModeChanged = false;
 #ifdef RETROPLATFORM
        rp_set_hwnd(mon->hAmigaWnd);
 #endif
@@ -3203,6 +3201,7 @@ static void createstatuswindow(struct AmigaMonitor *mon)
        if (mon->hStatusWnd) {
                ShowWindow(mon->hStatusWnd, SW_HIDE);
                DestroyWindow(mon->hStatusWnd);
+               mon->hStatusWnd = NULL;
        }
        if (currprefs.win32_statusbar == 0 || mon->monitor_id > 0)
                return;
@@ -3546,7 +3545,7 @@ static int create_windows(struct AmigaMonitor *mon)
 #endif
                GetWindowRect (mon->hAmigaWnd, &r);
 
-               int sbheight = currprefs.win32_statusbar ? getstatuswindowheight(mon->monitor_id, mon->hAmigaWnd) : 0;
+               int sbheight = currprefs.win32_statusbar && !currprefs.win32_borderless ? getstatuswindowheight(mon->monitor_id, mon->hAmigaWnd) : 0;
                int dpi = getdpiforwindow(mon->hAmigaWnd);
 
                x = r.left;
@@ -3640,6 +3639,10 @@ static int create_windows(struct AmigaMonitor *mon)
                return 1;
        }
 
+       gfx_lock();
+       D3D_free(mon->monitor_id, false);
+       gfx_unlock();
+
        if (fsw && !borderless)
                borderless = 1;
        window_led_drives = 0;
@@ -3647,7 +3650,7 @@ static int create_windows(struct AmigaMonitor *mon)
        mon->hMainWnd = NULL;
        x = 0; y = 0;
 
-       int sbheight = currprefs.win32_statusbar ? getstatuswindowheight(mon->monitor_id, NULL) : 0;
+       int sbheight = currprefs.win32_statusbar && !currprefs.win32_borderless ? getstatuswindowheight(mon->monitor_id, NULL) : 0;
 
        if (borderless)
                sbheight = cyborder = 0;
@@ -4011,8 +4014,10 @@ retry:
        }
 
        S2X_free(mon->monitor_id);
-       for (int i = 0; i < MAX_AMIGAMONITORS; i++) {
-               oldtex_w[i] = oldtex_h[i] = -1;
+       if (!D3D_isenabled(mon->monitor_id)) {
+               for (int i = 0; i < MAX_AMIGAMONITORS; i++) {
+                       oldtex_w[i] = oldtex_h[i] = -1;
+               }
        }
        if (mon->currentmode.flags & DM_D3D) {
                int fmh = mon->screen_is_picasso ? 1 : currprefs.gf[ad->gf_index].gfx_filter_filtermodeh + 1;
index 316777504b1f9a6bf9c1b0160a5b68e356f7ede6..2c9e5ea22eb1109be665288055b340c6461c3523 100644 (file)
@@ -208,7 +208,7 @@ bool isguiactive(void)
 }
 
 static const int defaultaspectratios[] = {
-               5, 4, 4, 3, 16, 10, 15, 9, 27, 16, 128, 75, 16, 9, 256, 135, 21, 9, 16, 3,
+               5, 4, 4, 3, 16, 10, 15, 9, 27, 16, 128, 75, 16, 9, 256, 135, 21, 9, 32, 9, 16, 3,
                -1
 };
 static int getaspectratioindex (int ar)
@@ -408,6 +408,11 @@ static int gui_get_string_cursor(int *table, HWND hDlg, int item)
 
 static INT_PTR commonproc2(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam, bool *handled)
 {
+       if (dialog_inhibit) {
+               *handled = true;
+               return FALSE;
+       }
+
        if (msg == WM_INITDIALOG) {
                darkmode_initdialog(hDlg);
        } else if (msg == WM_CTLCOLORDLG || msg == WM_CTLCOLORSTATIC) {
@@ -425,6 +430,12 @@ static INT_PTR commonproc2(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam, bo
 static INT_PTR commonproc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam, bool *handled)
 {
        *handled = false;
+
+       if (dialog_inhibit) {
+               *handled = true;
+               return FALSE;
+       }
+
        if (msg == WM_DPICHANGED) {
                RECT *const r = (RECT *)lParam;
                SetWindowPos(hDlg, NULL, r->left, r->top, r->right - r->left, r->bottom - r->top, SWP_NOZORDER | SWP_NOACTIVATE);
@@ -440,9 +451,6 @@ static INT_PTR commonproc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam, boo
 
 static INT_PTR CALLBACK StringBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -1780,9 +1788,6 @@ static bool infoboxdialogstate;
 static HWND infoboxhwnd;
 static INT_PTR CALLBACK InfoBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -5765,9 +5770,6 @@ static INT_PTR CALLBACK InfoSettingsProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
 {
        static int recursive = 0;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -5837,10 +5839,12 @@ static INT_PTR CALLBACK InfoSettingsProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
                        case IDOK:
                        customdialogactive = -1;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                        case IDCANCEL:
                        customdialogactive = 0;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                        case IDC_CONFIGAUTO:
                        if (configtypepanel > 0) {
@@ -6335,9 +6339,6 @@ static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
        static int recursive;
        static struct ConfigStruct *config;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -6471,9 +6472,6 @@ static INT_PTR CALLBACK ErrorLogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 {
        TCHAR *err;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -6545,9 +6543,6 @@ static TCHAR szContributors[MAX_CONTRIBUTORS_LENGTH * 2];
 
 static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -6937,9 +6932,6 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        int val, selpath = 0;
        TCHAR tmp[MAX_DPATH];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -7783,9 +7775,6 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L
        static int doinit;
        int val;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -8020,9 +8009,6 @@ static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 {
        static HFONT font1, font2;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -8036,16 +8022,12 @@ static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                        pages[ABOUT_ID] = hDlg;
                        currentpage = ABOUT_ID;
 
-                       if (!font1) {
-                               font1 = CreateFont(-getscaledfontsize(60), 0, 0, 0, 0,
-                                       0, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
-                                       PROOF_QUALITY, FF_DONTCARE, _T("Segoe UI"));
-                       }
-                       if (!font2) {
-                               font2 = CreateFont(-getscaledfontsize(32), 0, 0, 0, 0,
-                                       0, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
-                                       PROOF_QUALITY, FF_DONTCARE, _T("Segoe UI"));
-                       }
+                       font1 = CreateFont(getscaledfontsize(60), 0, 0, 0, 0,
+                               0, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
+                               PROOF_QUALITY, FF_DONTCARE, _T("Segoe UI"));
+                       font2 = CreateFont(getscaledfontsize(32), 0, 0, 0, 0,
+                               0, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
+                               PROOF_QUALITY, FF_DONTCARE, _T("Segoe UI"));
 
                        HWND hwnd = GetDlgItem(hDlg, IDC_RICHEDIT1);
                        SendMessage(hwnd, WM_SETFONT, (WPARAM)font1, 0);
@@ -8058,7 +8040,7 @@ static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                                hwnd = GetDlgItem(hDlg, urls[i].id);
                                SendMessage(hwnd, WM_SETFONT, (WPARAM)font2, 0);
                                SetWindowText(hwnd, urls[i].display);
-                       }               break;
+                       }
                        return TRUE;
                }
        case WM_COMMAND:
@@ -8072,6 +8054,12 @@ static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        case WM_MOUSEMOVE:
                url_handler(hDlg, msg, wParam, lParam);
                break;
+       case WM_DESTROY:
+               DeleteObject(font1);
+               font1 = NULL;
+               DeleteObject(font2);
+               font2 = NULL;
+               break;
        }
 
        return FALSE;
@@ -9075,9 +9063,6 @@ static INT_PTR CALLBACK DisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
 {
        static int recursive = 0;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -9331,9 +9316,6 @@ static INT_PTR CALLBACK ChipsetDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
        static int recursive = 0;
        TCHAR buffer[MAX_DPATH], tmp[MAX_DPATH];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -9750,9 +9732,6 @@ static INT_PTR CALLBACK ChipsetDlgProc2 (HWND hDlg, UINT msg, WPARAM wParam, LPA
        static int recursive = 0;
        TCHAR tmp[MAX_DPATH];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -11281,9 +11260,6 @@ static INT_PTR CALLBACK Expansion2DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LP
        TCHAR tmp[MAX_DPATH];
        static int recursive = 0;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -11679,9 +11655,6 @@ static INT_PTR CALLBACK ExpansionDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        static int recursive = 0;
        static int enumerated;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -11988,9 +11961,6 @@ static INT_PTR CALLBACK BoardsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        static int recursive = 0;
        static int selected = -1;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -12135,9 +12105,6 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
        static int recursive = 0;
        int v;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -12546,9 +12513,6 @@ static INT_PTR CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        static int recursive;
        TCHAR tmp[MAX_DPATH];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -13751,9 +13715,6 @@ static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
        static int recursive = 0;
        int idx;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -14292,9 +14253,6 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        int numdevs;
        int card, i;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -14563,9 +14521,6 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
 {
        static int recursive = 0;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -14665,10 +14620,12 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
                        case IDOK:
                                customdialogactive = -1;
                                DestroyWindow(hDlg);
+                               recursive = 0;
                                return TRUE;
                        case IDCANCEL:
                                customdialogactive = 0;
                                DestroyWindow(hDlg);
+                               recursive = 0;
                                return TRUE;
                        }
                }
@@ -15171,9 +15128,6 @@ static INT_PTR CALLBACK TapeDriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara
        int posn, readonly;
        TCHAR tmp[MAX_DPATH];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -15277,10 +15231,12 @@ static INT_PTR CALLBACK TapeDriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara
                case IDOK:
                        customdialogactive = -1;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                case IDCANCEL:
                        customdialogactive = 0;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                }
                current_tapedlg.ci.readonly = !ischecked (hDlg, IDC_TAPE_RW);
@@ -15295,9 +15251,6 @@ static INT_PTR CALLBACK CDDriveSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
        static int recursive = 0;
        int posn;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -15345,10 +15298,12 @@ static INT_PTR CALLBACK CDDriveSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
                case IDOK:
                        customdialogactive = -1;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                case IDCANCEL:
                        customdialogactive = 0;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                case IDC_HDF_CONTROLLER:
                        posn = gui_get_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER);
@@ -15410,9 +15365,6 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
        int v;
        int *p;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -15588,10 +15540,12 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
                case IDOK:
                        customdialogactive = -1;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                case IDCANCEL:
                        customdialogactive = 0;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                case IDC_HDF_PHYSGEOMETRY:
                        current_hfdlg.ci.physical_geometry = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY);
@@ -15706,9 +15660,6 @@ static INT_PTR CALLBACK HarddriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara
        int posn;
        static int oposn;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -15780,10 +15731,12 @@ static INT_PTR CALLBACK HarddriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara
                        case IDOK:
                                customdialogactive = -1;
                                DestroyWindow(hDlg);
+                               recursive = 0;
                                return TRUE;
                        case IDCANCEL:
                                customdialogactive = 0;
                                DestroyWindow(hDlg);
+                               recursive = 0;
                                return TRUE;
                        case IDC_HDF_PHYSGEOMETRY:
                                current_hfdlg.ci.physical_geometry = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY);
@@ -16265,9 +16218,6 @@ static void harddiskdlg_volume_notify (HWND hDlg, NM_LISTVIEW *nmlistview)
 /* harddisk parent view */
 static INT_PTR CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -17036,9 +16986,6 @@ static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
        static TCHAR diskname[40] = { _T("") };
        static int dropopen;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -17374,9 +17321,6 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
        static int entry;
        TCHAR tmp[MAX_DPATH];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -18221,14 +18165,16 @@ static void init_portsdlg (HWND hDlg)
        xSendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_RESETCONTENT, 0, 0L);
        xSendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_ADDSTRING, 0, (LPARAM)szNone.c_str());
        for (port = 0; port < MAX_MIDI_PORTS && midioutportinfo[port]; port++) {
-               xSendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_ADDSTRING, 0, (LPARAM)midioutportinfo[port]->name);
+               TCHAR *n = midioutportinfo[port]->label ? midioutportinfo[port]->label : midioutportinfo[port]->name;
+               xSendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_ADDSTRING, 0, (LPARAM)n);
        }
        ew (hDlg, IDC_MIDIOUTLIST, port > 0);
 
        xSendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_RESETCONTENT, 0, 0L);
        xSendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_ADDSTRING, 0, (LPARAM)szNone.c_str());
        for (port = 0; port < MAX_MIDI_PORTS && midiinportinfo[port]; port++) {
-               xSendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_ADDSTRING, 0, (LPARAM)midiinportinfo[port]->name);
+               TCHAR *n = midiinportinfo[port]->label ? midiinportinfo[port]->label : midiinportinfo[port]->name;
+               xSendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_ADDSTRING, 0, (LPARAM)n);
        }
        bNoMidiIn = port == 0;
        ew (hDlg, IDC_MIDIINLIST, port > 0);
@@ -18257,9 +18203,6 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        static int first;
        int temp;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -18480,9 +18423,6 @@ static INT_PTR CALLBACK IOPortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
 {
        static int recursive = 0;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -19410,7 +19350,7 @@ static void handlerawinput (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
        if (msg == WM_INPUT) {
                handle_rawinput (lParam);
-               DefWindowProc (hDlg, msg, wParam, lParam);
+               DefWindowProc(hDlg, msg, wParam, lParam);
        }
 }
 
@@ -19562,10 +19502,12 @@ static INT_PTR CALLBACK RemapSpecialsProc(HWND hDlg, UINT msg, WPARAM wParam, LP
        case IDOK:
        customdialogactive = -1;
        DestroyWindow(hDlg);
+       recursive = 0;
        return TRUE;
        case IDCANCEL:
        customdialogactive = 0;
        DestroyWindow(hDlg);
+       recursive = 0;
        return TRUE;
        }
        recursive--;
@@ -19581,9 +19523,6 @@ static void input_remapspecials(HWND hDlg)
 
 static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -19898,9 +19837,6 @@ static void qualifierlistview (HWND list)
 
 static INT_PTR CALLBACK QualifierProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR v = commonproc(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -20002,10 +19938,12 @@ static INT_PTR CALLBACK QualifierProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
                case IDOK:
                        customdialogactive = -1;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                case IDCANCEL:
                        customdialogactive = 0;
                        DestroyWindow(hDlg);
+                       recursive = 0;
                        return TRUE;
                }
                recursive--;
@@ -20101,9 +20039,6 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        int items = 0, entry = 0;
        static int recursive;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -21056,9 +20991,6 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        static int filteroverlaypos = -1;
        static bool firstinit;
        
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -21552,9 +21484,6 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        static int recursive = 0;
        TCHAR tmp[1000];
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -22664,6 +22593,115 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int       currentpage)
        return ret;
 }
 
+static int HitTestToSizingEdge(WPARAM wHitTest)
+{
+       switch (wHitTest)
+       {
+               case HTLEFT:        return WMSZ_LEFT;
+               case HTRIGHT:       return WMSZ_RIGHT;
+               case HTTOP:         return WMSZ_TOP;
+               case HTTOPLEFT:     return WMSZ_TOPLEFT;
+               case HTTOPRIGHT:    return WMSZ_TOPRIGHT;
+               case HTBOTTOM:      return WMSZ_BOTTOM;
+               case HTBOTTOMLEFT:  return WMSZ_BOTTOMLEFT;
+               case HTBOTTOMRIGHT: return WMSZ_BOTTOMRIGHT;
+       }
+       return 0;
+}
+
+
+static bool gui_resizing;
+static int nSizingEdge;
+static POINT ptResizePos;
+static RECT rcResizeStartWindowRect;
+
+static void StartCustomResize(HWND hWindow, int nEdge, int x, int y)
+{
+       gui_resizing = TRUE;
+       SetCapture(hWindow);
+       nSizingEdge = nEdge;
+       ptResizePos.x = x;
+       ptResizePos.y = y;
+       GetWindowRect(hWindow, &rcResizeStartWindowRect);
+}
+
+static void CustomResizeMouseMove(HWND hWindow)
+{
+       POINT pt;
+       GetCursorPos(&pt);
+       if (pt.x != ptResizePos.x || pt.y != ptResizePos.y) {
+               int x = rcResizeStartWindowRect.left;
+               int y = rcResizeStartWindowRect.top;
+               int w, h;
+               int dx = pt.x - ptResizePos.x;
+               int dy = pt.y - ptResizePos.y;
+               getguisize(hWindow, &w, &h);
+               switch (nSizingEdge)
+               {
+                       case WMSZ_TOP:
+                               y = pt.y;
+                               h -= dy;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_BOTTOM:
+                               h += dy;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_LEFT:
+                               x = pt.x;
+                               w -= dx;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_RIGHT:
+                               w += dx;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_TOPLEFT:
+                               x = pt.x;
+                               w -= dx;
+                               y = pt.y;
+                               h -= dy;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_TOPRIGHT:
+                               w += dx;
+                               y = pt.y;
+                               h -= dy;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_BOTTOMLEFT:
+                               x = pt.x;
+                               w -= dx;
+                               h += dy;
+                               gui_size_changed = -1;
+                               break;
+                       case WMSZ_BOTTOMRIGHT:
+                               w += dx;
+                               h += dy;
+                               gui_size_changed = -1;
+                               break;
+               }
+               if (gui_size_changed < 0) {
+                       gui_width = w;
+                       gui_height = h;
+                       SetWindowPos(hWindow, NULL, x, y,w, h, 0);
+               }
+               ptResizePos.x = pt.x;
+               ptResizePos.y = pt.y;
+       }
+}
+
+static void EndCustomResize(HWND hWindow, BOOL bCanceled)
+{
+       gui_resizing = false;
+       ReleaseCapture();
+       if (bCanceled) {
+               SetWindowPos(hWindow, NULL, rcResizeStartWindowRect.left, rcResizeStartWindowRect.top,
+                       rcResizeStartWindowRect.right - rcResizeStartWindowRect.left, rcResizeStartWindowRect.bottom - rcResizeStartWindowRect.top,
+                       SWP_NOZORDER | SWP_NOACTIVATE);
+       }
+}
+
 static int dialogreturn;
 static int devicechangetimer = -1;
 static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -22671,9 +22709,6 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
        static int recursive = 0;
        static int oldwidth, oldheight;
 
-       if (dialog_inhibit)
-               return 0;
-
        bool handled;
        INT_PTR vv = commonproc2(hDlg, msg, wParam, lParam, &handled);
        if (handled) {
@@ -22745,6 +22780,52 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
                        return FALSE;
                }
                break;
+
+       case WM_NCLBUTTONDOWN:
+               switch (wParam)
+               {
+                       case HTLEFT:
+                       case HTRIGHT:
+                       case HTTOP:
+                       case HTTOPLEFT:
+                       case HTTOPRIGHT:
+                       case HTBOTTOM:
+                       case HTBOTTOMLEFT:
+                       case HTBOTTOMRIGHT:
+                               if (gui_resize_enabled)
+                               {
+                                       SetForegroundWindow(hDlg);
+                                       StartCustomResize(hDlg, HitTestToSizingEdge(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+                                       return 0;
+                               }
+                               break;
+               }
+               break;
+
+       case WM_MOUSEMOVE:
+               if (gui_resizing)
+               {
+                       CustomResizeMouseMove(hDlg);
+               }
+               break;
+       case WM_LBUTTONUP:
+               if (gui_resizing) {
+                       EndCustomResize(hDlg, FALSE);
+                       return 0;
+               }
+               break;
+       case WM_CANCELMODE:
+               if (gui_resizing) {
+                       EndCustomResize(hDlg, FALSE);
+               }
+               break;
+       case WM_KEYDOWN:
+               if (gui_resizing && wParam == VK_ESCAPE)
+               {
+                       EndCustomResize(hDlg, TRUE);
+                       return 0;
+               }
+               break;
        case WM_DEVICECHANGE:
                {
                        DEV_BROADCAST_HDR *pBHdr = (DEV_BROADCAST_HDR *)lParam;
@@ -23005,7 +23086,7 @@ int CustomCreateDialogBox(int templ, HWND hDlg, DLGPROC proc)
                                break;
                }
        }
-       return 1;
+       return customdialogactive;
 }
 
 static int init_page (int tmpl, int icon, int title,
@@ -23414,7 +23495,7 @@ static int GetSettings (int all_options, HWND hwnd)
                                }
                                if (dialogreturn >= 0)
                                        break;
-                               if (gui_size_changed > 0) {
+                               if (gui_size_changed) {
                                        saveguisize();
                                        regsetint(NULL, _T("GUIResize"), gui_resize_enabled ? 1 : 0);
                                        regsetint(NULL, _T("GUIFullscreen"), gui_fullscreen > 0 ? 1 : 0);
index 1a88c7f8b378bf0c42c95b1d8d6c67ee231b167e..e628bfeff9448f0dce9be4342ad3ac73bfb81f7b 100644 (file)
@@ -634,15 +634,15 @@ static HWND DIALOG_CreateIndirect(HINSTANCE hInst, LPCVOID dlgTemplate,
                size.cy = res->height;
        }
 
+       HMONITOR monitor = 0;
+       MONITORINFO mon_info;
+
        if (tmpl->x == CW_USEDEFAULT16)
        {
                pos.x = pos.y = CW_USEDEFAULT;
        }
        else
        {
-               HMONITOR monitor = 0;
-               MONITORINFO mon_info;
-
                mon_info.cbSize = sizeof(mon_info);
                if (tmpl->style & DS_CENTER)
                {
@@ -676,6 +676,26 @@ static HWND DIALOG_CreateIndirect(HINSTANCE hInst, LPCVOID dlgTemplate,
                }
        }
 
+       if (tmpl->style & (DS_CENTER | DS_CENTERMOUSE)) {
+               POINT pos2 = pos;
+               pos2.x += size.cx / 2;
+               pos2.y += size.cy / 2;
+               monitor = MonitorFromPoint(pos, MONITOR_DEFAULTTOPRIMARY);
+               GetMonitorInfoW(monitor, &mon_info);
+               if (pos.x + size.cx > mon_info.rcWork.right) {
+                       pos.x = mon_info.rcWork.right - size.cx;
+               }
+               if (pos.y + size.cy > mon_info.rcWork.bottom) {
+                       pos.y = mon_info.rcWork.bottom - size.cy;
+               }
+               if (pos.x < mon_info.rcWork.left) {
+                       pos.x = mon_info.rcWork.left;
+               }
+               if (pos.y < mon_info.rcWork.top) {
+                       pos.y = mon_info.rcWork.top;
+               }
+       }
+
        res->unitx = MulDiv(8, xBaseUnit, 4);
        res->unity = MulDiv(8, yBaseUnit, 8);