]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Prevent clipboard activity immediately after mode changes delaying automatic host...
authorToni Wilen <twilen@winuae.net>
Thu, 12 Jul 2018 18:45:48 +0000 (21:45 +0300)
committerToni Wilen <twilen@winuae.net>
Thu, 12 Jul 2018 18:45:48 +0000 (21:45 +0300)
devices.cpp
drawing.cpp
filesys.cpp
include/clipboard.h
include/devices.h
od-win32/clipboard_win32.cpp
od-win32/win32gfx.cpp

index e6760c4e77494f8aa0c75f726e31dc5a861a1eee..bc032020a987d393fd8f320d5baddeadbe6661c9 100644 (file)
@@ -500,3 +500,8 @@ void devices_unpause(void)
        pausevideograb(0);
        ethernet_pause(0);
 }
+
+void devices_unsafeperiod(void)
+{
+       clipboard_unsafeperiod();
+}
index 7c92d3a3a130521fb5299e299b2bc73850d04b19..b55f1479479f07f6f93bbf5ba38508f86ebf68fb 100644 (file)
@@ -3954,6 +3954,8 @@ void check_prefs_picasso(void)
 
                if (ad->picasso_requested_on == ad->picasso_on && !ad->picasso_requested_forced_on)
                        continue;
+                
+               devices_unsafeperiod();
 
                if (!ad->picasso_requested_on && monid > 0) {
                        ad->picasso_requested_on = ad->picasso_on;
index 75b16923ee748e7cc4bc105a521c18181ad1d638..3edd22a2788ed1649efb7a7ddd734458a627ffd0 100644 (file)
@@ -1874,12 +1874,12 @@ int filesys_eject(int nr)
 }
 
 static uae_u32 heartbeat;
-static int heartbeat_count;
+static int heartbeat_count, heartbeat_count_cont;
 static int heartbeat_task;
 
 bool filesys_heartbeat(void)
 {
-       return heartbeat_count > 0;
+       return heartbeat_count_cont > 0;
 }
 
 // This uses filesystem process to reduce resource usage
@@ -9044,9 +9044,12 @@ void filesys_vsync (void)
        if (heartbeat == get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT)) {
                if (heartbeat_count > 0)
                        heartbeat_count--;
+               if (heartbeat_count_cont > 0)
+                       heartbeat_count_cont--;
                return;
        }
        heartbeat = get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT);
+       heartbeat_count_cont = 10;
        cia_heartbeat ();
 
        for (u = units; u; u = u->next) {
index b5f4ae31e62c2321c5d7e0c1de4897f15b1d482c..9e6cb4675bc0d2fcf4dc700f80ae441d27c32829 100644 (file)
@@ -11,5 +11,6 @@ extern uaecptr amiga_clipboard_proc_start(TrapContext *ctx);
 extern void amiga_clipboard_task_start(TrapContext *ctx, uaecptr);
 extern void clipboard_disable(bool);
 extern void clipboard_vsync(void);
+extern void clipboard_unsafeperiod(void);
 
 #endif /* UAE_CLIPBOARD_H */
index bb149b36287ef983da0aee2589582d7030803250..14e784df5b52e0de9f9db8eaa7e51d190aefe793 100644 (file)
@@ -17,6 +17,7 @@ void devices_restore_start(void);
 void device_check_config(void);
 void devices_pause(void);
 void devices_unpause(void);
+void devices_unsafeperiod(void);
 
 #define IRQ_SOURCE_PCI 0
 #define IRQ_SOURCE_SOUND 1
index c6051b9fc9cfcb9ca1fe85e0a266991a0852a968..6d3aad0123da4e9153e87f6db211b6f581b2cc71 100644 (file)
@@ -26,9 +26,11 @@ int clipboard_debug;
 static HWND chwnd;
 static HDC hdc;
 static uaecptr clipboard_data;
-static int vdelay, signaling, initialized;
+static int vdelay, vdelay2;
+static int signaling, initialized;
 static uae_u8 *to_amiga;
 static uae_u32 to_amiga_size;
+static int to_amiga_phase;
 static int clipopen;
 static int clipactive;
 static int clipboard_change;
@@ -67,8 +69,6 @@ static void debugwrite (TrapContext *ctx, const TCHAR *name, uaecptr p, int size
 
 static uae_u32 to_amiga_start_cb(TrapContext *ctx, void *ud)
 {
-       if (!filesys_heartbeat())
-               return 0;
        if (trap_get_long(ctx, clipboard_data) != 0)
                return 0;
        if (clipboard_debug) {
@@ -79,20 +79,18 @@ static uae_u32 to_amiga_start_cb(TrapContext *ctx, void *ud)
 #endif
        trap_put_long(ctx, clipboard_data, to_amiga_size);
        uae_Signal(trap_get_long(ctx, clipboard_data + 8), 1 << 13);
+       to_amiga_phase = 2;
        return 1;
 }
 
 static void to_amiga_start(TrapContext *ctx)
 {
+       to_amiga_phase = 0;
        if (!initialized)
                return;
        if (!clipboard_data)
                return;
-       if (!ctx) {
-               trap_callback(to_amiga_start_cb, NULL);
-       } else {
-               to_amiga_start_cb(ctx, NULL);
-       }
+       to_amiga_phase = 1;
 }
 
 static uae_char *pctoamiga (const uae_char *txt)
@@ -988,21 +986,35 @@ static uae_u32 clipboard_vsync_cb(TrapContext *ctx, void *ud)
 
 void clipboard_vsync(void)
 {
-       if (!signaling || !clipboard_data)
-               return;
        if (!filesys_heartbeat())
                return;
-       vdelay--;
-       if (vdelay > 0)
+       if (!clipboard_data)
                return;
-       trap_callback(clipboard_vsync_cb, NULL);
-       vdelay = 50;
+
+       if (signaling) {
+               vdelay--;
+               if (vdelay > 0)
+                       return;
+
+               trap_callback(clipboard_vsync_cb, NULL);
+               vdelay = 50;
+       }
+
+       if (vdelay2 > 0) {
+               vdelay2--;
+               //write_log(_T("vdelay2 = %d\n"), vdelay2);
+       }
+
+       if (to_amiga_phase == 1 && vdelay2 <= 0) {
+               trap_callback(to_amiga_start_cb, NULL);
+       }
+
 }
 
 void clipboard_reset(void)
 {
        write_log (_T("clipboard: reset (%08x)\n"), clipboard_data);
-       vdelay = 100;
+       clipboard_unsafeperiod();
        clipboard_free_delayed ();
        clipboard_data = 0;
        signaling = 0;
@@ -1010,6 +1022,7 @@ void clipboard_reset(void)
        xfree (to_amiga);
        to_amiga = NULL;
        to_amiga_size = 0;
+       to_amiga_phase = 0;
        clip_disabled = false;
        ReleaseDC (chwnd, hdc);
 }
@@ -1024,3 +1037,11 @@ void target_paste_to_keyboard(void)
 {
        clipboard_read(NULL, chwnd, true);
 }
+
+// force 2 second delay before accepting new data
+void clipboard_unsafeperiod(void)
+{
+       vdelay2 = 100;
+       if (vdelay < 60)
+               vdelay = 60;
+}
index dc74ad9948b3acbb45f9b6b60b8202838f87ca9d..b4e88a2886835e6a99d8bc3d203e210bd9cf208e 100644 (file)
@@ -61,6 +61,7 @@
 #include "rp.h"
 #endif
 #include "statusline.h"
+#include "devices.h"
 
 #define DM_DX_FULLSCREEN 1
 #define DM_W_FULLSCREEN 2
@@ -4287,6 +4288,7 @@ bool toggle_rtg (int monid, int mode)
                                gfxboard_toggle(r->monitor_id, -1, -1);
                                if (mode < -1)
                                        return true;
+                               devices_unsafeperiod();
                                gfxboard_rtg_disable(monid, old_index);
                                // can always switch from RTG to custom
                                if (ad->picasso_requested_on && ad->picasso_on) {
@@ -4360,6 +4362,7 @@ void toggle_fullscreen(int monid, int mode)
                v = GFX_WINDOW;
        }
        *p = v;
+       devices_unsafeperiod();
        updatewinfsmode(monid, &changed_prefs);
 }