Skip to content

Commit 40fbcd6

Browse files
committed
v1.1.0 src
- temporarily disabled wallpaper resizing on screen property change due to alt-tabbing bug when running fullscreen games. - extprogram wallpaper now work for unity and program type without specifying type. - redirected vlc and mpv player message/errors. - removed unused file extensions for video format. - updated some libraries.
1 parent 6c76a43 commit 40fbcd6

20 files changed

+178
-182
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ Help translate lively to other languages: <a href="https://github.com/rocksdanis
8888

8989
**_I'm not officially affiliated with Unity technologies, godot, shadertoy;_**
9090
## Download
91-
##### Latest version: v1.0.8.0 (Windows 10 1903 or above)[What's new?](https://github.com/rocksdanister/lively/releases/tag/v1.0.8.0)
91+
##### Latest version: v1.1.0.0 (Windows 10 1903 or above)[What's new?](https://github.com/rocksdanister/lively/releases/tag/v1.1.0.0)
9292
- [`Download Lively Wallpaper`][direct-full-win32]
9393

94-
[direct-full-win32]: https://github.com/rocksdanister/lively/releases/download/v1.0.8.0/lively_setup_x86_full_v1080.exe
94+
[direct-full-win32]: https://github.com/rocksdanister/lively/releases/download/v1.1.0.0/lively_setup_x86_full_v1100.exe
9595

9696
**Installer will give Smartscreen warning, [discussion.](https://github.com/rocksdanister/lively/issues/9)**
9797

src/installer/Script.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; https://jrsoftware.org/isinfo.php
33

44
#define MyAppName "Lively Wallpaper"
5-
#define MyAppVersion "1.0.7.0"
5+
#define MyAppVersion "1.1.0.0"
66
#define MyAppPublisher "rocksdanister"
77
#define MyAppURL "https://github.com/rocksdanister/lively"
88
#define MyAppExeName "livelywpf.exe"

src/livelywpf/libMPVPlayer/App.xaml.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
1717
{
1818
this.SessionEnding += App_SessionEnding;
1919
var wnd = new MainWindow(e.Args);
20-
//SetupUnhandledExceptionLogging();
20+
SetupUnhandledExceptionLogging();
2121
wnd.Show();
2222
}
2323

@@ -43,7 +43,7 @@ private void SetupUnhandledExceptionLogging()
4343

4444
private void LogUnhandledException(Exception exception, string source)
4545
{
46-
MessageBox.Show(exception.ToString());
46+
Console.WriteLine(exception.Message);
4747
}
4848
}
4949
}

src/livelywpf/libMPVPlayer/MainWindow.xaml.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ private void RunOptions(Options opts)
9797
player.Load(opts.FilePath);
9898
player.Resume();
9999
}
100-
catch (Exception)
100+
catch (Exception e)
101101
{
102-
//todo: pass msg to parent process.
102+
Console.WriteLine(e.Message);
103103
}
104104
finally
105105
{
@@ -109,7 +109,7 @@ private void RunOptions(Options opts)
109109

110110
private void HandleParseError(IEnumerable<Error> errs)
111111
{
112-
//todo: pass msg to parent process.
112+
Console.WriteLine("Error parsing cmdline args, Exiting!");
113113
Application.Current.Shutdown();
114114
}
115115

@@ -134,7 +134,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
134134

135135
private void Player_MediaError1(object sender, System.EventArgs e)
136136
{
137-
//todo: pass msg to parent process.
137+
Console.WriteLine("Media playback Error");
138138
}
139139

140140
public void PausePlayer()
@@ -221,9 +221,9 @@ await Task.Run(async () =>
221221
}
222222
});
223223
}
224-
catch
224+
catch(Exception e)
225225
{
226-
//todo: send error to lively parent program.
226+
Console.WriteLine(e.Message);
227227
}
228228
finally
229229
{

src/livelywpf/libVLCPlayer/App.xaml.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@ public partial class App : Application
1515
{
1616
private void Application_Startup(object sender, StartupEventArgs e)
1717
{
18+
this.SessionEnding += App_SessionEnding;
1819
MainWindow wnd = new MainWindow(e.Args);
19-
//SetupUnhandledExceptionLogging();
20+
SetupUnhandledExceptionLogging();
2021
wnd.Show();
2122
}
2223

24+
private void App_SessionEnding(object sender, SessionEndingCancelEventArgs e)
25+
{
26+
if (e.ReasonSessionEnding == ReasonSessionEnding.Shutdown || e.ReasonSessionEnding == ReasonSessionEnding.Logoff)
27+
{
28+
e.Cancel = true;
29+
}
30+
}
31+
2332
private void SetupUnhandledExceptionLogging()
2433
{
2534
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
@@ -34,7 +43,7 @@ private void SetupUnhandledExceptionLogging()
3443

3544
private void LogUnhandledException(Exception exception, string source)
3645
{
37-
MessageBox.Show(exception.ToString());
46+
Console.WriteLine(exception.Message);
3847
}
3948
}
4049
}

src/livelywpf/libVLCPlayer/MainWindow.xaml.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async void VideoView_Loaded(object sender, RoutedEventArgs e)
5050
Volume = 0
5151
};
5252
_mediaPlayer.EndReached += _mediaPlayer_EndReached;
53+
_mediaPlayer.EncounteredError += _mediaPlayer_EncounteredError;
5354
videoView.MediaPlayer = _mediaPlayer;
5455

5556
if (_isStream)
@@ -66,9 +67,9 @@ async void VideoView_Loaded(object sender, RoutedEventArgs e)
6667
}
6768
_mediaReady = true;
6869
}
69-
catch
70+
catch (Exception ex)
7071
{
71-
//todo: send error to lively parent program.
72+
Console.WriteLine(ex.Message);
7273
}
7374
finally
7475
{
@@ -147,6 +148,11 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
147148
catch { }
148149
}
149150

151+
private void _mediaPlayer_EncounteredError(object sender, EventArgs e)
152+
{
153+
Console.WriteLine("Media playback Error");
154+
}
155+
150156
private void Window_Loaded(object sender, RoutedEventArgs e)
151157
{
152158
IntPtr handle = new WindowInteropHelper(this).Handle;
@@ -208,9 +214,9 @@ await Task.Run(async () =>
208214
}
209215
});
210216
}
211-
catch
217+
catch (Exception e)
212218
{
213-
//todo: send error to lively parent program.
219+
Console.WriteLine(e.Message);
214220
}
215221
finally
216222
{

src/livelywpf/libVLCPlayer/libVLCPlayer.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="LibVLCSharp.WPF" Version="3.4.7" />
19+
<PackageReference Include="LibVLCSharp.WPF" Version="3.4.8" />
2020
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.11" />
2121
</ItemGroup>
2222

src/livelywpf/livelywpf/Core/SetupDesktop.cs

+9-18
Original file line numberDiff line numberDiff line change
@@ -546,52 +546,43 @@ private static void SystemEvents_DisplaySettingsChanged(object sender, EventArgs
546546

547547
private static void UpdateWallpaperRect()
548548
{
549-
//Logger.Info("System parameters changed: wallpaper resizing disabled due to focus bug.");
550-
//return;
551549
NativeMethods.RECT prct = new NativeMethods.RECT();
552550
//Known issues: Buggy if screen dpi is greater than 100% in multiscreen.
553551
//Possible cause: the window being used as reference is not updated to the new dpi in time?
554552
if (ScreenHelper.IsMultiScreen() && Program.SettingsVM.Settings.WallpaperArrangement == WallpaperArrangement.span)
555553
{
556554
if(Wallpapers.Count != 0)
557555
{
558-
//detach wallpaper window from this dialogue.
559-
WindowOperations.SetParentSafe(Wallpapers[0].GetHWND(), IntPtr.Zero);
560-
SetWallpaperSpanScreen(Wallpapers[0].GetHWND(), false);
561-
Wallpapers[0].SetScreen(ScreenHelper.GetPrimaryScreen());
556+
Logger.Info("System parameters changed: Screen Param(Span)");
562557
/*
563558
NativeMethods.GetWindowRect(workerw, out prct); //get spawned workerw rectangle data.
564-
NativeMethods.SetWindowPos(Wallpapers[0].GetHWND(), 1, 0, 0, prct.Right - prct.Left, prct.Bottom - prct.Top, 0 | 0x0010); //fill wp into the whole workerw area.
565-
Wallpapers[0].SetScreen(ScreenHelper.GetPrimaryScreen());
559+
NativeMethods.SetWindowPos(Wallpapers[0].GetHWND(), 1, 0, 0, prct.Right - prct.Left, prct.Bottom - prct.Top, 0 | 0x0010);
566560
*/
561+
Wallpapers[0].SetScreen(ScreenHelper.GetPrimaryScreen());
567562
}
568563
}
569564
else
570565
{
571566
int i;
572567
foreach (var item in ScreenHelper.GetScreen())
573568
{
574-
//Assumption: If number of connected devices is unchanged -> devicename is also unchanged?
575569
if ((i = Wallpapers.FindIndex(x => ScreenHelper.ScreenCompare(item, x.GetScreen(), DisplayIdentificationMode.screenClass))) != -1)
576570
{
577-
Logger.Info("System parameters changed: Screen Param old/new -> " + Wallpapers[i].GetScreen().Bounds + "/" + item.Bounds);
578-
//detach wallpaper window from this dialogue.
579-
WindowOperations.SetParentSafe(Wallpapers[i].GetHWND(), IntPtr.Zero);
580-
SetWallpaperPerScreen(Wallpapers[i].GetHWND(), item, false);
581-
Wallpapers[i].SetScreen(item);
571+
Logger.Info("System parameters changed: Screen Param old/new -> " + Wallpapers[i].GetScreen().Bounds + "/" + item.Bounds);
582572
/*
583-
//Using this window as reference for MapWindowPoints.
584-
Window w = new Window() { Width = 10, Height = 10, ShowActivated = false, ShowInTaskbar = false };
573+
//temporarily disabled due to buggy behaviour exclusive fullscreen game alt-tabbing.
574+
//Using this window as reference for MapWindowPoints.
575+
Window w = new Window() { Width = 0, Height = 0, ShowActivated = false, ShowInTaskbar = false, Focusable = false};
585576
w.Show();
586577
NativeMethods.SetWindowPos(new WindowInteropHelper(w).Handle, 1, item.Bounds.Left, item.Bounds.Top, 0, 0,
587578
(int)NativeMethods.SetWindowPosFlags.SWP_NOACTIVATE | (int)NativeMethods.SetWindowPosFlags.SWP_NOSIZE);
588579
NativeMethods.MapWindowPoints(new WindowInteropHelper(w).Handle, workerw, ref prct, 2);
589580
w.Close();
590-
581+
591582
//Updating position and data of wallpaper.
592583
NativeMethods.SetWindowPos(Wallpapers[i].GetHWND(), 1, prct.Left, prct.Top, (item.Bounds.Width), (item.Bounds.Height), 0 | 0x0010);
593-
Wallpapers[i].SetScreen(item);
594584
*/
585+
Wallpapers[i].SetScreen(item);
595586
}
596587
}
597588
}

src/livelywpf/livelywpf/Core/Wallpapers/ExtPrograms.cs

+42-42
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,14 @@ public class ExtPrograms : IWallpaper
1212
{
1313
public ExtPrograms(string path, LibraryModel model, LivelyScreen display, int timeOut = 20)
1414
{
15-
string cmdArgs;
16-
if (model.LivelyInfo.Type == WallpaperType.unity)
17-
{
18-
//-popupwindow removes from taskbar
19-
//-fullscreen disable fullscreen mode if set during compilation (lively is handling resizing window instead).
20-
//Alternative flags:
21-
//Unity attaches to workerw by itself; Problem: Process window handle is returning zero.
22-
//"-parentHWND " + workerw.ToString();// + " -popupwindow" + " -;
23-
cmdArgs = "-popupwindow -screen-fullscreen 0";
24-
}
25-
else
26-
{
27-
cmdArgs = model.LivelyInfo.Arguments;
28-
}
15+
// Unity flags
16+
//-popupwindow removes from taskbar
17+
//-fullscreen disable fullscreen mode if set during compilation (lively is handling resizing window instead).
18+
//Alternative flags:
19+
//Unity attaches to workerw by itself; Problem: Process window handle is returning zero.
20+
//"-parentHWND " + workerw.ToString();// + " -popupwindow" + " -;
21+
//cmdArgs = "-popupwindow -screen-fullscreen 0";
22+
string cmdArgs = model.LivelyInfo.Arguments;
2923

3024
ProcessStartInfo start = new ProcessStartInfo
3125
{
@@ -92,24 +86,30 @@ public WallpaperType GetWallpaperType()
9286

9387
public void Pause()
9488
{
89+
//Disabled, need further testing.
90+
/*
9591
try
9692
{
9793
ProcessSuspend.SuspendAllThreads(this);
9894
//thread buggy noise otherwise?!
9995
VolumeMixer.SetApplicationMute(Proc.Id, true);
10096
}
10197
catch { }
98+
*/
10299
}
103100

104101
public void Play()
105102
{
103+
//Disabled, need further testing.
104+
/*
106105
try
107106
{
108107
ProcessSuspend.ResumeAllThreads(this);
109108
//thread buggy noise otherwise?!
110109
VolumeMixer.SetApplicationMute(Proc.Id, false);
111110
}
112111
catch { }
112+
*/
113113
}
114114

115115
public void SetHWND(IntPtr hwnd)
@@ -148,13 +148,13 @@ public async void Show()
148148
}
149149
else
150150
{
151-
if(GetWallpaperType() != WallpaperType.unity)
152-
{
153-
WindowOperations.BorderlessWinStyle(HWND);
154-
WindowOperations.RemoveWindowFromTaskbar(HWND);
155-
}
151+
WindowOperations.BorderlessWinStyle(HWND);
152+
WindowOperations.RemoveWindowFromTaskbar(HWND);
156153
//Program ready!
157-
WindowInitialized?.Invoke(this, new WindowInitializedArgs() { Success = true, Error = null, Msg = null });
154+
WindowInitialized?.Invoke(this, new WindowInitializedArgs() {
155+
Success = true,
156+
Error = null,
157+
Msg = null });
158158
}
159159
}
160160
catch(OperationCanceledException e1)
@@ -231,36 +231,36 @@ private async Task<IntPtr> WaitForProcesWindow()
231231
}
232232
return wHWND;
233233
}
234-
else if (GetWallpaperType() == WallpaperType.unity)
234+
235+
//Find process window.
236+
for (int i = 0; i < timeOut && Proc.HasExited == false; i++)
237+
{
238+
ctsProcessWait.Token.ThrowIfCancellationRequested();
239+
if (!IntPtr.Equals((wHWND = GetProcessWindow(Proc, true)), IntPtr.Zero))
240+
break;
241+
await Task.Delay(1);
242+
}
243+
244+
//Player settings dialog of Unity (if exists.)
245+
IntPtr cHWND = NativeMethods.FindWindowEx(wHWND, IntPtr.Zero, "Button", "Play!");
246+
if (!IntPtr.Equals(cHWND, IntPtr.Zero))
235247
{
236-
//Player settings dialog of Unity (if exists.)
248+
//Simulate Play! button click. (Unity config window)
249+
NativeMethods.SendMessage(cHWND, NativeMethods.BM_CLICK, IntPtr.Zero, IntPtr.Zero);
250+
//Refreshing..
251+
wHWND = IntPtr.Zero;
252+
await Task.Delay(1);
253+
254+
//Search for Unity main Window.
237255
for (int i = 0; i < timeOut && Proc.HasExited == false; i++)
238256
{
239257
ctsProcessWait.Token.ThrowIfCancellationRequested();
240258
if (!IntPtr.Equals((wHWND = GetProcessWindow(Proc, true)), IntPtr.Zero))
259+
{
241260
break;
261+
}
242262
await Task.Delay(1);
243263
}
244-
245-
IntPtr cHWND = NativeMethods.FindWindowEx(wHWND, IntPtr.Zero, "Button", "Play!");
246-
if (!IntPtr.Equals(cHWND, IntPtr.Zero))
247-
{
248-
//Simulate Play! button click. (Unity config window)
249-
NativeMethods.SendMessage(cHWND, NativeMethods.BM_CLICK, IntPtr.Zero, IntPtr.Zero);
250-
}
251-
await Task.Delay(1);
252-
//Refresh
253-
wHWND = IntPtr.Zero;
254-
}
255-
256-
for (int i = 0; i < timeOut && Proc.HasExited == false; i++)
257-
{
258-
ctsProcessWait.Token.ThrowIfCancellationRequested();
259-
if (!IntPtr.Equals((wHWND = GetProcessWindow(Proc, true)), IntPtr.Zero))
260-
{
261-
break;
262-
}
263-
await Task.Delay(1);
264264
}
265265
return wHWND;
266266
}

src/livelywpf/livelywpf/Core/Wallpapers/VideoPlayerMPVExt.cs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public VideoPlayerMPVExt(string path, LibraryModel model, LivelyScreen display,
2020
FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", "libMPVPlayer", "libMPVPlayer.exe"),
2121
RedirectStandardInput = true,
2222
RedirectStandardOutput = true,
23+
RedirectStandardError = true,
2324
UseShellExecute = false,
2425
WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", "libMPVPlayer")
2526
};

src/livelywpf/livelywpf/Core/Wallpapers/VideoPlayerVLCExt.cs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public VideoPlayerVLCExt(string path, LibraryModel model, LivelyScreen display)
1919
FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", "libVLCPlayer", "libVLCPlayer.exe"),
2020
RedirectStandardInput = true,
2121
RedirectStandardOutput = true,
22+
RedirectStandardError = true,
2223
UseShellExecute = false,
2324
WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins", "libVLCPlayer")
2425
};

0 commit comments

Comments
 (0)