attach to console on startup

macos-click-through
Keith Simmons 3 years ago
parent 4982c2615e
commit b78a714be0

@ -134,11 +134,13 @@ pub fn handle_command_line_arguments(args: Vec<String>) -> Result<(), String> {
Arg::with_name("wayland_app_id") Arg::with_name("wayland_app_id")
.long("wayland-app-id") .long("wayland-app-id")
.takes_value(true) .takes_value(true)
.help("Specify an App ID for Wayland"),
) )
.arg( .arg(
Arg::with_name("x11_wm_class") Arg::with_name("x11_wm_class")
.long("x11-wm-class") .long("x11-wm-class")
.takes_value(true) .takes_value(true)
.help("Specify an X11 WM class"),
); );
let matches = clapp.get_matches_from(args); let matches = clapp.get_matches_from(args);

@ -117,6 +117,9 @@ fn main() {
// Multiple other parts of the app "queue_next_frame" function to ensure animations continue // Multiple other parts of the app "queue_next_frame" function to ensure animations continue
// properly or updates to the graphics are pushed to the screen. // properly or updates to the graphics are pushed to the screen.
#[cfg(target_os = "windows")]
windows_attach_to_console();
//Will exit if -h or -v //Will exit if -h or -v
if let Err(err) = cmd_line::handle_command_line_arguments(args().collect()) { if let Err(err) = cmd_line::handle_command_line_arguments(args().collect()) {
eprintln!("{}", err); eprintln!("{}", err);
@ -244,3 +247,13 @@ fn handle_macos() {
} }
} }
} }
#[cfg(target_os = "windows")]
fn windows_attach_to_console() {
// Attach to parent console tip found here: https://github.com/rust-lang/rust/issues/67159#issuecomment-987882771
use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS};
unsafe {
AttachConsole(ATTACH_PARENT_PROCESS);
}
}

Loading…
Cancel
Save