Commit graph

74 commits

Author SHA1 Message Date
Joe Moon be6d2ed3b9 subclass windows in macos so they can be made resizable even with no decorations (#408)
* make windows without decorations resizable and movable in macos

fixes #368

The subclassing logic was copied from servo's fork of glutin:
63026a0f4c/src/api/cocoa/mod.rs (L418)

* remove `isMovableByWindowBackground` and `mouseDownCanMoveWindow`

* revert example changes

* remove resizable mask from decoration: false

* avoid duplicate class declarations

* update changelog

* fix changelog

* changelog whitespace
2018-04-02 19:12:38 -04:00
Osspial bbcd3019e8 Add ability to change the min/max size of windows at runtime (#405)
* Add min/max size setting for win32 and wayland backends

* Implement dynamic min/max size on macos

* Add min/max size setting for x11

* Add empty functions for remaining platforms

* Improved min/max size setting for x11

* Added CHANGELOG entry for new min/max methods

* Added documentation for new min/max methods

* On win32, bound window size to min/max dimensions on window creation

* On win32, force re-check of window size when changing min/max dimensions

* Fix freeze when setting min and max size
2018-03-23 10:35:35 +01:00
Joe Moon ce7a426bb5 323 windowbuilder ext macos (#423)
* macOS: Allow hiding the title from the titlebar

* macOS: Allow making the titlebar transparent

* macOS: Give control over content view size

Allows setting `NSFullSizeContentViewWindowMask` with WindowBuilder.

* macOS: add `.with_titlebar_hidden` to WindowBuilderExt

* macOS: adds `titlebar_buttons_hidden` platform specific attribute
2018-03-22 17:57:35 +01:00
YVT 559681b0ed [macOS] Fix crashes due to the stabilization of the ! (never) type (#428)
Due to the recent changes in the Rust compiler, unconstrained type
variables are now deduced to `!` instead of `()`. There are some
occurrences where `msg_send!` is used without constraining its return
type (relying on the assumption that they would be deduced to be `()`).
As a result, the macOS port of winit stopped working.

This PR fixes this issue (#426) by adding explicit return types to
such uses of `msg_send!`.
2018-03-21 20:36:06 +01:00
Nicholas Lordello f3d43016ad Implement MonitorId::get_hidpi_factor for macOS (#410)
* Implement MonitorId::get_hidpi_factor for macOS

* Added changelog entry
2018-03-06 09:35:04 +01:00
Michael Schumacher 1609808e27 Add support for Caret (^) Key in OSX (de_DE) (#380)
* Add caret key

* Use hex value

* Added caret key support.
2018-01-25 13:32:30 +01:00
Robert Günzler 7e1c70964d [macOS] Move the window if there is no title bar (#382)
* macOS: Move the window if there is no title bar

On macOS by default windows can only be moved by clicking and
dragging on the titlebar, if we spawn a window without one we
need to set the `movableByWindowBackground` property.

Partial fix for #368

* macOS: Make moveByWindowBackground optional

Implements setting the property via WindowBuilderExt:

    WindowBuilder::new()
        .with_decorations(false)
        .with_movable_by_window_background(true)

* Update CHANGELOG
2018-01-22 19:07:51 +01:00
Bryan Gilbert 011720848a Added modifier support to mouse events (#328) 2017-12-26 22:46:28 +01:00
Francesca Sunshine 463f316cb8 Add set_decorations method to Window (#365)
This has been stubbed on all platforms other than X11. The X11 implementation has also been
revised to toggle correctly, as it was previously only able to remove decorations.
2017-12-22 13:50:46 +01:00
stuart nelson 0f14e63b34 Send mouse position after focused/cursorenter events (#349)
* Update mouse pos after cursor enter event

* Update mouse position on windows focus

* Send device_id

* Update other device id

* Fix windows import

* Remove deque for vec

* Just send event

* Use correct push_back method

* Push correct event
2017-11-26 21:43:13 +01:00
Jacob Kiesel cfd087d9a5 Mouse events (#344)
* Explicit mouse-related DeviceEvents

This makes the API more intuitive for common use-cases and allows us
to better propagate platform knowledge of motion semantics.

* Improve event naming consistency

* Clarify axis event forwards-compatibility

* Rename WindowEvent::MouseMoved/Entered/Left to CursorMoved/...

This emphasizes the difference between motion of the host GUI cursor,
as used for clicking on things, and raw mouse(-like) input data, as
used for first-person controls.

* Add support for windows and OSX, fix merging

* Fix warnings and errors on Linux

* Remove unnecessary breaking changes

* Add MouseWheel events to windows and OSX

* Fix bad push call.

* Fix docs, naming, and x11 events

* Remove mutability warning

* Add changelog entry
2017-11-12 21:56:57 +01:00
Andriy Symonovych 37a10e6741 update macos deps (#335) 2017-10-31 11:03:18 +01:00
Chris Tolliday 159364bec3 Impl Clone for EventsLoopProxy (#331) 2017-10-25 20:03:57 +02:00
kryptan 4e4db1749d Make MonitorId::get_position() return (i32, i32) instead of (u32, u32) because it can be negative on Windows (#324) 2017-10-19 19:08:05 +02:00
kryptan 48902297b7 Implement public API for high-DPI (#319)
* Implement public API for high-DPI #105

* Recover get_inner_size_points and get_inner_size_pixels and change their implementation assuming get_inner_size() returns size in pixels

* Update changelog for high-DPI changes
2017-10-17 13:56:38 +02:00
Pedro Côrte-Real 59c33d2c6a Move fullscreen modes to not touch physical resolutions (#270)
* Fix X11 screen resolution change using XrandR

The previous XF86 resolution switching was broken and everything
seems to have moved on to xrandr. Use that instead while cleaning
up the code a bit as well.

* Use XRandR for actual multiscreen support in X11

* Use actual monitor names in X11

* Get rid of ptr::read usage in X11

* Use a bog standard Vec instead of VecDeque

* Get rid of the XRandR mode switching stuff

Wayland has made the decision that apps shouldn't change screen
resolutions and just take the screens as they've been setup. In the
modern world where GPU scaling is cheap and LCD panels are scaling
anyway it makes no sense to make "physical" resolution changes when
software should be taking care of it. This massively simplifies the
code and makes it easier to extend to more niche setups like MST and
videowalls.

* Rename fullscreen options to match new semantics

* Implement XRandR 1.5 support

* Get rid of the FullScreen enum

Moving to just having two states None and Some(MonitorId) and then
being able to set full screen in the current monitor with something
like:

window.set_fullscreen(Some(window.current_monitor()));

* Implement Window::get_current_monitor()

Do it by iterating over the available monitors and finding which
has the biggest overlap with the window. For this MonitorId needs
a new get_position() that needs to be implemented for all platforms.

* Add unimplemented get_position() to all MonitorId

* Make get_current_monitor() platform specific

* Add unimplemented get_current_monitor() to all

* Implement proper primary monitor selection in X11

* Shut up some warnings

* Remove libxxf86vm package from travis

Since we're no longer using XF86 there's no need to keep the package
around for CI.

* Don't use new struct syntax

* Fix indentation

* Adjust Android/iOS fullscreen/maximized

On Android and iOS we can assume single screen apps that are already
fullscreen and maximized so there are a few methods that are implemented
by just returning a fixed value or not doing anything.

* Mark OSX/Win fullscreen/maximized unimplemented()!

These would be safe as no-ops but we should make it explicit so
there is more of an incentive to actually implement them.
2017-09-07 10:33:46 +02:00
tomaka 342d5d8587 Remove api_transition macro (#279)
* Remove api_transition macro

* Rename Window2 to Window

* Try fix X11 code
2017-09-06 17:32:24 +02:00
tomaka 3d1c18ded9 Events loop backend (#269)
* Don't use UNIX_BACKEND in Window2::new

* Move get_available_monitors and get_primary_monitor to EventsLoop

* Remove UNIX_BACKEND

* Restore choosing the Linux backend

* Return a XNotSupported for new_x11()

* Fix fullscreen example
2017-09-01 11:04:57 +02:00
tomaka 7dc6fcdedc Rework MonitorId::get_native_identifier (#267)
* Rework MonitorId::get_native_identifier

* Try fix compilation

* Returns the monitor ID on wayland as well

* Try fix compilation

* Fix iOS compilation
2017-08-30 08:49:18 +02:00
Pedro Côrte-Real 60b575a7c1 Get rid of FullScreenState::get_monitor() 2017-08-29 02:53:13 +01:00
Pedro Côrte-Real 9693f7caa9 Convert new fullscreen API in all platforms 2017-08-29 02:16:16 +01:00
Pedro Côrte-Real b35c4a5ee5 maximized/fullscreen as noops for other platforms 2017-08-28 02:23:55 +01:00
tomaka 200ef9c307 Merge pull request #244 from robsaunders/mac-file-drag-and-drop
Mac file drag and drop
2017-08-18 11:35:19 +02:00
Tristam MacDonald 15c4641758 Unwrap axis id in raw mouse motion on Mac 2017-07-29 08:11:46 -07:00
Tristam MacDonald 6820e2a826 Implement raw mouse motion for Mac 2017-07-29 08:04:37 -07:00
Tristam MacDonald ed761bef7d Also hide the cursor when grabbed 2017-07-29 08:04:37 -07:00
Rob Saunders 06e01e4cb3 Added event for cancelling a drag and drop. 2017-07-27 10:56:34 +08:00
Rob Saunders 5f00028f6b Mac module emits the winit events DroppedFile and HoveredFile. 2017-07-27 10:51:00 +08:00
Rob Saunders 4ef7c71c66 Initial drag and drop support for Mac OS, printing filenames to stdout. 2017-07-27 00:59:42 +08:00
Brendan Zabarauskas 886eab5c7e Fix build on nightly
Nightly recently fixed some soundness issues related to `Sized`. This had to be fixed in the cocoa crates as well, and also affects our ios bindings.
2017-07-01 17:48:47 +10:00
mitchmindtree 04ccad1dbc Rename ControlFlow variant from Complete to Break 2017-06-20 21:25:53 +10:00
mitchmindtree 0237526999 Complete macos backend update to addition of ControlFlow 2017-06-09 22:13:30 +10:00
mitchmindtree c5b9bd3612 Update macos backend to addition of ControlFlow (untested) 2017-06-09 19:40:22 +10:00
mitchmindtree 339318f295 Update macOS backend to removal of Send+Sync and addition of EventsLoopProxy 2017-05-31 15:00:49 +10:00
Joe Wilm 0b75a6b60c Make keyboard input event order consistent
All platforms should now receive events in the following order:

1. KeyboardInput(ElementState::Pressed, ..)
2. ReceivedCharacter
3. KeyboardInput(ElementState::Released, ..)

cc https://github.com/tomaka/glutin/issues/878
2017-05-07 21:16:48 -07:00
Benjamin Saunders 22bc119cd7 Richer input events
This expands input events to represent sub-pixel mouse positions, devices responsible for generating events, and raw
device-oriented events. The X11 back end is refactored to make full use of the new expressiveness. Other backends have
had new functionality minimally stubbed out, save for the macos backend which already supports sub-pixel mouse
positions.
2017-04-23 01:08:15 -07:00
mitchmindtree cccc48b84d [macos] Emit a resize event when Window changes screens 2017-03-19 20:30:54 +11:00
mitchmindtree 4656540417 Close NSWindow when Window is dropped if not already closed.
Previously, if a `Window` was `Drop`ped while open, the window would
remain open until the user pressed the x button. This fixes the
behaviour so that the window is closed when dropped if it has not
already been closed.
2017-03-19 19:32:24 +11:00
mitchmindtree 27bd796c2a [macos] Remove Window from EventsLoop's Window list on close and drop
Previously, a Window was only removed from the list when dropped.
2017-03-19 19:20:38 +11:00
mitchmindtree 41e7572147 [macos] Avoid panic when callback is None.
This can happen when window is destroyed/created during a call to user
callback as this causes WindowDelegate method to be called.

Instead if the user callback is `None` store the event in
`pending_events`.
2017-03-19 19:09:20 +11:00
mitchmindtree 4b39f81621 Avoid leaking Windows by storing Weak pointers in EventsLoop 2017-03-19 18:19:24 +11:00
Gabriel Martinez deeda59689 Clean up macOS window style logic
* Remove NSTitledWindowMask for windows with no decorations. This
makes sure that they do not have a title bar.
* Transparency is not be taken into account as we could have a window
with a titlebar or without that is transparent.
2017-03-05 14:50:39 -08:00
Erik Rigtorp 290040dbd8 Implement KeyboardEvent ModifiersState for macOS 2017-02-27 13:38:47 -06:00
Erik Rigtorp f3ccdb7aec Add keyboard modifiers to input event
Making applications track modifier keys results in unnecessary work for
consumers, it's error prone, and it turns out to have unavoidable bugs.
For example, alt-tabbing with x11 results in the alt modifier state
getting stuck.

To resolve these problems, this patch adds a Mods value to the keyboard
input event.

Based on this patch: d287fa96e3
2017-02-27 13:36:11 -06:00
mitchmindtree 24b44e3b8e Remove confusingly named event import alias 2017-02-05 20:41:26 +11:00
mitchmindtree ba71f6fb77 Add missing unsafe block to check for main thread macOS 2017-02-05 19:53:13 +11:00
mitchmindtree 926e03039f Panic if the user attempts to create window on non-main thread 2017-02-05 19:47:39 +11:00
mitchmindtree b62ecfd517 Fix comments on macOS backend UserCallback methods 2017-02-05 19:37:00 +11:00
mitchmindtree 30e00f0454 Fix comment on event conversion special case 2017-02-05 19:21:51 +11:00
mitchmindtree 06c1b5903b Fix bug where an NSEvent is produced when a user opens spotlight while
the NSApplication is in focus.

This NSEvent produces an undocumented NSEventType value `21` that has no
associated variant within the cocoa-rs crate's `NSEventType` enum, thus
causing a segfault when attemptingt to match on the value.

This commit adds a check for `21` to avoid the segfault.

This fixes #104.
2017-02-05 19:01:27 +11:00