Commit graph

143 commits

Author SHA1 Message Date
Amr Bashir
ab1f636960
feat(Windows): add skip taskbar methods () 2022-04-01 20:21:09 +02:00
Amr Bashir
08de2b3fc4
feat(Windows): add with_msg_hook () 2022-03-30 10:30:45 +02:00
Markus Siglreithmaier
945a9e3122
Windows: Remove owned DC context per window ()
The flag is not required for OpenGL and comes with several limitations when used with other style flags
2022-03-26 22:59:13 +01:00
Johan Andersson
6e28ba8927
Fix fullscreen window messaging race on Windows () 2022-03-26 16:43:13 +01:00
Lucas Kent
7369551c02
Clippy fixes for windows platform () 2022-03-23 19:08:04 +01:00
Mads Marquart
a438091266
Rename internal structs for consistency ()
Proxy -> EventLoopProxy
Id -> WindowId or DeviceId
WindowTarget -> EventLoopWindowTarget
Handle -> MonitorHandle
Mode -> VideoMode
PlatformSpecificBuilderAttributes -> PlatformSpecificWindowBuilderAttributes
SuperWindowId -> RootWindowId
2022-03-18 14:09:39 +01:00
Emil Ernerfeldt
85baf79d17
Reverse horizontal scroll direction () 2022-03-13 14:22:02 +01:00
Clemens Wasser
b222dde835
Adopt windows-sys () 2022-03-07 22:58:12 +01:00
Markus Røyset
40f48cbeb4
Fix unsafe_op_in_unsafe_fn warning on nightly () 2022-02-25 12:27:52 +01:00
Amr Bashir
f9643917d3
feat: add Window::is_visible ()
* feat: add `Window::is_visible`

* use `Option<bool>`

* update doc

* move it right after `set_visible`
2022-02-17 19:44:14 +01:00
Amr Bashir
daf0d6b9a7
feat: add Window::is_resizable ()
* feat: add `Window::is_resizable`

* move it right after `set_resizable`
2022-02-17 16:03:17 +01:00
Amr Bashir
fa14863284
feat: add Window::is_decorated ()
* feat: add `Window::is_decorated`

* move it right after `set_decorations`
2022-02-17 14:31:13 +01:00
Mads Marquart
f3f6f1008a
Add EventLoopBuilder
This commit adds an `EventLoopBuilder` struct to simplify event loop
customization and providing options to it upon creation. It also
deprecates the use of `EventLoop::with_user_event` in favor of the same
method on new builder, and replaces old platforms specific extension
traits with the new ones on the `EventLoopBuilder`.
2022-02-17 00:09:03 +03:00
Lucas Kent
cf4660841a
Update to Rust 2021 Edition () 2022-01-13 06:59:57 +01:00
multisn8
a52f755ce8
Add exit code to ControlFlow::Exit ()
* Add exit code to control flow and impl on linux

* Fix examples to have an exit code

* Fix doc examples to use an exit code

* Improve documentation wording on the exit code

* Add exit code example

* Add exit code on windows

* Change i32 as exit code to u8

This avoids nasty surprises with negative numbers on some unix-alikes
due to two's complement.

* Fix android usages of ControlFlow::Exit

* Fix ios usages of ControlFlow::Exit

* Fix web usages of ControlFlow::Exit

* Add macos exit code

* Add changelog note

* Document exit code on display server disconnection

* Revert "Change i32 as exit code to u8"

This reverts commit f88fba0253b45de6a2ac0c3cbcf01f50503c9396.

* Change Exit to ExitWithCode and make an Exit const

* Revert "Add exit code example"

This reverts commit fbd3d03de9c2d7516c7a63da489c99f498b710df.

* Revert "Fix doc examples to use an exit code"

This reverts commit daabcdf9ef9e16acad715c094ae442529e39fcbc.

* Revert "Fix examples to have an exit code"

This reverts commit 0df486896b8d106acf65ba83c45cc88d60d228e1.

* Fix unix-alike to use ExitWithCode instead of Exit

* Fix windows to use ExitWithCode rather than Exit

* Silence warning about non-uppercase Exit const

* Refactor exit code handling

* Fix macos Exit usage and recover original semantic

* Fix ios to use ExitWithCode instead of Exit

* Update documentation to reflect ExitWithCode

* Fix web to use ExitWithCode when needed, not Exit

* Fix android to use ExitWithCode, not Exit

* Apply documenation nits

* Apply even more documentation nits

* Move change in CHANGELOG.md under "Unreleased"

* Try to use OS error code as exit code on wayland
2022-01-11 01:23:20 +01:00
Shuoliu Yang
25ff30ee8c
Fix transparent window crash on Windows 11 ()
Maybe the transparent setting in WM_NCCREATE on Windows 11 will cause a block when calling DwmEnableBlureBehindWindow and will crash. Puts them into WM_CREATE and it works.
2022-01-03 13:54:31 +01:00
Mads Marquart
11a44081df
macOS move impl details of platform into platform_impl 2021-12-01 14:20:56 +03:00
Mads Marquart
5eb9c9504b
Update raw-window-handle to 0.4.1 ()
* Update raw-window-handle to `0.4.2`

See:
- https://github.com/rust-windowing/raw-window-handle/issues/72
- https://github.com/rust-windowing/raw-window-handle/pull/73
- https://github.com/rust-windowing/raw-window-handle/pull/74

* Clean up raw_window_handle functions a bit
2021-11-30 17:50:23 +01:00
Markus Siglreithmaier
3ecbea3c39
Windows: Split window initialization across NCCREATE and CREATE ()
* Refactor window initialization by splitting NCCREATE and CREATE related tasks.

Fixes issue with invisible owner windows.

* address review comments

* Update src/platform_impl/windows/event_loop.rs

Co-authored-by: Markus Røyset <maroider@protonmail.com>

Co-authored-by: Markus Røyset <maroider@protonmail.com>
2021-11-17 18:33:44 +01:00
Markus Siglreithmaier
cfbe8462cc
Windows: Increase wait timer resolution ()
Windows: Increase wait timer resolution for more accurate timing when using `WaitUntil`.
2021-11-02 21:51:39 +01:00
Philippe Renon
1b3b82a3c1
Clippy fixes ()
* windows: bump winapi version

* windows: address dark_mode FIXMEs

use now available winapi structures

* clippy: fix clippy::upper_case_acronyms warnings

* clippy: fix needless_arbitrary_self_type warnings

* clippy: fix clone_on_copy warnings

* clippy: fix unnecessary_mut_passed warnings

* clippy: fix identity_op warnings

* clippy: fix misc warnings

* prefix rustdoc lints with rustdoc::

the prefix was introduced in Rust 1.52

* windows: silence file_drop_handler is never read warning

* clippy: fix from_over_into warnings

and a bit of naming simplification

* clippy: fix missing_safety_doc warnings

* make dummy() functions const
2021-08-30 19:40:02 +02:00
Markus Siglreithmaier
b87757c552
Fix Window visibility regression ()
On Windows, set windows visible on init before position update

Ensure that the style change is correctly applied, triggering the necessary events.
2021-08-12 18:57:07 +02:00
Osspial
f92803d80e
Prevent ghost window from showing up on taskbar ()
Add WS_EX_TOOLWINDOW to event target window
2021-08-11 20:02:40 +02:00
Markus Røyset
63ad47a7bf
Remove window subclassing ()
* Remove window subclassing

* Always call `DefWindowProcW` when we don't process a message

* Improve window initialization

Note that the error path in `init` is kind of cursed at the moment.

* Rename `ThreadMsgTargetCallbackData` to `ThreadMsgTargetData`

* Simplify window initialization

* Fix compilation on 32-bit targets

* Simplify the creation of the event target window

* Use `.clone()` rather than `Rc::clone()`

* Use concrete types for args to `SetWindowLongPtrW`

On 32-bit targets, `SetWindowLongPtrW` is an alias to `SetWindowLongW`,
which returns `LONG` (`i32`) rather than `LONG_PTR` (`isisze`).

* Minor comment adjustments
2021-07-16 12:40:48 +02:00
i509VCB
1eff7ae004
Document how main_thread_id for Windows works () 2021-06-05 12:46:44 +02:00
Max de Danschutter
b371b406d5
Implemented focus_window () 2021-05-19 18:39:53 +02:00
Rodrigodd
dabcb1834d
On Windows, allow the creation of popup window ()
Add with_owner_window to WindowBuilderExtWindows.
Add set_enable to WindowExtWindows.
2021-04-10 15:47:19 +02:00
Michal Srb
0d634a0061
Add WindowBuilder::with_outer_position () 2021-03-25 19:18:51 +01:00
Norbert Nemec
86748fbc68
Fix communication of fractional RI_MOUSE_WHEEL events (Windows) () 2021-03-11 22:08:29 +01:00
daxpedda
98470393d1
Add dragging window with cursor feature ()
* X11 implementation.

* Introduce example.

* Wayland implementation.

* Windows implementation.

* Improve Wayland seat passing.

* MacOS implementation.

* Correct windows implementation per specification.

* Update dependency smithay-client-toolkit from branch to master.

* Fixed blocking thread in windows implementation.

* Add multi-window example.

* Move Wayland to a different PR.

* Fix CHANGELOG.

* Improve example.

Co-authored-by: Markus Røyset <maroider@protonmail.com>

* Rename `set_drag_window` to `begin_drag`.

* Improve example.

* Fix CHANGELOG.

* Fix CHANGELOG.

Co-authored-by: Markus Røyset <maroider@protonmail.com>

* Rename to `drag_window`.

* Fix typo.

* Re-introduce Wayland implementation.

* Fixing Wayland build.

* Fixing Wayland build.

* Move SCTK to 0.12.3.

Co-authored-by: Markus Røyset <maroider@protonmail.com>
2021-03-07 10:43:23 +01:00
Axel Cocat
10a94c0794
Fix Windows' try_theme returning Theme::Dark when new theme is light () 2021-02-20 00:06:12 +01:00
Björn Steinbrink
dd32ace9ab
Restore the ability to have fully transparent windows on Windows ()
* Restore the ability to have fully transparent windows on Windows

Besides its original purpose, commit 6343059b "Fix Windows transparency
behavior to support fully-opaque regions ()" also included some
changes considered cleanups, one of them was:

* Remove the `CreateRectRgn` call, since we want the entire window's region to
  have blur behind it, and `DwnEnableBlurBehindWindow` does that by default.

But the original code actually disabled the blur effect for the whole
window by creating an empty region for it, because that allows for the
window to be truely fully transparent. With the blur effect in place,
the areas meant to be transparent either blur the things behind it
(until Windows 8) or are darkened (since Windows 8). This also means
that on Windows 8 and newer, the resulting colors are darker than
intended in translucent areas when the blur effect is enabled.

This restores the behaviour from winit <0.24 and fixes .

Arguably, one might want to expose the ability to control the blur
region, but that is outside the scope of this commit.

* Remove useless WS_EX_LAYERED from transparent windows on Windows

`WS_EX_LAYERED` is not supposed to be used in combination with
`CS_OWNDC`. In winit, as it is currently used, `WS_EX_LAYERED` actually
has no effect at all. The only relevant call is to
`SetLayeredWindowAttributes`, which is required to make the window
visible at all with `WS_EX_LAYERED` set, but is called with full
opacity, i.e. there's no transparency involved at all.

The actual transparency is already achieved by using
`DwmEnableBlurBehindWindow`, so `WS_EX_LAYERED` and the call to
`SetLayeredWindowAttributes` can both be removed.
2021-02-17 13:50:24 +01:00
Ssaely
b1be34c6a0
fix cursor blinking when clicking decorations bar on Windows () 2021-02-06 21:10:36 +01:00
Mads Marquart
b1d353180b
Add ability to assign a menu when creating a window on Windows () 2021-02-04 22:26:33 +01:00
Mads Marquart
f79c01b0cf
Fix HINSTANCE returned by raw_window_handle on 64 bit Windows () 2021-01-28 18:51:49 +01:00
Simas Toleikis
3f1e09ec0e
Add Window::is_maximized method () 2021-01-27 19:01:17 +01:00
Markus Røyset
05125029c6
On Windows, fix deadlock caused by mouse capture ()
The issue was caused by calling SetCapture on a window which already
had the capture. The WM_CAPTURECHANGED handler assumed that it would
only run if the capture was lost, but that wasn't the case. This made
the handler to try to lock the window state mutex while it was already
locked.

The issue was introduced in  (932cbe4).
2021-01-19 17:41:02 +01:00
Markus Røyset
9d63fc7ca0
On Windows, set the cursor icon when the cursor first enters a window () 2021-01-05 17:39:13 +01:00
Markus Røyset
38fccebe1f
On Windows, change the default window size () 2020-12-20 17:59:46 +01:00
Markus Røyset
c05952b813
On Windows, improve handling of window destruction () 2020-12-20 12:54:42 +01:00
Samuel
932cbe40bf
On Windows, fix bug causing mouse capture to not be released. () 2020-12-15 07:31:13 +01:00
relrelb
39573d65d0
Windows: Preserve minimized/maximized state in fullscreen () 2020-12-13 19:06:53 +01:00
Viktor Zoutman
6f70fd90b9
Windows: Changed thread_event_target_callback's WM_DESTROY to WM_NCDESTROY () 2020-12-10 12:09:08 +01:00
moko256
db038d943c
On Windows, implement 'Window::set_ime_position' with IMM API 2020-12-09 23:16:59 +03:00
Kirill Chibisov
c5620efc9c
On Wayland, don't drop extra mouse buttons
This commit forwards "unknown" Wayland mouse buttons downstream via
'MouseButton::Other'. Possible values for those could be found in
<linux/input-event-codes.h>.

Also, since Wayland just forwards buttons from the kernel, which are
'u16', we must adjust 'MouseButton::Other' to take 'u16' instead of
'u8'.
2020-12-09 23:11:25 +03:00
Viktor Zoutman
6ddee9a8ac
Ability to force a theme on Windows () 2020-11-30 19:04:26 +01:00
Max de Danschutter
0861a353d6
Add 'request_user_attention' to Window
This commit introduces a cross platform way to request a user attention
to the window via a 'request_user_attention' method on a Window struct.
This method is inspired by macOS's 'request_user_attention' method and
thus reuses its signature and semantics to some extent.
2020-11-27 05:03:08 +03:00
Viktor Zoutman
77d5d20391
Windows: Delayed Message Boxes Fix. () 2020-11-24 23:05:29 +01:00
qthree
66c117e599
[Windows] Fix use after free during window destruction () 2020-10-23 19:04:18 +02:00
Vickles
fbd3918d3a
Add prefix byte for extended scancodes on Windows () 2020-10-19 16:35:01 +02:00