Skip to content

Commit

Permalink
implement x-get-focus-frame
Browse files Browse the repository at this point in the history
  • Loading branch information
harryfei committed May 31, 2020
1 parent 9077139 commit 1143367
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
13 changes: 11 additions & 2 deletions rust_src/src/webrender/display_info.rs
@@ -1,13 +1,22 @@
use libc;
use std::ptr;

use crate::{lisp::ExternalPtr, remacs_sys::wr_display_info};
use crate::{frame::LispFrameRef, lisp::ExternalPtr, remacs_sys::wr_display_info};

use super::term::TerminalRef;

#[derive(Default)]
pub struct DisplayInfoInner {
pub terminal: TerminalRef,
pub focus_frame: LispFrameRef,
}

impl Default for DisplayInfoInner {
fn default() -> Self {
DisplayInfoInner {
terminal: TerminalRef::default(),
focus_frame: LispFrameRef::new(ptr::null_mut()),
}
}
}

pub type DisplayInfoInnerRef = ExternalPtr<DisplayInfoInner>;
Expand Down
13 changes: 12 additions & 1 deletion rust_src/src/webrender/frame.rs
Expand Up @@ -7,7 +7,11 @@ use crate::{
},
};

use super::{display_info::DisplayInfoRef, term::KboardRef};
use super::{
display_info::DisplayInfoRef,
output::{Output, OutputRef},
term::KboardRef,
};

pub fn create_frame(
display: LispObject,
Expand All @@ -30,5 +34,12 @@ pub fn create_frame(
frame.terminal = dpyinfo.get_inner().terminal.as_mut();
frame.set_output_method(output_method::output_wr);

// Remeber to destory the Output object when frame destoried.
let output = Box::new(Output::new());
let mut output = OutputRef::new(Box::into_raw(output));
frame.output_data.wr = output.as_mut();

output.get_inner().display_info = dpyinfo;

frame
}
11 changes: 9 additions & 2 deletions rust_src/src/wrterm.rs
Expand Up @@ -153,10 +153,17 @@ pub extern "C" fn x_focus_frame(frame: LispFrameRef, noactivate: bool) {
// FRAME is used only to get a handle on the X display. We don't pass the
// display info directly because we're called from frame.c, which doesn't
// know about that structure.
#[allow(unused_variables)]
#[no_mangle]
pub extern "C" fn x_get_focus_frame(frame: LispFrameRef) -> LispObject {
unimplemented!();
let output: OutputRef = unsafe { frame.output_data.wr.into() };
let dpyinfo = output.get_inner().display_info;

let focus_frame = dpyinfo.get_inner().focus_frame;

match focus_frame.is_null() {
true => Qnil,
false => focus_frame.into(),
}
}

#[allow(unused_variables)]
Expand Down

0 comments on commit 1143367

Please sign in to comment.