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

Revert 466 window resize mouse up fix #470

Merged
merged 5 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- Implemented `Refresh` event on Windows.
- Properly calculate the minimum and maximum window size on Windows, including window decorations.
- Map more `MouseCursor` variants to cursor icons on Windows.
- Discard the stray mouse down event being delivered after window resize on macOS.
- Corrected `get_position` on macOS to return outer frame position, not content area position.
- Corrected `set_position` on macOS to set outer frame position, not content area position.
- Added `get_inner_position` method to `Window`, which gets the position of the window's client area. This is implemented on all applicable platforms (all desktop platforms other than Wayland, where this isn't possible).
Expand Down
26 changes: 2 additions & 24 deletions src/platform/macos/events_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::collections::VecDeque;
use std::sync::{Arc, Mutex, Weak};
use super::window::Window2;
use std;
use std::cell::RefCell;
use super::DeviceId;


Expand All @@ -19,7 +18,6 @@ pub struct EventsLoop {
pub struct Shared {
pub windows: Mutex<Vec<Weak<Window2>>>,
pub pending_events: Mutex<VecDeque<Event>>,
pub discard_event: RefCell<bool>,
// The user event callback given via either of the `poll_events` or `run_forever` methods.
//
// We store the user's callback here so that it may be accessed by each of the window delegate
Expand Down Expand Up @@ -57,7 +55,6 @@ impl Shared {
Shared {
windows: Mutex::new(Vec::new()),
pending_events: Mutex::new(VecDeque::new()),
discard_event: RefCell::new(false),
user_callback: UserCallback { mutex: Mutex::new(None) },
}
}
Expand Down Expand Up @@ -102,19 +99,6 @@ impl Shared {
}
}

// Instructs the `EventsLoop` to discard the next input event.
//
// This is called when the window is resized, to avoid a delayed mouse down event being posted
// after the resize completes.
pub fn discard_next_event(&self) {
*self.discard_event.borrow_mut() = true;
}

fn should_discard_next_event(&self) -> bool {
let result = *self.discard_event.borrow();
*self.discard_event.borrow_mut() = false;
result
}
}


Expand Down Expand Up @@ -224,11 +208,7 @@ impl EventsLoop {

match event {
// Call the user's callback.
Some(event) => {
if !self.shared.should_discard_next_event() {
self.shared.user_callback.call_with_event(event);
}
},
Some(event) => self.shared.user_callback.call_with_event(event),
None => break,
}
}
Expand Down Expand Up @@ -281,9 +261,7 @@ impl EventsLoop {
let _: () = msg_send![pool, release];

if let Some(event) = maybe_event {
if !self.shared.should_discard_next_event() {
self.shared.user_callback.call_with_event(event);
}
self.shared.user_callback.call_with_event(event);
if let ControlFlow::Break = control_flow.get() {
break;
}
Expand Down
5 changes: 0 additions & 5 deletions src/platform/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ impl WindowDelegate {
let state: *mut c_void = *this.get_ivar("winitState");
let state = &mut *(state as *mut DelegateState);
emit_resize_event(state);

// discard the pending mouse down event
if let Some(shared) = state.shared.upgrade() {
shared.discard_next_event();
}
}
}

Expand Down