Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Window::set_fullscreen pass a non-None value when entering fullscreen #22853

Closed
jdm opened this issue Feb 8, 2019 · 38 comments
Closed

Make Window::set_fullscreen pass a non-None value when entering fullscreen #22853

jdm opened this issue Feb 8, 2019 · 38 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Feb 8, 2019

I expect we can call window.get_primary_monitor() to get a monitor id, then pass that in a Some value when state is true. This will hopefully make Servo actually enter full screen mode.

It looks like we will also need to change the use of SetFullscreenState in exit_fullscreen in document.rs to pass the value false, or we will never be able to exit fullscreen mode.

https://www.joshmatthews.net/webgl2.html should be able to verify if these changes are behaving as expected.

@highfive
Copy link

@highfive highfive commented Feb 8, 2019

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Feb 21, 2019

@highfive assign me. I am new on this project. Would like to start with this issue

@highfive
Copy link

@highfive highfive commented Feb 21, 2019

Hey @kamal-umudlu! Thanks for your interest in working on this issue. It's now assigned to you!

@highfive highfive added the C-assigned label Feb 21, 2019
@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Hi,
Currently I am working on this bug. Please correct me if I am wrong. After my fix, fullscreen-region-content-001.html should go to the full screen and exit from full screen mode by pressing esc. Is that all I need to fix for this bug?

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

I tried to pass get_primary_monitor() in Some value under get_allow_fullscreen() but it looks like there is no window.get_primary_monitor() function in windows.rs file.

I am new in this project maybe I am wrong. Could you please give a little clarification about issue?
Thanks )

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

Sorry, I should have been more specific about the code I was looking at:

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Hi Josh,
So I have changed code to window.set_fullscreen(Some(window.get_primary_monitor())); and build the project to see my changes in fullscreen-region-content-001.html. After my change, when I press "Go full screen" button the whole window (not only video part) goes to full screen mode and I can't exit from fullscreen mode by pressing "ESC" button.

Is there any way to make only video to become full screen or am I running wrong html file?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

Our existing fullscreen support (inside of a window, rather than actually making the window fullscreen) is supposed to do what you describe. Have you tried https://www.joshmatthews.net/webgl2.html?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

As for leaving fullscreen, I would expect fixing the code in document.rs to avoid that problem.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Yeah I understood fullscreen support and also tried https://www.joshmatthews.net/webgl2.html. I was expecting the same behaviour from fullscreen-region-content-001.html but maybe I am missing something that doesn't make video element to become full size.

My expectation was after passing window.set_fullscreen(Some(window.get_primary_monitor())), it will get video element and make it full screen which doesn't.

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

That may be related to #22358. We have observed fullscreen support not working for videos in particular.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Under #22358 , it says issue may be relevant to this issue. That is why I thought maybe my fix also needs to fix #22358 . Am I wrong?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

I wouldn't expect the changes for this issue to affect #22358.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Oh sure. Is there any other fix I need to do other than passing monitor_id and changing SetFullscreenState to true in exit_fullscreen?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

If those make the window enter fullscreen mode and leave it, then no :)

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

The only issue I have right now is when I press "ESC" keyboard button, it close the whole servo app (doesn't make difference if it is in fullscreen mode or not). Is it also issue that I need to fix? If yes, is there any way to map "ESC" button to exit_fullscreen() function?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

Ooh, that's a very good point. So, the decision to quit Servo happens in handle_key_from_window in ports/servo/browser.rs. This is called before web content is allowed to handle it; I think we should add a check for whether self.window is currently fullscreen and send a message to the constellation to exit fullscreen (which will get passed to the appropriate script thread and invoke document.exit_fullscreen()). Would you like to work on that?

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Sure I can try :)

But the only thing I just need to make sure is it is feasible to fix it until Friday noon.
I just need the steps that I can follow and I also have couple questions.

  1. If the window is not in fullscreen mode, should it quit from the app when "ESC" button is pressed?

  2. How I can send a message to the constellation? Do I have to add a script like WindowEvent::ExitFullScreen in servo/components/servo/lib.rs file?

  3. Where I can call document.exit_fullscreen() that will actually exit from fullscreen mode?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 5, 2019

  1. Yes.

2&3.
You will need to add a new WindowEvent value, then handle it in handle_window_event in components/servo/lib.rs by sending a new ConstellationMsg value like WindowEvent::LoadUrl does. This new value will be handled by handle_request_from_compositor in components/constellation/constellation.rs, and it will send a new ConstellationControlMsg value to the script thread. You can use FromCompositorMsg::WindowSize as a model; it takes the toplevel browsing context id, gets a pipeline from it (in resize_browsing_context) and sends a ConstellationControlMsg to it that tells the script thread that a resize has happened. The new message for exiting fullscreen will need to be handled in start in components/script/script_thread.rs, and you can use the Resize message as a guide again. That will allow you to invoke the exit_fullscreen method on an actual document :D

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 5, 2019

Thanks :)

I will do my best and will let you know if I have any question.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

Is there any public getter function to check whether self.window is in fullscreen mode or not?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

Actually it looks like you can check self.fullscreen instead.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

oh I thought it is a private value, if it is public value then it is fine :)

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

Update

I have tried to use self.window.fulscreen, but it seems like it is private value. So, I can't actually use self.window.fullscreen :(

I am actually so close to the fix, but don't know If I should add getter function for fullscreen value.

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

Like I said, self.fullscreen instead of self.window.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

So I was saying in browser.rs file, is there any way to access fullscreen state? I have tried self.fullscreen too but it says there is no field. Is there way to get state of fullscreen in browser.rs?

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

.shortcut(Modifiers::empty(), Key::Escape, || { let state = **self.fullscreen**; if state { if let Some(id) = self.browser_id { let event = WindowEvent::ExitFullScreen(id); self.event_queue.push(event); } } else { self.event_queue.push(WindowEvent::Quit); } })

Here is my code in browser.rs

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

Oh, I'm sorry. I kept mixing up which file we were talking about. Yes, go ahead and add a public getter to Window that returns self.fullscreen.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

I added getter function and now I can get self.fulscreen value. Right now I don't have any compile error and I have tested my code on fullscreen-region-content-002.html. But it is not actually changing fullscreen mode when I pressed ESC button.

So my guess is, I am missing something in script_thread.rs file.

This is the code I added to script_thread.rs file. Am I missing something here?

fn handle_exit_fullscreen(&self, id: PipelineId) {
        let document = self.documents.borrow().find_document(id);
        if let Some(document) = document {
            document.exit_fullscreen();
            return;
        }
    }
@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

That seems reasonable. Have you tried using a debugger or adding println! statements to make sure the new code is being executed?

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

I am trying now. Just one quick question. After adding println statements, do I have to build project again?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

Yes.

@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

So yeah I added println statements and seems like the new code is being executed. But in document.exit_fullscreen() function, after executing let promise = Promise::new(global.r()); it is crashing.

Is there any file or function that actually calls document.exit_fullscreen()?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

When I search the code (using grep or ack, for example) I see unbind_from_tree in element.rs, which is executed when an element is removed from a document (like with node.remove() in JS). I suspect that adding this code before calling exit_fullscreen will make the crash go away:

let _ac = JSAutoCompartment::new(document.global().get_cx(), document.reflector().get_jsobject().get());
@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

Can I just add that code on my handler like this?

fn handle_exit_fullscreen(&self, id: PipelineId) {
        let document = self.documents.borrow().find_document(id);
        if let Some(document) = document {
            let _ac = JSAutoCompartment::new(document.global().get_cx(), document.reflector().get_jsobject().get());
            document.exit_fullscreen();
            return;
        }
    }
@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 6, 2019

I tested it. I think it worked :)

kamal-umudlu added a commit to kamal-umudlu/servo that referenced this issue Mar 8, 2019
…when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False
@kamal-umudlu
Copy link
Contributor

@kamal-umudlu kamal-umudlu commented Mar 8, 2019

Hi Josh. I have one more last question :)

Should I create two different Pull Requests for one fixing issue #22853 and the second for adding ESC button that make Servo exit full screen mode? Or should i just do one PR that covers both patches?

@jdm
Copy link
Member Author

@jdm jdm commented Mar 8, 2019

One PR for both commits is fine.

@kamal-umudlu kamal-umudlu mentioned this issue Mar 28, 2019
4 of 5 tasks complete
kamal-umudlu added a commit to kamal-umudlu/servo that referenced this issue Apr 1, 2019
…when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False

Added patch for bug:22853

Added implementation to exit from fullscreen mode by pressing ESC button

Added patch that supports to exit from fullscreen mode by pressing ESC

Deleted patch files

Added all requested changes on project

Removed the loop over self.pending_changes in switch_fullscreen_mode function

Bug servo#22853 - Make Window::set_fullscreen pass a non-None value when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False
kamal-umudlu added a commit to kamal-umudlu/servo that referenced this issue Apr 1, 2019
…when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False

Added patch for bug:22853

Added implementation to exit from fullscreen mode by pressing ESC button

Added patch that supports to exit from fullscreen mode by pressing ESC

Deleted patch files

Added all requested changes on project

Removed the loop over self.pending_changes in switch_fullscreen_mode function

Bug servo#22853 - Make Window::set_fullscreen pass a non-None value when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False

Added missing bracket in constellation.rs file to fix build issue

Bug: servo#22853 --> Make Window::set_fullscreen pass a non-None value when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False
bors-servo added a commit that referenced this issue Apr 2, 2019
…een, r=jdm

Pass not none value in setfullscreen

<!-- Please describe your changes on the following line: -->
# Diagnose

Entering fullscreen mode is passing `None` value to `Window` when `set_fullscreen` function is called which prevents
Servo actually entering fullscreen mode.
In addition, the function `exit_fullscreen` in `document.rs` is passing True value to
`SetFullscreenState` which doesn't allow to exit from fullscreen mode.

# Solution

1. Instead of passing `None` value when `FullScreenState` is true, `window.get_primary_monitor()` is called in order to pass a monitor id.
This fix make Servo actually enter fullscreen mode.
2. Changed `SetFullscreenState` to false when `exit_fullscreen` function is called.
3. In addition, added new implementation to support exiting from fullscreen mode by pressing `Escape` button.

# Testing Plan

After my change in [windows.rs and document.rs](kamal-umudlu@af6b598),
the Servo app can enter/exit fullscreen mode.
In addition, the [`ESC button support`](kamal-umudlu@14ebd5b)
allows to exit from fullscreenmode.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22853

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23128)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Apr 2, 2019
…een, r=jdm

Pass not none value in setfullscreen

<!-- Please describe your changes on the following line: -->
# Diagnose

Entering fullscreen mode is passing `None` value to `Window` when `set_fullscreen` function is called which prevents
Servo actually entering fullscreen mode.
In addition, the function `exit_fullscreen` in `document.rs` is passing True value to
`SetFullscreenState` which doesn't allow to exit from fullscreen mode.

# Solution

1. Instead of passing `None` value when `FullScreenState` is true, `window.get_primary_monitor()` is called in order to pass a monitor id.
This fix make Servo actually enter fullscreen mode.
2. Changed `SetFullscreenState` to false when `exit_fullscreen` function is called.
3. In addition, added new implementation to support exiting from fullscreen mode by pressing `Escape` button.

# Testing Plan

After my change in [windows.rs and document.rs](kamal-umudlu@af6b598),
the Servo app can enter/exit fullscreen mode.
In addition, the [`ESC button support`](kamal-umudlu@14ebd5b)
allows to exit from fullscreenmode.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22853

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23128)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.