Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
redox-os
orbital
Commits
78c6f9ed
Verified
Commit
78c6f9ed
authored
Aug 10, 2019
by
Jeremy Soller
Browse files
WIP: Add mouse cursor visibility, mouse grabbing, and mouse relative mode
parent
1762355c
Changes
3
Hide whitespace changes
Inline
Side-by-side
orbital-core/src/lib.rs
View file @
78c6f9ed
...
...
@@ -124,6 +124,12 @@ pub trait Handler {
flags
:
&
str
,
title
:
String
)
->
syscall
::
Result
<
usize
>
;
/// Called when the scheme is read for events
fn
handle_window_read
(
&
mut
self
,
orb
:
&
mut
Orbital
,
id
:
usize
,
buf
:
&
mut
[
Event
])
->
syscall
::
Result
<
usize
>
;
/// Called when the window asks to set mouse cursor visibility
fn
handle_window_mouse_cursor
(
&
mut
self
,
orb
:
&
mut
Orbital
,
id
:
usize
,
visible
:
bool
)
->
syscall
::
Result
<
()
>
;
/// Called when the window asks to set mouse grabbing
fn
handle_window_mouse_grab
(
&
mut
self
,
orb
:
&
mut
Orbital
,
id
:
usize
,
grab
:
bool
)
->
syscall
::
Result
<
()
>
;
/// Called when the window asks to set mouse relative mode
fn
handle_window_mouse_relative
(
&
mut
self
,
orb
:
&
mut
Orbital
,
id
:
usize
,
relative
:
bool
)
->
syscall
::
Result
<
()
>
;
/// Called when the window asks to be repositioned
fn
handle_window_position
(
&
mut
self
,
orb
:
&
mut
Orbital
,
id
:
usize
,
x
:
Option
<
i32
>
,
y
:
Option
<
i32
>
)
->
syscall
::
Result
<
()
>
;
/// Called when the window asks to be resized
...
...
@@ -397,6 +403,33 @@ impl<H: Handler> SchemeMut for OrbitalHandler<H> {
(
kind
,
data
)
};
match
kind
{
"M"
=>
match
data
{
"C,0"
=>
{
self
.handler
.handle_window_mouse_cursor
(
&
mut
self
.orb
,
id
,
false
)
?
;
Ok
(
buf
.len
())
},
"C,1"
=>
{
self
.handler
.handle_window_mouse_cursor
(
&
mut
self
.orb
,
id
,
true
)
?
;
Ok
(
buf
.len
())
},
"G,0"
=>
{
self
.handler
.handle_window_mouse_grab
(
&
mut
self
.orb
,
id
,
false
)
?
;
Ok
(
buf
.len
())
}
"G,1"
=>
{
self
.handler
.handle_window_mouse_grab
(
&
mut
self
.orb
,
id
,
true
)
?
;
Ok
(
buf
.len
())
},
"R,0"
=>
{
self
.handler
.handle_window_mouse_relative
(
&
mut
self
.orb
,
id
,
false
)
?
;
Ok
(
buf
.len
())
},
"R,1"
=>
{
self
.handler
.handle_window_mouse_relative
(
&
mut
self
.orb
,
id
,
true
)
?
;
Ok
(
buf
.len
())
},
_
=>
Err
(
syscall
::
Error
::
new
(
EINVAL
)),
},
"P"
=>
{
let
mut
parts
=
data
.split
(
','
);
let
x
=
parts
.next
()
.unwrap_or
(
""
)
.parse
::
<
i32
>
()
.ok
();
...
...
src/scheme.rs
View file @
78c6f9ed
...
...
@@ -193,6 +193,30 @@ impl Handler for OrbitalScheme {
Err
(
Error
::
new
(
EBADF
))
}
}
fn
handle_window_mouse_cursor
(
&
mut
self
,
_orb
:
&
mut
Orbital
,
id
:
usize
,
visible
:
bool
)
->
syscall
::
Result
<
()
>
{
if
let
Some
(
window
)
=
self
.windows
.get_mut
(
&
id
)
{
window
.mouse_cursor
=
visible
;
Ok
(())
}
else
{
Err
(
Error
::
new
(
EBADF
))
}
}
fn
handle_window_mouse_grab
(
&
mut
self
,
_orb
:
&
mut
Orbital
,
id
:
usize
,
grab
:
bool
)
->
syscall
::
Result
<
()
>
{
if
let
Some
(
window
)
=
self
.windows
.get_mut
(
&
id
)
{
window
.mouse_grab
=
grab
;
Ok
(())
}
else
{
Err
(
Error
::
new
(
EBADF
))
}
}
fn
handle_window_mouse_relative
(
&
mut
self
,
_orb
:
&
mut
Orbital
,
id
:
usize
,
relative
:
bool
)
->
syscall
::
Result
<
()
>
{
if
let
Some
(
window
)
=
self
.windows
.get_mut
(
&
id
)
{
window
.mouse_relative
=
relative
;
Ok
(())
}
else
{
Err
(
Error
::
new
(
EBADF
))
}
}
fn
handle_window_position
(
&
mut
self
,
_orb
:
&
mut
Orbital
,
id
:
usize
,
x
:
Option
<
i32
>
,
y
:
Option
<
i32
>
)
->
syscall
::
Result
<
()
>
{
if
let
Some
(
window
)
=
self
.windows
.get_mut
(
&
id
)
{
window
.x
=
x
.unwrap_or
(
window
.x
);
...
...
src/window.rs
View file @
78c6f9ed
...
...
@@ -36,6 +36,9 @@ pub struct Window {
pub
notified_read
:
bool
,
//TODO: implement better clipboard mechanism
pub
clipboard_seek
:
usize
,
pub
mouse_cursor
:
bool
,
pub
mouse_grab
:
bool
,
pub
mouse_relative
:
bool
,
}
impl
Window
{
...
...
@@ -58,6 +61,9 @@ impl Window {
notified_read
:
false
,
//TODO: implement better clipboard mechanism
clipboard_seek
:
0
,
mouse_cursor
:
true
,
mouse_grab
:
false
,
mouse_relative
:
false
,
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment