Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
orbutils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
orbutils
Commits
27b59f74
Commit
27b59f74
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Update to new orbclient events
parent
65a15a90
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/browser/main.rs
+35
-27
35 additions, 27 deletions
src/browser/main.rs
src/launcher/main.rs
+157
-120
157 additions, 120 deletions
src/launcher/main.rs
with
192 additions
and
147 deletions
src/browser/main.rs
+
35
−
27
View file @
27b59f74
...
...
@@ -566,6 +566,8 @@ fn main_window(arg: &str, font: &Font, font_bold: &Font) {
let
mut
offset
=
(
0
,
0
);
let
mut
max_offset
=
(
0
,
0
);
let
mut
mouse_x
=
0
;
let
mut
mouse_y
=
0
;
let
mut
mouse_down
=
false
;
let
mut
reload
=
true
;
...
...
@@ -656,40 +658,46 @@ fn main_window(arg: &str, font: &Font, font_bold: &Font) {
_
=>
()
}
},
EventOption
::
Mouse
(
mouse_event
)
=>
if
mouse_event
.left_button
{
mouse_down
=
true
;
}
else
if
mouse_down
{
mouse_down
=
false
;
let
mut
link_opt
=
None
;
for
block
in
blocks
.iter
()
{
if
block
.contains
(
mouse_event
.x
,
mouse_event
.y
,
offset
)
{
println!
(
"Click {}"
,
block
.string
);
if
let
Some
(
ref
link
)
=
block
.link
{
link_opt
=
Some
(
link
.clone
());
break
;
EventOption
::
Mouse
(
mouse_event
)
=>
{
mouse_x
=
mouse_event
.x
;
mouse_y
=
mouse_event
.y
;
},
EventOption
::
Button
(
button_event
)
=>
{
if
button_event
.left
{
mouse_down
=
true
;
}
else
if
mouse_down
{
mouse_down
=
false
;
let
mut
link_opt
=
None
;
for
block
in
blocks
.iter
()
{
if
block
.contains
(
mouse_x
,
mouse_y
,
offset
)
{
println!
(
"Click {}"
,
block
.string
);
if
let
Some
(
ref
link
)
=
block
.link
{
link_opt
=
Some
(
link
.clone
());
break
;
}
}
}
}
if
let
Some
(
link
)
=
link_opt
{
if
link
.starts_with
(
'#'
)
{
if
let
Some
(
anchor
)
=
anchors
.get
(
&
link
[
1
..
])
{
println!
(
"Anchor {}: {}"
,
link
,
*
anchor
);
offset
.0
=
0
;
offset
.1
=
*
anchor
;
redraw
=
true
;
if
let
Some
(
link
)
=
link_opt
{
if
link
.starts_with
(
'#'
)
{
if
let
Some
(
anchor
)
=
anchors
.get
(
&
link
[
1
..
])
{
println!
(
"Anchor {}: {}"
,
link
,
*
anchor
);
offset
.0
=
0
;
offset
.1
=
*
anchor
;
redraw
=
true
;
}
else
{
println!
(
"Anchor {} not found"
,
link
);
}
}
else
{
println!
(
"Anchor {} not found"
,
link
);
}
}
else
{
history
.push
(
url
.clone
());
history
.push
(
url
.clone
());
url
=
url
.join
(
&
link
)
.unwrap
();
url
=
url
.join
(
&
link
)
.unwrap
();
println!
(
"Navigate {}: {:#?}"
,
link
,
url
);
println!
(
"Navigate {}: {:#?}"
,
link
,
url
);
reload
=
true
;
reload
=
true
;
}
}
}
},
...
...
This diff is collapsed.
Click to expand it.
src/launcher/main.rs
+
157
−
120
View file @
27b59f74
...
...
@@ -169,127 +169,153 @@ fn bar_main() {
let
mut
window
=
Window
::
new
(
0
,
height
as
i32
-
ICON_SIZE
,
width
,
ICON_SIZE
as
u32
,
""
)
.expect
(
"launcher: failed to open window"
);
let
mut
selected
=
-
1
;
let
mut
last_left_button
=
false
;
let
mut
mouse_x
=
0
;
let
mut
mouse_y
=
0
;
let
mut
mouse_left
=
false
;
let
mut
last_mouse_left
=
false
;
draw
(
&
mut
window
,
&
packages
,
&
start
,
selected
);
'running
:
loop
{
for
event
in
window
.events
()
{
match
event
.to_option
()
{
let
redraw
=
match
event
.to_option
()
{
EventOption
::
Mouse
(
mouse_event
)
=>
{
let
mut
now_selected
=
-
1
;
mouse_x
=
mouse_event
.x
;
mouse_y
=
mouse_event
.y
;
true
},
EventOption
::
Button
(
button_event
)
=>
{
mouse_left
=
button_event
.left
;
true
},
EventOption
::
Quit
(
_
)
=>
break
'running
,
_
=>
false
};
{
let
mut
x
=
0
;
let
y
=
0
;
let
mut
i
=
0
;
{
if
mouse_event
.y
>=
y
&&
mouse_event
.x
>=
x
&&
mouse_event
.x
<
x
+
start
.width
()
as
i32
{
now_selected
=
i
;
}
x
+=
start
.width
()
as
i32
;
i
+=
1
;
}
if
redraw
{
let
mut
now_selected
=
-
1
;
for
package
in
packages
.iter
()
{
if
mouse_event
.y
>=
y
&&
mouse_event
.x
>=
x
&&
mouse_event
.x
<
x
+
package
.icon
.width
()
as
i32
{
now_selected
=
i
;
}
x
+=
package
.icon
.width
()
as
i32
;
i
+=
1
;
{
let
mut
x
=
0
;
let
y
=
0
;
let
mut
i
=
0
;
{
if
mouse_y
>=
y
&&
mouse_x
>=
x
&&
mouse_x
<
x
+
start
.width
()
as
i32
{
now_selected
=
i
;
}
x
+=
start
.width
()
as
i32
;
i
+=
1
;
}
if
now_selected
!=
selected
{
selected
=
now_selected
;
draw
(
&
mut
window
,
&
packages
,
&
start
,
selected
);
for
package
in
packages
.iter
()
{
if
mouse_y
>=
y
&&
mouse_x
>=
x
&&
mouse_x
<
x
+
package
.icon
.width
()
as
i32
{
now_selected
=
i
;
}
x
+=
package
.icon
.width
()
as
i32
;
i
+=
1
;
}
}
if
!
mouse_event
.left_button
&&
last_left_button
{
let
mut
i
=
0
;
if
now_selected
!=
selected
{
selected
=
now_selected
;
draw
(
&
mut
window
,
&
packages
,
&
start
,
selected
);
}
if
i
==
selected
{
let
start_h
=
start_packages
.len
()
as
u32
*
ICON_SMALL_SIZE
as
u32
;
let
mut
start_window
=
Window
::
new
(
0
,
height
as
i32
-
ICON_SIZE
-
start_h
as
i32
,
320
,
start_h
,
""
)
.unwrap
();
let
font
=
Font
::
find
(
Some
(
"Sans"
),
None
,
None
)
.unwrap
();
let
mut
selected
=
-
1
;
let
mut
last_left_button
=
false
;
draw_chooser
(
&
mut
start_window
,
&
font
,
&
start_packages
,
selected
);
'start_choosing
:
loop
{
for
event
in
start_window
.events
()
{
match
event
.to_option
()
{
EventOption
::
Mouse
(
mouse_event
)
=>
{
let
mut
now_selected
=
-
1
;
let
mut
y
=
0
;
for
(
j
,
_package
)
in
start_packages
.iter
()
.enumerate
()
{
if
mouse_event
.y
>=
y
&&
mouse_event
.y
<
y
+
ICON_SMALL_SIZE
{
now_selected
=
j
as
i32
;
}
y
+=
ICON_SMALL_SIZE
;
}
if
!
mouse_left
&&
last_mouse_left
{
let
mut
i
=
0
;
if
i
==
selected
{
let
start_h
=
start_packages
.len
()
as
u32
*
ICON_SMALL_SIZE
as
u32
;
let
mut
start_window
=
Window
::
new
(
0
,
height
as
i32
-
ICON_SIZE
-
start_h
as
i32
,
320
,
start_h
,
""
)
.unwrap
();
let
font
=
Font
::
find
(
Some
(
"Sans"
),
None
,
None
)
.unwrap
();
let
mut
selected
=
-
1
;
let
mut
mouse_y
=
0
;
let
mut
mouse_left
=
false
;
let
mut
last_mouse_left
=
false
;
draw_chooser
(
&
mut
start_window
,
&
font
,
&
start_packages
,
selected
);
'start_choosing
:
loop
{
for
event
in
start_window
.events
()
{
let
redraw
=
match
event
.to_option
()
{
EventOption
::
Mouse
(
mouse_event
)
=>
{
mouse_y
=
mouse_event
.y
;
true
},
EventOption
::
Button
(
button_event
)
=>
{
mouse_left
=
button_event
.left
;
true
},
EventOption
::
Key
(
key_event
)
=>
{
match
key_event
.scancode
{
K_ESC
=>
break
'start_choosing
,
_
=>
false
}
},
EventOption
::
Focus
(
focus_event
)
=>
if
!
focus_event
.focused
{
break
'start_choosing
;
}
else
{
false
},
EventOption
::
Quit
(
_
)
=>
break
'start_choosing
,
_
=>
false
};
if
redraw
{
let
mut
now_selected
=
-
1
;
let
mut
y
=
0
;
for
(
j
,
_package
)
in
start_packages
.iter
()
.enumerate
()
{
if
mouse_y
>=
y
&&
mouse_y
<
y
+
ICON_SMALL_SIZE
{
now_selected
=
j
as
i32
;
}
y
+=
ICON_SMALL_SIZE
;
}
if
now_selected
!=
selected
{
selected
=
now_selected
;
draw_chooser
(
&
mut
start_window
,
&
font
,
&
start_packages
,
selected
);
}
if
now_selected
!=
selected
{
selected
=
now_selected
;
draw_chooser
(
&
mut
start_window
,
&
font
,
&
start_packages
,
selected
);
}
if
!
mouse_event
.left_button
&&
last_left_button
{
let
mut
y
=
0
;
for
package
in
start_packages
.iter
()
{
if
mouse_event
.y
>=
y
&&
mouse_event
.y
<
y
+
ICON_SMALL_SIZE
{
if
package
.binary
==
"exit"
{
break
'running
;
}
else
{
match
Command
::
new
(
&
package
.binary
)
.spawn
()
{
Ok
(
child
)
=>
children
.push
(
child
),
Err
(
err
)
=>
println!
(
"launcher: failed to launch {}: {}"
,
package
.binary
,
err
)
}
}
break
'start_choosing
;
if
!
mouse_left
&&
last_mouse_left
{
let
mut
y
=
0
;
for
package
in
start_packages
.iter
()
{
if
mouse_y
>=
y
&&
mouse_y
<
y
+
ICON_SMALL_SIZE
{
if
package
.binary
==
"exit"
{
break
'running
;
}
else
{
match
Command
::
new
(
&
package
.binary
)
.spawn
()
{
Ok
(
child
)
=>
children
.push
(
child
),
Err
(
err
)
=>
println!
(
"launcher: failed to launch {}: {}"
,
package
.binary
,
err
)
}
y
+=
ICON_SMALL_SIZE
;
}
break
'start_choosing
;
}
last_left_button
=
mouse_event
.left_button
;
},
EventOption
::
Key
(
key_event
)
=>
{
match
key_event
.scancode
{
K_ESC
=>
break
'start_choosing
,
_
=>
()
}
},
EventOption
::
Focus
(
focus_event
)
=>
if
!
focus_event
.focused
{
break
'start_choosing
;
},
EventOption
::
Quit
(
_
)
=>
break
'start_choosing
,
_
=>
()
y
+=
ICON_SMALL_SIZE
;
}
}
last_mouse_left
=
mouse_left
;
}
}
}
i
+=
1
;
}
i
+=
1
;
for
package
in
packages
.iter
()
{
if
i
==
selected
{
match
Command
::
new
(
&
package
.binary
)
.spawn
()
{
Ok
(
child
)
=>
children
.push
(
child
),
Err
(
err
)
=>
println!
(
"launcher: failed to launch {}: {}"
,
package
.binary
,
err
)
}
for
package
in
packages
.iter
()
{
if
i
==
selected
{
match
Command
::
new
(
&
package
.binary
)
.spawn
()
{
Ok
(
child
)
=>
children
.push
(
child
),
Err
(
err
)
=>
println!
(
"launcher: failed to launch {}: {}"
,
package
.binary
,
err
)
}
i
+=
1
;
}
i
+=
1
;
}
}
last_left_button
=
mouse_event
.left_button
;
},
EventOption
::
Quit
(
_
)
=>
break
'running
,
_
=>
()
last_mouse_left
=
mouse_left
;
}
}
}
...
...
@@ -336,45 +362,56 @@ fn chooser_main(paths: env::Args) {
let
font
=
Font
::
find
(
Some
(
"Sans"
),
None
,
None
)
.expect
(
"launcher: failed to open font"
);
let
mut
selected
=
-
1
;
let
mut
last_left_button
=
false
;
let
mut
mouse_y
=
0
;
let
mut
mouse_left
=
false
;
let
mut
last_mouse_left
=
false
;
draw_chooser
(
&
mut
window
,
&
font
,
&
packages
,
selected
);
'choosing
:
loop
{
for
event
in
window
.events
()
{
match
event
.to_option
()
{
let
redraw
=
match
event
.to_option
()
{
EventOption
::
Mouse
(
mouse_event
)
=>
{
let
mut
now_selected
=
-
1
;
mouse_y
=
mouse_event
.y
;
true
},
EventOption
::
Button
(
button_event
)
=>
{
mouse_left
=
button_event
.left
;
true
},
EventOption
::
Quit
(
_
)
=>
break
'choosing
,
_
=>
false
};
let
mut
y
=
0
;
for
(
i
,
_package
)
in
packages
.iter
()
.enumerate
()
{
if
mouse_event
.y
>=
y
&&
mouse_event
.y
<
y
+
ICON_SIZE
{
now_selected
=
i
as
i32
;
}
y
+=
ICON_SMALL_SIZE
;
}
if
redraw
{
let
mut
now_selected
=
-
1
;
if
now_selected
!=
selected
{
selected
=
now_selected
;
draw_chooser
(
&
mut
window
,
&
font
,
&
packages
,
selected
);
let
mut
y
=
0
;
for
(
i
,
_package
)
in
packages
.iter
()
.enumerate
()
{
if
mouse_y
>=
y
&&
mouse_y
<
y
+
ICON_SIZE
{
now_selected
=
i
as
i32
;
}
y
+=
ICON_SMALL_SIZE
;
}
if
!
mouse_event
.left_button
&&
last_left_button
{
let
mut
y
=
0
;
for
package
in
packages
.iter
()
{
if
mouse_event
.y
>=
y
&&
mouse_event
.y
<
y
+
ICON_SMALL_SIZE
{
if
let
Err
(
err
)
=
Command
::
new
(
&
package
.binary
)
.arg
(
path
)
.spawn
()
{
println!
(
"launcher: failed to launch {}: {}"
,
package
.binary
,
err
);
}
break
'choosing
;
if
now_selected
!=
selected
{
selected
=
now_selected
;
draw_chooser
(
&
mut
window
,
&
font
,
&
packages
,
selected
);
}
if
!
mouse_left
&&
last_mouse_left
{
let
mut
y
=
0
;
for
package
in
packages
.iter
()
{
if
mouse_y
>=
y
&&
mouse_y
<
y
+
ICON_SMALL_SIZE
{
if
let
Err
(
err
)
=
Command
::
new
(
&
package
.binary
)
.arg
(
path
)
.spawn
()
{
println!
(
"launcher: failed to launch {}: {}"
,
package
.binary
,
err
);
}
y
+=
ICON_SMALL_SIZE
;
break
'choosing
;
}
y
+=
ICON_SMALL_SIZE
;
}
}
last_left_button
=
mouse_event
.left_button
;
},
EventOption
::
Quit
(
_
)
=>
break
'choosing
,
_
=>
()
last_mouse_left
=
mouse_left
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment