mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Bug: #22853 - Make Window::set_fullscreen pass a non-None value 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 #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: #22853 --> Make Window::set_fullscreen pass a non-None value when entering fullscreen is fixed and SetFullscreenState in exit_fullscreen changed to False
This commit is contained in:
parent
e27653ceae
commit
a8995fbf1a
8 changed files with 81 additions and 3 deletions
|
@ -78,6 +78,8 @@ pub enum WindowEvent {
|
|||
Navigation(TopLevelBrowsingContextId, TraversalDirection),
|
||||
/// Sent when the user quits the application
|
||||
Quit,
|
||||
/// Sent when the user exits from fullscreen mode
|
||||
ExitFullScreen(TopLevelBrowsingContextId),
|
||||
/// Sent when a key input state changes
|
||||
Keyboard(KeyboardEvent),
|
||||
/// Sent when Ctr+R/Apple+R is called to reload the current page.
|
||||
|
@ -125,6 +127,7 @@ impl Debug for WindowEvent {
|
|||
WindowEvent::ToggleWebRenderDebug(..) => write!(f, "ToggleWebRenderDebug"),
|
||||
WindowEvent::CaptureWebRender => write!(f, "CaptureWebRender"),
|
||||
WindowEvent::ToggleSamplingProfiler(..) => write!(f, "ToggleSamplingProfiler"),
|
||||
WindowEvent::ExitFullScreen(..) => write!(f, "ExitFullScreen"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1230,6 +1230,9 @@ where
|
|||
}
|
||||
}
|
||||
},
|
||||
FromCompositorMsg::ExitFullScreen(top_level_browsing_context_id) => {
|
||||
self.handle_exit_fullscreen_msg(top_level_browsing_context_id);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3664,6 +3667,15 @@ where
|
|||
self.window_size = new_size;
|
||||
}
|
||||
|
||||
/// Called when the window exits from fullscreen mode
|
||||
fn handle_exit_fullscreen_msg(
|
||||
&mut self,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
) {
|
||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||
self.switch_fullscreen_mode(browsing_context_id);
|
||||
}
|
||||
|
||||
/// Handle updating actual viewport / zoom due to @viewport rules
|
||||
fn handle_viewport_constrained_msg(
|
||||
&mut self,
|
||||
|
@ -3900,6 +3912,25 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// Handle switching from fullscreen mode
|
||||
fn switch_fullscreen_mode(&mut self, browsing_context_id: BrowsingContextId) {
|
||||
if let Some(browsing_context) = self.browsing_contexts.get(&browsing_context_id) {
|
||||
let pipeline_id = browsing_context.pipeline_id;
|
||||
let pipeline = match self.pipelines.get(&pipeline_id) {
|
||||
None => {
|
||||
return warn!(
|
||||
"Pipeline {:?} switched from fullscreen mode after closing.",
|
||||
pipeline_id
|
||||
)
|
||||
},
|
||||
Some(pipeline) => pipeline,
|
||||
};
|
||||
let _ = pipeline
|
||||
.event_loop
|
||||
.send(ConstellationControlMsg::ExitFullScreen(pipeline.id));
|
||||
}
|
||||
}
|
||||
|
||||
// Close a browsing context (and all children)
|
||||
fn close_browsing_context(
|
||||
&mut self,
|
||||
|
|
|
@ -3211,7 +3211,7 @@ impl Document {
|
|||
|
||||
let window = self.window();
|
||||
// Step 8
|
||||
let event = EmbedderMsg::SetFullscreenState(true);
|
||||
let event = EmbedderMsg::SetFullscreenState(false);
|
||||
self.send_to_embedder(event);
|
||||
|
||||
// Step 9
|
||||
|
|
|
@ -1304,6 +1304,10 @@ impl ScriptThread {
|
|||
// An event came-in from a document that is not fully-active, it has been stored by the task-queue.
|
||||
// Continue without adding it to "sequential".
|
||||
},
|
||||
FromConstellation(ConstellationControlMsg::ExitFullScreen(id)) => self
|
||||
.profile_event(ScriptThreadEventCategory::ExitFullscreen, Some(id), || {
|
||||
self.handle_exit_fullscreen(id);
|
||||
}),
|
||||
_ => {
|
||||
sequential.push(event);
|
||||
},
|
||||
|
@ -1500,6 +1504,7 @@ impl ScriptThread {
|
|||
Reload(id, ..) => Some(id),
|
||||
WebVREvents(id, ..) => Some(id),
|
||||
PaintMetric(..) => None,
|
||||
ExitFullScreen(id, ..) => Some(id),
|
||||
}
|
||||
},
|
||||
MixedMessage::FromDevtools(_) => None,
|
||||
|
@ -1731,6 +1736,7 @@ impl ScriptThread {
|
|||
msg @ ConstellationControlMsg::Viewport(..) |
|
||||
msg @ ConstellationControlMsg::SetScrollState(..) |
|
||||
msg @ ConstellationControlMsg::Resize(..) |
|
||||
msg @ ConstellationControlMsg::ExitFullScreen(..) |
|
||||
msg @ ConstellationControlMsg::ExitScriptThread => {
|
||||
panic!("should have handled {:?} already", msg)
|
||||
},
|
||||
|
@ -1953,6 +1959,19 @@ impl ScriptThread {
|
|||
warn!("resize sent to nonexistent pipeline");
|
||||
}
|
||||
|
||||
// exit_fullscreen creates a new JS promise object, so we need to have entered a compartment
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_viewport(&self, id: PipelineId, rect: Rect<f32>) {
|
||||
let document = self.documents.borrow().find_document(id);
|
||||
if let Some(document) = document {
|
||||
|
|
|
@ -262,6 +262,8 @@ pub enum ConstellationControlMsg {
|
|||
Resize(PipelineId, WindowSizeData, WindowSizeType),
|
||||
/// Notifies script that window has been resized but to not take immediate action.
|
||||
ResizeInactive(PipelineId, WindowSizeData),
|
||||
/// Window switched from fullscreen mode.
|
||||
ExitFullScreen(PipelineId),
|
||||
/// Notifies the script that the document associated with this pipeline should 'unload'.
|
||||
UnloadDocument(PipelineId),
|
||||
/// Notifies the script that a pipeline should be closed.
|
||||
|
@ -388,6 +390,7 @@ impl fmt::Debug for ConstellationControlMsg {
|
|||
Reload(..) => "Reload",
|
||||
WebVREvents(..) => "WebVREvents",
|
||||
PaintMetric(..) => "PaintMetric",
|
||||
ExitFullScreen(..) => "ExitFullScreen",
|
||||
};
|
||||
write!(formatter, "ConstellationControlMsg::{}", variant)
|
||||
}
|
||||
|
@ -782,6 +785,8 @@ pub enum ConstellationMsg {
|
|||
EnableProfiler(Duration, Duration),
|
||||
/// Disable the sampling profiler.
|
||||
DisableProfiler,
|
||||
/// Request to exit from fullscreen mode
|
||||
ExitFullScreen(TopLevelBrowsingContextId),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ConstellationMsg {
|
||||
|
@ -811,6 +816,7 @@ impl fmt::Debug for ConstellationMsg {
|
|||
SetCursor(..) => "SetCursor",
|
||||
EnableProfiler(..) => "EnableProfiler",
|
||||
DisableProfiler => "DisableProfiler",
|
||||
ExitFullScreen(..) => "ExitFullScreen",
|
||||
};
|
||||
write!(formatter, "ConstellationMsg::{}", variant)
|
||||
}
|
||||
|
|
|
@ -401,6 +401,13 @@ where
|
|||
self.compositor.maybe_start_shutting_down();
|
||||
},
|
||||
|
||||
WindowEvent::ExitFullScreen(top_level_browsing_context_id) => {
|
||||
let msg = ConstellationMsg::ExitFullScreen(top_level_browsing_context_id);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!("Sending exit fullscreen to constellation failed ({:?}).", e);
|
||||
}
|
||||
},
|
||||
|
||||
WindowEvent::Reload(top_level_browsing_context_id) => {
|
||||
let msg = ConstellationMsg::Reload(top_level_browsing_context_id);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
|
|
|
@ -159,7 +159,15 @@ impl Browser {
|
|||
}
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::Escape, || {
|
||||
self.event_queue.push(WindowEvent::Quit);
|
||||
let state = self.window.get_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);
|
||||
}
|
||||
})
|
||||
.otherwise(|| self.platform_handle_key(key_event));
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ impl Window {
|
|||
match self.kind {
|
||||
WindowKind::Window(ref window, ..) => {
|
||||
if self.fullscreen.get() != state {
|
||||
window.set_fullscreen(None);
|
||||
window.set_fullscreen(Some(window.get_primary_monitor()));
|
||||
}
|
||||
},
|
||||
WindowKind::Headless(..) => {},
|
||||
|
@ -337,6 +337,10 @@ impl Window {
|
|||
self.fullscreen.set(state);
|
||||
}
|
||||
|
||||
pub fn get_fullscreen(&self) -> bool {
|
||||
return self.fullscreen.get();
|
||||
}
|
||||
|
||||
fn is_animating(&self) -> bool {
|
||||
self.animation_state.get() == AnimationState::Animating && !self.suspended.get()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue