JezerM / web-greeter

A modern, visually appealing greeter for LightDM.
https://web-greeter-page.vercel.app
GNU General Public License v3.0
216 stars 12 forks source link

Prompt Autofocus Support #86

Open TheWisker opened 1 week ago

TheWisker commented 1 week ago

Environment

Description of feature

When making some changes and improvements to Shikai Theme, I wanted to implement an autofocus feature for the password prompt, which would focus the prompt when the theme gets loaded, so the user does not have to click on it manually. In theory, this is something simple to do and, consequently, I achieved it by adding the following code to get triggered on the prompt load event:

setTimeout(() => {document.getElementById("password").focus();}, 250);

The problem is this only seems to work when running the greeter on a single monitor or inside a session with and without the -d flag.

What I could deduct from some tests I did is that when using more than one monitor each monitor behaves like a separate tab/window and only one of them has 'focus'. As the .focus() function only gives focus to the element if the tab is active, the element does not get focused. Particularly, in my situation, the secondary screen, that only shows a wallpaper, appears to be the one focused, thus preventing the primary screen, that has the prompt, to get focused/active and the .focus() function to have any effect. My mouse always appears on the secondary screen and sometimes when I click on the primary screen the .focus() function seems to take effect as the prompt gets focused.

Possible solutions

This is a list of possible solutions I came with:

The list of solutions is based on the assumption that all of my deductions are correct and the greeter does work like that internally. In case I'm wrong feel free to correct me :)

Thanks for making the greeter

JezerM commented 4 days ago

Hi! I made an update in the master branch to focus the primary screen at start. Let me know if it works!