@@ -142,6 +142,10 @@ impl Adapter {
142
142
/// until you send the first update. For an optimal implementation,
143
143
/// consider using [`Adapter::with_direct_handlers`] or
144
144
/// [`Adapter::with_mixed_handlers`] instead.
145
+ ///
146
+ /// # Panics
147
+ ///
148
+ /// Panics if the window is already visible.
145
149
pub fn with_event_loop_proxy < T : From < Event > + Send + ' static > (
146
150
event_loop : & ActiveEventLoop ,
147
151
window : & Window ,
@@ -179,13 +183,21 @@ impl Adapter {
179
183
/// some platform adapters to use a placeholder tree until you send
180
184
/// the first update. However, remember that each of these handlers may be
181
185
/// called on any thread, depending on the underlying platform adapter.
186
+ ///
187
+ /// # Panics
188
+ ///
189
+ /// Panics if the window is already visible.
182
190
pub fn with_direct_handlers (
183
191
event_loop : & ActiveEventLoop ,
184
192
window : & Window ,
185
193
activation_handler : impl ' static + ActivationHandler + Send ,
186
194
action_handler : impl ' static + ActionHandler + Send ,
187
195
deactivation_handler : impl ' static + DeactivationHandler + Send ,
188
196
) -> Self {
197
+ if window. is_visible ( ) == Some ( true ) {
198
+ panic ! ( "The AccessKit winit adapter must be created before the window is shown (made visible) for the first time." ) ;
199
+ }
200
+
189
201
let inner = platform_impl:: Adapter :: new (
190
202
event_loop,
191
203
window,
@@ -208,6 +220,10 @@ impl Adapter {
208
220
/// while using a direct, caller-provided activation handler that can
209
221
/// return the initial tree synchronously. Remember that the thread on which
210
222
/// the activation handler is called is platform-dependent.
223
+ ///
224
+ /// # Panics
225
+ ///
226
+ /// Panics if the window is already visible.
211
227
pub fn with_mixed_handlers < T : From < Event > + Send + ' static > (
212
228
event_loop : & ActiveEventLoop ,
213
229
window : & Window ,
0 commit comments