Skip to content

Commit 1c18145

Browse files
committed
UX tweak: hide the fullscreen label on click
1 parent 70fe725 commit 1c18145

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

FlashpointSecurePlayer/Shared.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,14 @@ public static void LogExceptionToLauncher(Exception ex) {
159159
public const int WM_DESTROY = 0x00000002;
160160
public const int WM_PAINT = 0x0000000F;
161161
public const int WM_MOUSEMOVE = 0x00000200;
162+
public const int WM_LBUTTONUP = 0x00000202;
163+
public const int WM_RBUTTONUP = 0x00000205;
164+
public const int WM_MBUTTONUP = 0x00000208;
162165
public const int WM_XBUTTONUP = 0x0000020C;
163166
public const int WM_PARENTNOTIFY = 0x00000210;
164167

165-
public const int MK_XBUTTON1 = 0x00010000;
166-
public const int MK_XBUTTON2 = 0x00020000;
168+
public const int XBUTTON1 = 0x00010000;
169+
public const int XBUTTON2 = 0x00020000;
167170

168171
public const int S_OK = unchecked((int)0x00000000);
169172
public const int S_FALSE = unchecked((int)0x00000001);

FlashpointSecurePlayer/WebBrowserMode.cs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ private bool ExitFullscreenLabelTimer {
9494
}
9595

9696
set {
97-
if (exitFullscreenLabelTimer != null) {
97+
if (exitFullscreenLabelTimer == null) {
98+
if (!value) {
99+
// timer not started, already hidden
100+
return;
101+
}
102+
} else {
98103
exitFullscreenLabelTimer.Stop();
99104
exitFullscreenLabelTimer.Tick -= exitFullscreenLabelTimer_Tick;
100105
exitFullscreenLabelTimer.Dispose();
@@ -221,14 +226,26 @@ public bool Fullscreen {
221226
}
222227

223228
private class MessageFilter : IMessageFilter {
229+
private readonly EventHandler stopExitFullscreenLabelTimer;
224230
private readonly EventHandler back;
225231
private readonly EventHandler forward;
226232

227-
public MessageFilter(EventHandler back, EventHandler forward) {
233+
public MessageFilter(EventHandler stopExitFullscreenLabelTimer, EventHandler back, EventHandler forward) {
234+
this.stopExitFullscreenLabelTimer = stopExitFullscreenLabelTimer;
228235
this.back = back;
229236
this.forward = forward;
230237
}
231238

239+
private void OnStopExitFullscreenLabelTimer(EventArgs e) {
240+
EventHandler eventHandler = stopExitFullscreenLabelTimer;
241+
242+
if (eventHandler == null) {
243+
return;
244+
}
245+
246+
eventHandler(this, e);
247+
}
248+
232249
private void OnBack(EventArgs e) {
233250
EventHandler eventHandler = back;
234251

@@ -256,18 +273,25 @@ public bool PreFilterMessage(ref Message m) {
256273
// for example, if there is a popup, the
257274
// mouse buttons shouldn't navigate both the
258275
// main and popup windows
259-
if (m.Msg == WM_XBUTTONUP) {
276+
switch (m.Msg) {
277+
case WM_LBUTTONUP:
278+
case WM_RBUTTONUP:
279+
case WM_MBUTTONUP:
280+
OnStopExitFullscreenLabelTimer(EventArgs.Empty);
281+
return false;
282+
case WM_XBUTTONUP:
260283
int wParam = m.WParam.ToInt32();
261284

262-
if ((wParam & MK_XBUTTON1) == MK_XBUTTON1) {
285+
if ((wParam & XBUTTON1) == XBUTTON1) {
263286
OnBack(EventArgs.Empty);
264287
return true;
265288
}
266289

267-
if ((wParam & MK_XBUTTON2) == MK_XBUTTON2) {
290+
if ((wParam & XBUTTON2) == XBUTTON2) {
268291
OnForward(EventArgs.Empty);
269292
return true;
270293
}
294+
return false;
271295
}
272296
return false;
273297
}
@@ -362,7 +386,7 @@ public WebBrowserMode(bool useFlashActiveXControl = false) {
362386
UseFlashActiveXControl = useFlashActiveXControl;
363387

364388
lowLevelMouseProc = new HookProc(LowLevelMouseProc);
365-
messageFilter = new MessageFilter(Back, Forward);
389+
messageFilter = new MessageFilter(StopExitFullscreenLabelTimer, Back, Forward);
366390
webBrowserModeTitle = new WebBrowserModeTitle(TitleChanged);
367391

368392
statusBarStatusStrip.Renderer = new EndEllipsisTextRenderer();
@@ -375,7 +399,7 @@ public WebBrowserMode(Uri webBrowserURL, bool useFlashActiveXControl = false) {
375399
UseFlashActiveXControl = useFlashActiveXControl;
376400

377401
lowLevelMouseProc = new HookProc(LowLevelMouseProc);
378-
messageFilter = new MessageFilter(Back, Forward);
402+
messageFilter = new MessageFilter(StopExitFullscreenLabelTimer, Back, Forward);
379403
webBrowserModeTitle = new WebBrowserModeTitle(TitleChanged);
380404

381405
statusBarStatusStrip.Renderer = new EndEllipsisTextRenderer();
@@ -474,6 +498,10 @@ public void BrowserFullscreen() {
474498
Fullscreen = !Fullscreen;
475499
}
476500

501+
private void StopExitFullscreenLabelTimer(object sender, EventArgs e) {
502+
ExitFullscreenLabelTimer = false;
503+
}
504+
477505
private void Back(object sender, EventArgs e) {
478506
BrowserBack();
479507
}

0 commit comments

Comments
 (0)