It's hard to resize the Picture-in-Picture video window
source link: https://bugzilla.mozilla.org/show_bug.cgi?id=1598312
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
It seems that the Picture-in-Picture window has a hit-area for resizing about one pixel wide around its edges, which makes it very tricky to resize it, especially diagonally. It would be nice if we could increase the hit area a bit to make it a bit easier to grab the window edges for resizing with a mouse/touchpad.
It is a lot easier in Chrome/Edge to do this.
To get started on this, we can look at this window utility called setChromeMargin. This allows us to adjust the chrome size on each side of the window.
This method utility should be available on the PiP window we open at: https://searchfox.org/mozilla-central/rev/a6db3bd67367aa9ddd9505690cab09b47e65a762/toolkit/components/pictureinpicture/PictureInPicture.jsm#410-416. I believe we'll want to call this setChromeMargin
around this area of the code.
Updates on this:
It doesn't look like setChromeMargin
is what we want here. This looks like it's going to require some fiddling with the platform code to get working:
We have 2 approaches for this:
1. The first looks at having a way to set the resizable margin from the WindowUtils. To do this, we'll need to do the following:
-
Expose a method on WindowUtils called
setResizableMargin
.SetResizableMargin
takes in margin values for changing the horizontal/vertical resizer margin:aHResizerSize
andaVResizerSize
. -
Create an implementation for
SetResizableMargin
like SetChromeMargin. This function will be responsible for calling a method on nsWindow that is responsible for modifying these valuesmHorResizeMargin
andmVertResizeMargin
withaHResizerSize
andaVResizerSize
, respectively. -
Create a method on
nsWindow
calledSetWindowResizerSize
. As described above, it setsmHorResizeMargin
andmVertResizeMargin
and then calls UpdateNonClientMargins to apply other "window-y" things it needs. -
Now we need a way to prevent
UpdateNonClientMargins
from overwriting what we setmHorResizeMargin
andmVertResizeMargin
to. Right now, we should do this by storing creating another member variables onnsWindow
, perhaps calledmUseResizeMarginOverrides
, and use this to prevent executing this code.
After all this, we should be able to do something like: pipWindow.windowUtils.setWindowResizableMargin(x, y)
to increase the resizer size.
2. The second approach looks at changing what min-resize border value we use.
- Create some local variable called "minResizableBorder" whose value is initialized to
kResizableBorderMinSize
. - Do a check for whether or not the window is a PiP window. I believe this is currently available by checking
mAlwaysOnTop
innsWindow
.
If we're using PiP, then reassignsminResizableBorder
to some other pixel value that would increase the border size significantly. - Replace uses of
kResizableBorderMinSize
withminResizableBorder
here: https://searchfox.org/mozilla-central/rev/26330a08b1f9d06938faa0aa5e0f8c7a58064aa2/widget/windows/nsWindow.cpp#6419-6427
I believe the first approach is what we should be exploring first due to the fact we can reuse it for other feature windows and that it seems to be using the correct variables to ensure the resizer works on different desktop resolutions, plus any other calculations nsWindow
needs.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK