Skip to content

Commit

Permalink
feat: Allow disabling action keys on slop selection (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Dec 10, 2020
1 parent 612bf61 commit 35cf674
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Allow disabling action keys on slop selection ([#12](https://github.com/orhun/menyoki/issues/12))

### Fixed
- Use the parent window on invalid child geometry ([#6](https://github.com/orhun/menyoki/issues/6))

Expand Down
16 changes: 15 additions & 1 deletion src/record/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct RecordFlag {
pub alpha: bool,
pub keys: Option<&'static str>,
pub font: Option<&'static str>,
pub select: bool,
}

/* Default initialization values for RecordFlag */
Expand All @@ -83,6 +84,7 @@ impl Default for RecordFlag {
alpha: false,
keys: Some(""),
font: None,
select: true,
}
}
}
Expand All @@ -94,9 +96,15 @@ impl RecordFlag {
* @param alpha
* @param keys (Option)
* @param font (Option)
* @param select
* @return RecordFlag
*/
pub fn new(alpha: bool, keys: Option<&'static str>, font: &str) -> Self {
pub fn new(
alpha: bool,
keys: Option<&'static str>,
font: &str,
select: bool,
) -> Self {
Self {
alpha,
keys,
Expand All @@ -105,6 +113,7 @@ impl RecordFlag {
} else {
Some(Box::leak(font.to_string().into_boxed_str()))
},
select,
}
}
}
Expand Down Expand Up @@ -261,6 +270,11 @@ impl RecordSettings {
))
},
matches.value_of("font").unwrap_or_default(),
if matches.value_of("size").unwrap_or_default().contains('+') {
matches.is_present("select")
} else {
true
},
),
RecordWindow::from_args(&matches),
),
Expand Down
3 changes: 3 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ impl<'a> AppSettings<'a> {
);
}
}
if !self.record.flag.select {
self.record.border = None;
}
if self.save.file.format == FileFormat::Ico {
self.set_icon_size()
}
Expand Down
15 changes: 10 additions & 5 deletions src/x11/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ impl Display {
let start_time = Instant::now();
while !input_state.check_action_keys() {
window = self.get_window().0;
window.draw_borders();
window.show_text_centered(Some(window.area.to_string()), font);
if self.settings.flag.select {
window.draw_borders();
window.show_text_centered(Some(window.area.to_string()), font);
}
let reset_area =
self.update_area(window, input_state, &mut change_factor);
if input_state.check_cancel_keys() {
Expand All @@ -202,7 +204,7 @@ impl Display {
xid = None;
break;
} else if xid != Some(window.xid) || reset_area {
if !reset_area {
if !reset_area && self.settings.flag.select {
debug!("Window ID: {}", window.xid);
info!("{}", window);
}
Expand All @@ -218,13 +220,16 @@ impl Display {
self.get_symbol_from_keycode(&input_state.action_keys.main_key),
);
xid = Some(window.xid);
} else if !self.settings.flag.select {
break;
}
thread::sleep(Duration::from_millis(self.settings.time.interval));
}
trace!("{:?}", input_state);
debug!("Selected window: {:?}", xid);
if self.settings.border.is_some()
|| (self.settings.border.is_none() && self.settings.time.countdown == 0)
if (self.settings.border.is_some()
|| (self.settings.border.is_none() && self.settings.time.countdown == 0))
&& self.settings.flag.select
{
window.clear_area();
window.show_text(Some(String::from(" ")), FpsClock::new(500));
Expand Down

0 comments on commit 35cf674

Please sign in to comment.