FreeTube icon indicating copy to clipboard operation
FreeTube copied to clipboard

Ensure that FreeTube always opens on a display that is currently attached

Open absidue opened this issue 3 years ago • 8 comments


Ensure that FreeTube always opens on a display that is currently attached

Pull Request Type

  • [x] Bugfix

Related issue

closes https://github.com/FreeTubeApp/FreeTube/issues/1938

Description

This pull request fixes the issues with FreeTube being positioned on disconnected displays when started. If the saved bounds are on a display that is connected then the window will be positioned at the saved bounds. Alternatively if the display is disconnected the window will be placed on the nearest display to the saved bounds at the same percentage offset from the top left of the screen, this allows it to work even if the displays have different resolutions. Finally when FreeTube is opened for the first time after the update, the offsets won't be stored in the database. As this would cause issues if the display is disconnected FreeTube falls back to just setting the window size and leaving the positioning up to the operating system, which should always place it on a connected display.

Testing (for code that is not small enough to be easily understandable)

I tested this multiple times by disconnecting my second display after closing FreeTube and checking that FreeTube was always visible. Important to note that if the dev tools are open in a second window they need to be closed before closing the main FreeTube window as FreeTube only saves the window position if there is a single window open at the time of closing. see: https://github.com/FreeTubeApp/FreeTube/blob/1eab4c8a2457803f7bdcb7960e7ed0c18413bb5d/src/main/index.js#L306-L309

Desktop (please complete the following information):

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 7878e9e3a671830426bc0893a44c1baff5801cb9

absidue avatar Apr 16 '22 16:04 absidue

I am sorry but this is beyond my technical/coding skills. If there is a compiled version available with this fix I am happy to test it on my dual monitor setup but as it stands this is too deep for me.

MM502 avatar May 19 '22 13:05 MM502

@MM502 you can download the compiled version from my fork, i've told it to build this branch. The artifacts are here: https://github.com/absidue/FreeTube/actions/runs/2354670497

absidue avatar May 19 '22 21:05 absidue

@absidue do you know how i can reproduce the issue for myself because FT right now seems to be doing the same as your build to me. FT always seems to open correctly for me doesn't matter if the screen is connected or disconnected.

@efb4f5ff-1298-471a-8973-3d47447115dc I think this might only be a problem on Windows, which is why you can't replicate it.

absidue avatar May 23 '22 22:05 absidue

@efb4f5ff-1298-471a-8973-3d47447115dc I think this might only be a problem on Windows, which is why you can't replicate it.

@absidue So i've just took an Win10 machine and a display to test this. Weird enough i couldnt reproduce the issue on the normal FT install but i did get the issue when i had installed your build. Im not sure if im doing anything wrong. Probably just going to wait on the others to report.

When opening the application it opened in my second monitor. Closed the application. Disconnected the monitor and opened the application. But it didnt open. Connected my display again and i still didnt see the application. Had to go into task manager to close FT. After that i could open it again

@efb4f5ff-1298-471a-8973-3d47447115dc see #1938

absidue avatar May 24 '22 17:05 absidue

@absidue i want to give this another try could u provide me some testcases?

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Sep 20 '22 12:09 github-actions[bot]

This PR is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Oct 19 '22 02:10 github-actions[bot]

I deleted my AppData folder and then re-installed v0.17.1 and the problem has gone away. There is now a new settings.db file and I am getting the following error message: Local API Error: TypeError: Cannot read properties of undefined (reading 'contents')

I don't know if this error is related to the issue or if it relates to my history not importing properly after re-intalling.

MM502 avatar Oct 19 '22 12:10 MM502

This PR is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Nov 17 '22 02:11 github-actions[bot]

This PR is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Dec 16 '22 01:12 github-actions[bot]

@absidue I have a second monitor now so I'll be able to test it, you'll need to rebase/merge development in this branch first

ChunkyProgrammer avatar Jan 11 '23 02:01 ChunkyProgrammer

Conflicts have been resolved. A maintainer will review the pull request shortly.

github-actions[bot] avatar Jan 12 '23 18:01 github-actions[bot]

FreeTube seems to not be opening when i remove the display. So I think I'll approve the other PR

ChunkyProgrammer avatar Jan 12 '23 19:01 ChunkyProgrammer

@efb4f5ff-1298-471a-8973-3d47447115dc I think this might only be a problem on Windows, which is why you can't replicate it.

@absidue So i've just took an Win10 machine and a display to test this. Weird enough i couldnt reproduce the issue on the normal FT install but i did get the issue when i had installed your build. Im not sure if im doing anything wrong. Probably just going to wait on the others to report.

When opening the application it opened in my second monitor. Closed the application. Disconnected the monitor and opened the application. But it didnt open. Connected my display again and i still didnt see the application. Had to go into task manager to close FT. After that i could open it again

I believe the issue is mainly for if the setup is a display below another display which is why u couldnt reproduce it.

ChunkyProgrammer avatar Jan 12 '23 19:01 ChunkyProgrammer

Ah okay. The setup i used was with a laptop and an external display that was hanging above the laptop.

Edit: i shared a txt document in IRC a while back with my test results. Just want to mention it to u, maybe its some useful info.

Is this PR still up for consideration or should I close it in favour of the other one?

absidue avatar Jan 14 '23 15:01 absidue

The other pr seems to work better (for me at least) so I think I'd favor the other one. We should probably wait for @efb4f5ff-1298-471a-8973-3d47447115dc to try the other one when they have time since they have two monitors too before deciding 🙂

ChunkyProgrammer avatar Jan 31 '23 19:01 ChunkyProgrammer

help needed https://github.com/FreeTubeApp/FreeTube/pull/3008#issuecomment-1418247816