I figured out a way to so fix some of the problem. It doesn't work on youtube/adobe flash in Firefox, but it works on Firefox, itunes, and VLC. I put the solution into a script that also does normal fullscreen toggling. So if you add the script to a keyboard shortcut, or, like me, to the EJECT key, the script will fix the problem if there is any, switch to window mode if in fullscreen, and switch to fullscreen if in window mode.
I used Accessibility Inspector ( https://developer.apple.com/library/mac/documentation/Accessibility/Conceptual/A ccessibilityMacOSX/OSXAXTesting/OSXAXTestingApps.html) and found that one of the attributes AXPosition missed on the y-axis by 22 pixels. If you amend that value, the black bar will be disappear.
Here is the script:
-- This script is meant to replace the default fullscreen keyboard shortcut.
-- If the current app is in window mode, this script will bring it to
-- fullscreen mode, provided the function is available.
-- If it's already fullscreen mode correctly, the script will exit fullscreen.
-- More importantly, if a black bar is displayed at where the hidden menu bar used
-- to be, this script will fix the problem.
-- Be ware: 1) The script, in its current form, only works on one display.
-- 2) The script requires manually entering the dimension of that display. The default
-- is for 1080p 16:9 ratio display.
-- 3) On the plus side, it works in both landscape and portrait mode.
-- 4) As far as I can tell, the script doesn't work on youtube w/ Firefox. It does the trick on
-- Firefox, VLC, and iTunes. I don't use Chrome or Netflix.
global longEdge, shortEdge
set longEdge to 1920
set shortEdge to 1080
global xA, yA, xB, yB, Fx
-- {xA, yA, xB, yB,}: the bounds of the window
-- The menubar seems to be always 22 pixels in height. is that true? If it is, the script
-- can be simpler.
set Fx to 0
-- Fx: Screen modes: 0: Windowed. 1: Fullscreen. 2: Fullscreen with black bar.
-- The following block of code tries to figure out the size and position of the application.
set currentApp to (path tofrontmost applicationasUnicode text)
tell applicationcurrentApp
set contentPosition to bounds of window 1
set {xA, yA, xB, yB} to contentPosition
end tell
-- Figuring out if it's already in fullscreen
-- Credits here: https://discussions.apple.com/thread/5212352
tell application "System Events" to tell (first process whose frontmost is true)
if front window exists then
tell front window
if value of attribute "AXFullScreen" is true then
set Fx to 1
else
set Fx to 0
end if
end tell
end if
end tell
-- Now figuring out if there is a black bar
if Fx is 1 then
if xA > xB then
set FxWidth to xA - xB
else
set FxWidth to xB - xA
end if
if yA > yB then
set FxHeight to yA - yB
else
set FxHeight to yB - yA
end if
-- In landscape mode
if FxWidth is equal to longEdge then
if FxHeight is not equal to shortEdge then
set Fx to 2
set yA to yB - shortEdge
end if
else
-- In portrait mode
if FxWidth is equal to shortEdge then
if FxHeight is not equal to longEdge then
set Fx to 2
set yA to yB - longEdge
end if
end if
end if
end if
-- Safari Exception
if currentApp is "OS X Mavericks:Applications:Safari.app:" then
if Fx is 2 then
set Fx to 1
end if
end if
-- Add others:
-- tell application currentApp
-- display dialog currentApp
-- end tell
-- alternate among modes
-- 1) go full screen
if Fx is 0 then
tell application "System Events" to tell (first process whose frontmost is true)
if front window exists then
tell front window
if value of attribute "AXFullScreen" is false then
set value of attribute "AXFullScreen" to true
end if
end tell
end if
end tell
end if
-- 2) exit fullscreen
if Fx is 1 then
tell application "System Events" to tell (first process whose frontmost is true)
if front window exists then
tell front window
if value of attribute "AXFullScreen" is true then
set value of attribute "AXFullScreen" to false
end if
end tell
end if
end tell
end if
-- 3) fix black bar
if Fx is 2 then
tell applicationcurrentApp
set bounds of window 1 to {xA, yA, xB, yB}
end tell
end if
-- Bind the script to a keyboard shortcut or a key. Voila.