Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDA-3990: Hide all windows and restore with previously focused window #1659

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

NguyenTranHoangSym
Copy link
Contributor

Description

  • Be able to restore previously worked on window
  • Be able to hide all windows

Related PRs

(window as ICustomBrowserWindow).winName !== currentWindow ||
(window as ICustomBrowserWindow).winName !== 'main'
) {
arr.push((window as ICustomBrowserWindow).winName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think every window has a winName no? Why not relying on the window ID here?

Copy link
Contributor Author

@NguyenTranHoangSym NguyenTranHoangSym Dec 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only exclude main not to push it in, already got main outside
The Idea here is I will consecutively push the element into array. Then with each of element in array I take it out to process consequently

const currentWindows = BrowserWindow.getAllWindows();

currentWindows.forEach((currentWindow) => {
currentWindow?.minimize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this behave on Windows with a window in fullscreen mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minmize and focus will switch back to previously working windows.
focus will bring it back instead of doing anything else. (No config modified)

Copy link
Contributor

@sbenmoussati sbenmoussati Dec 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this approach will cover all use-cases.
One of them which covers 2 use-cases actually is:

  • having 5 windows popped: 2 windows minimised and one in full screen

if hideOnCapture === true:

  • all windows will be minimised
  • we take a screenshot
  • all windows will be restored

Consequence: 5 windows on the screen rather than 3 with one in fullscreen

Maybe having a structure like this would help restoring all windows?

interface WindowState {
 minimized: boolean;
 focused: boolean;
 fullscreen: boolean
}

const windowsState: WindowState[] = [];

we populate windowsState before hiding all windows and we restore all windows based on windowsState
As we only have one focused window, this one should be the last one to be "restored" and focused.
WDYT @NguyenTranHoangSym ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbenmoussati
You are right. The status of currently minimized (The fullscreen thing i guess it is unaffected, since I will only focus back on the windows without changing anything). Im going to add an additional case to not restore the minimized ones

@@ -180,6 +199,25 @@ class ScreenSnippet {

if (dimensions.width === 0 && dimensions.height === 0) {
logger.info('screen-snippet-handler: no screen capture picture');

if (hideOnCapture) {
const currentFocusedWindow = winStore.getWindowStore();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this doesn't correspond to currentFocusedWindow, would currentWindows be more appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes totally agree let me change

{
id: 'main',
focused: mainWindow?.isFocused(),
minimized: mainWindow?.isMinimized(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question]: IWindowState has a fullscreen property that is missing here, any reason for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually need it now. I forgot to remove it.
Since rightnow you will show the old windows without changing anything relating to the aspect of windows

if (currentWindow !== 'main') {
curWindow?.minimize();

if (windowObj.windows.length < 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it would be clearer if we have dedicated functions like hideWindows() and restoreWindows(), what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done,. I have made it some common methods. Can be shared between components

@sbenmoussati sbenmoussati merged commit be17484 into finos:main Jan 9, 2023
sbenmoussati pushed a commit to sbenmoussati/SymphonyElectron that referenced this pull request Feb 8, 2023
sbenmoussati pushed a commit to sbenmoussati/SymphonyElectron that referenced this pull request Mar 28, 2023
NguyenTranHoangSym added a commit to NguyenTranHoangSym/SymphonyElectron that referenced this pull request Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants