Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Optimize titlebar space on Windows #3854

Merged
merged 17 commits into from
Sep 21, 2016
Merged

Optimize titlebar space on Windows #3854

merged 17 commits into from
Sep 21, 2016

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Sep 9, 2016

Changes done, only a few minor bugs open (see checklist below under known issues)

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Fixes #3036

Lots of changes; this PR:

  • Menubar and caption button changes only affect Windows
    • removes the standard menubar from the Window
    • custom renders the caption buttons (the minimize / maximize / close buttons)
    • custom renders a menubar (if visible). Can be toggled with ALT (left and right ALT both work).
    • Windows 10, 8.1, 8, or other will use Windows 10 styles
    • Windows 7 will use Windows 7 styles
  • Functionality for Linux was removed- this is captured separately with Titlebar on some Linux distros has a lot of wasted space #3126
  • Keyboard accelerators are now shown in context menus. This affects Mac and Linux

It also includes:

  • remove unused getParentMenuDetails method

Auditors

@bbondy @bridiver @bradleyrichter @Sh1d0w

Test Plan

Windows

Styles should match the mockup for the respective OS

image
image

Custom rendered menubar

  • Menubar should be hidden by default with a fresh session
  • If enabled, the menu will show all the time
  • When toggled, the lion head should not move horizontally
  • Menu should be usable in full screen mode (F11)

Custom render caption buttons

  • Minimize / Maximize / Close
  • Tooltip shows if you hover over it
  • Buttons should work
  • When maximized, maximize button turns into a restore icon
  • Going full screen (F11) should hide the caption buttons

Using menubar w/ the keyboard

  • Pressing any arrow keys should not interfere with the frame (unless menu is triggered using ALT)
  • Menu should toggle between shown and hidden with ALT
  • Navigation
    • When shown, menu will automatically highlight the "File" menu
    • When menu is "highlighted", you should be able to use arrow keys to move left and right and also up/down to:
      • show the initial context menu (the items under File or Edit, for example)
      • move your selection up/down, including wrapping around choose a different item
    • Once a menu item is highlighted, you should be able to trigger it by pressing ENTER
  • menu can be hidden at any time (even if it's popped up) by pressing ALT or ESCAPE
  • Menu should be readable/usable with usability options enabled:
    win7-magnifier
    win10-personalization
  • Menu hides after choosing an item (unless auto-hide is disabled)
  • Keyboard shortcuts making use of ALT should still work fine (and not toggle the menu)

Using menubar w/ the mouse

  • You can click any menu and it'll show the associated popup
  • If you clicked File, you should be able to move your mouse another item, like Edit, and it should automatically:
    • close the popup associated with File
    • open the popup associated with Edit
    • change the selection behind the menu name
  • Menu hides after choosing an item (unless auto-hide is disabled)
  • Picking copy or paste from Edit menu should not affect focus of the input box on a given page
  • Clicking in the middle of a page should unselect the menu item and hide any popup menus that were showing

Other style changes

  • window should have a 1 pixel black border around it now
  • Context menus now show keyboard shortcuts
    image
  • Menus should be displayable in other languages without issue
  • Window should be able to be made smaller without screwing up the URL bar / caption button area

Misc things to try

  • toggle the auto-hide menu bar (also can be triggered by right clicking in bookmarks toolbar or tab row and picking "Menu bar")
  • try using the long press back button / forward button. These also use our custom context menus
  • toggle the magic-titlebar (always show URL) setting. Does the window do anything weird during transition?
  • resize the window (small, big, push F11 and go fullscreen)

Mac / Linux

  • Custom titlebar should not be showing
  • You should see the keyboard shortcuts now in our custom context menus. For example, the hamburger button.
  • mac menu
  • Keyboard shortcuts should be in the proper order (shift before command, etc) and should be displayed, regardless of locale
  • Keyboard shortcuts should not be affected
    • Alt on Linux, option on Mac
    • Test keyboard shortcuts that use this
  • Popup elements should still work correctly
    • clicking on lock for security mode
    • adding / editing bookmark
    • clicking lion head to bring up site specific bravery panel
    • adding new autofill data in preferences

NOTE: besides the min/max/close tests (which aren't runnable), there are no other automated tests. I'd like to create some, but webdriver tests on Windows are not working

Known issues (will be working through these)

Issues towards the top of each respective category are higher priority. Issues which are considered show-stoppers are bolded (please feel free to edit this comment).

Issues with the checkbox are FIXED (see follow up commits for fix)

functional issues

  • Most menu items don't work when selected; they rely on input being passed to the click handler
  • The lion icon moves around when menu is toggled
  • Menu needs to auto close/expand when you move your cursor from one menu to another
  • Menubar needs to de-select the MenubarItem once context menu option is selected or context menu gets blurred
  • After pressing ALT menu shows- but isn't dismissed on a click that isn't the menu (when autohide menubar = true)
  • Menu does NOT respect the "Hide the menu bar by default" setting
  • Need to show hotkeys in the menu (shortcut keys, accelerators)
  • No resize cursor on top corner of window (both on top and on edge and on exact corner)
  • Feature needs a setting to disable, for folks that would have negative accessibility impacts
  • There is dead space under the min/max/close buttons that cannot be grabbed. This already has the -webkit-app-region: drag; style but isn't taking 100% height 😦
  • Menus should be navigable by keyboard (alt then arrow keys)
  • Right click in certain areas brings up restore/move/etc menu (not the expected context menu). This seems to be related to the CSS drag attribute edit: _root cause is that different OSes handle this differently. Windows did not treat these areas as draggable (even with the attribute) until the window became frameless. See frameless docs for more info.
  • Some menu items are not being selected when hovered?! edit: _after updating to allow menu to work w/ keyboard and fixing drag attributes, I can't reproduce this on Win7 or Win10. Marking as fixed.
  • Don't show buttons in full screen mode (or is full screen mode working properly?)
  • cut/copy are stealing focus
  • cut/ copy not working from menu on URL bar
  • first context menu item has issues (Windows 7 specific? able to fix in dev tools by removing border. Element is positioned absolutely and has transparency in BG color... needs more investigation) - edit: marking as closed; tracking with Windows 7 - selection problems with first item in custom menu  #4142
  • resize handle on top right of window not showing properly edit: marking as closed; tracking with Windows 7 - resize handle on top right corner is hard to click #4144
  • keyboard does not work with submenus (ex: bookmarks menu when you have folders) edit: marking as closed; tracking with Windows - Keyboard does not work with submenus #4143

style issues

  • back/forward buttons are oval shaped (not circle) also causes spacing to be messed up:
    image
  • space between menu text needs to be 22px
  • Font for the menu can be much larger than app, because it uses system size (we can override this and make it a static size, if we'd like)
    image
  • Windows caption buttons are supposed to show a title of "Maximize" or "Minimize" when mouse is left hovering over them
  • Context menu accelerators need restyling (need to be the same size as regular text)
  • Needs to show border
    • Windows 10 always puts a 1 pixel border with the users highlight color around each window... instead, a box shadow is drawn (which looks nice, but isn't consistent with OS)
    • Windows 7 doesn't use any effects around the border and when you're on a white page, it can be really confusing- because there is no borders and the white will blend in (making it hard to tell what is in the browser and what isn't)
  • Window needs a smaller min-width than 700px; currently, when less than that, the caption buttons get messed up.

@bsclifton bsclifton force-pushed the windows-titlebar-diet branch 2 times, most recently from 01989e4 to bb4db62 Compare September 10, 2016 18:36
@bbondy
Copy link
Member

bbondy commented Sep 12, 2016

btw this needs a rebase on master when you get time

@bsclifton bsclifton force-pushed the windows-titlebar-diet branch 2 times, most recently from dd23cbd to 5a1299b Compare September 12, 2016 04:11
@bsclifton
Copy link
Member Author

OK properly rebased and verified 😄

@bsclifton bsclifton force-pushed the windows-titlebar-diet branch from 9303351 to 920c27f Compare September 12, 2016 08:26
@bbondy bbondy added this to the 0.12.2dev milestone Sep 12, 2016
@bsclifton bsclifton force-pushed the windows-titlebar-diet branch 8 times, most recently from bea276f to 48d73bf Compare September 13, 2016 21:10
@bsclifton
Copy link
Member Author

Ready for review- @bbondy @srirambv @darkdh any feedback is appreciated 😄 I'll try to find some Windows contributors who can also try it and give feedback

@bsclifton
Copy link
Member Author

bsclifton commented Sep 13, 2016

Just a heads up- this branch can be tested on Mac, BTW

  • To make sure I didn't break anything
  • To see the new sweet keyboard accelerators in the context menus (burger menu for example)

@bsclifton bsclifton force-pushed the windows-titlebar-diet branch from 7d3b488 to d6199cd Compare September 13, 2016 23:52
@srirambv
Copy link
Collaborator

@bsclifton The new look is really good and looks neat.

Some observations:

  1. When custom title bar is disabled and enabled it shows two sets of windows buttons
    image
  2. Block script and Favorite icons are not properly aligned when hide URL bar is enabled
    12
  3. File menu/Hamburger menu text size is very small compared to the current version which could be a problem
  4. Window buttons are shown even if the browser is in fullscreen mode
  5. Mouse over highlight doesn't happen on some of the menu items
    1
  6. If the window is too small then the Sheilds and Password manager icons are hidden. It is displayed when you are on one of the about pages. The window buttons gets stacked one above the other
    2

@bsclifton
Copy link
Member Author

bsclifton commented Sep 14, 2016

Thanks for testing, @srirambv 😄

  1. Feature removed
    is a good concern; I'd like to defer to @bbondy and @bradleyrichter. Basically, if you go into settings, I've made this new feature configurable (enabled by default, can be turned off). If you do choose to toggle it, you are prompted by a "Restart needed. Do it now? yes/no". However you're not forced to do this. What do you all think is a good experience?
    • Force a restart by bringing up an OK/cancel dialog?
    • remove it as a configurable option for now?
    • other options?
  2. Already tracked with Block script icon is off location when URL bar is hidden #4007
  3. I'll defer to @bradleyrichter- the font size is 12px (roughly 9pt) which is the default system size. On bigger monitors, this might be unacceptable.
  4. great catch! 😄 I'll add that to my TODO list resolved
  5. will need to investigate... I definitely did not have that experience tracked with Windows 7 - selection problems with first item in custom menu  #4142
  6. is already captured in my help needed, trying to make the window respond better when below 700px width

@srirambv
Copy link
Collaborator

@clifton Would suggest a Ok/Cancel dialog than the notification bar. Goes along with the standard windows alert messages. This way the window remains as is and only applies the change after a restart is done.

@bradleyrichter
Copy link
Contributor

@srirambv These mini-screen captures are priceless. And addictive!

@bsclifton I'm confused about #1. We never want to see the standard non-custom titlebar. That is the whole point of this effort. Am I missing something?

Font size - we need to match the standard default in all cases - somehow copying the approach that WIN uses for it's view settings. Later we can try to support the user-overrides from the system.

@bsclifton
Copy link
Member Author

bsclifton commented Sep 14, 2016

@bradleyrichter for 1, that is a completely acceptable answer 😄 I made it toggle-able just in case there were folks with accessibility requirements (which the custom menu may not work). We can always revisit that later though

edit: this config option has now been removed

@bsclifton bsclifton force-pushed the windows-titlebar-diet branch 2 times, most recently from e258902 to 37474ea Compare September 15, 2016 06:56
@bbondy
Copy link
Member

bbondy commented Sep 15, 2016

Looking a lot better than my last pass.

A couple of things I noticed.

  • I think people will complain that they can't use the keyboard up / down arrows / right arrow to go to next menu, left for previous menu. Alt + arrows to navigate to item and hit enter to open. This is probably a bigger thing but we should handle it. As a side note, it'd be nice to have this for hamburger menu too.
  • Items like cut, copy, paste, paste with formatting (possibly others) are taking focus away from the page and then the operation doesn't work. This is both for if your cursor is in the urlbar or just selecting something on a page.
  • Minor thing but lion head looks like it needs a couple px more padding on the right to me.
  • The top right corner for resizing the window is really hard to make shot up. Whereas works reliably for other windows.

@bsclifton bsclifton force-pushed the windows-titlebar-diet branch 2 times, most recently from 601904f to ecbf741 Compare September 16, 2016 23:02
- Removed border on top since that now works; starting to finalize the X with Brad
- Windows 7 fixes
  - fix button size
  - new svg for close
  - fix margin
  - color updates
- updated naming in main.js; menubar text no longer selectable
- Caption buttons and border are now hidden when a window goes fullscreen
- Fix context menu accelerator size (windows only)
- selection can be made left and right
- menu can be popped up with up/down

known issues (what's left)
- storing the context menu's selected index in windowStore
- properly handling up/down (changing selection)
- handling submenus

also includes:
- small cleanup for custom titlebar in main.js
- lint cleanup
Menu fixes
- You can now hit enter to pick a selected menu item
- Fixed bug where menu opened by keyboard was not clickable

Cleanup
- Added reducer property which retuns a menu minus the separator items
- Moved wrappingClamp method into formatUtils
- Menu now sets default selection when you press ALT to show it
- Menu now behaves properly when always displayed (auto-hide=false)
- ALT and ESC now are properly handled; providing windows-like behavior
  (deselect and/or closing menu, etc)
- Fix click problem with extension button (it was tagged as draggable)
- Windows specific fixes for drag. Tested each area that was changed,
  comparing this build to 0.12.1 to make sure it's consistent.
- menu now returns focus properly to active web frame
- the pseudo click now sends over webContents (required for cut/copy)
- Bumped up minimum viewport width to 640px for Windows only.
  Media query strips margin left of the brave button unless you're at 720px
  or more (again- windows only)
- Properly handle all accelerator modifiers (was missing CommandOrControl
  and some replacement cases)
- Updated code to skip rendering / processing for hidden context menu items
…from

appState to windowState (not going to move it after talking w/ @bridiver).
Works well with URL bar always showing and also with title mode.
- capturing the browser's selection changes
- converting the activeElement object to a selector
- returning focus after menu is interacted with by:
  - using document.querySelectAll() to return focus to original element
  - executing window action which actually handles the menu action

This commit also cleans up `main.js` by properly encapsulating the
handlers required into a new method, `registerCustomTitlebarHandlers`

cc: @bbondy
@bsclifton bsclifton force-pushed the windows-titlebar-diet branch from 74c77ff to 39d2b0c Compare September 20, 2016 23:58
@bbondy
Copy link
Member

bbondy commented Sep 21, 2016

Let's get this merged and do anything else as follow ups. Nice work on all of this 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Titlebar on Windows has a lot of wasted space
5 participants