mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 11:17:15 +03:00
fixup build on windows
This commit is contained in:
parent
6aa575d838
commit
cc2b9507f8
@ -69,7 +69,7 @@ fn to_attr_word(attr: &CellAttributes) -> u16 {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let fg = match attr.foreground {
|
let fg = match attr.foreground() {
|
||||||
ColorAttribute::TrueColorWithDefaultFallback(_) | ColorAttribute::Default => {
|
ColorAttribute::TrueColorWithDefaultFallback(_) | ColorAttribute::Default => {
|
||||||
FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN
|
FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ fn to_attr_word(attr: &CellAttributes) -> u16 {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let bg = match attr.background {
|
let bg = match attr.background() {
|
||||||
ColorAttribute::TrueColorWithDefaultFallback(_) | ColorAttribute::Default => 0,
|
ColorAttribute::TrueColorWithDefaultFallback(_) | ColorAttribute::Default => 0,
|
||||||
ColorAttribute::TrueColorWithPaletteFallback(_, idx)
|
ColorAttribute::TrueColorWithPaletteFallback(_, idx)
|
||||||
| ColorAttribute::PaletteIndex(idx) => ansi_colors!(
|
| ColorAttribute::PaletteIndex(idx) => ansi_colors!(
|
||||||
|
@ -3,13 +3,13 @@ use crate::connection::ConnectionOps;
|
|||||||
use crate::{
|
use crate::{
|
||||||
Clipboard, Dimensions, KeyCode, KeyEvent, Modifiers, MouseButtons, MouseCursor, MouseEvent,
|
Clipboard, Dimensions, KeyCode, KeyEvent, Modifiers, MouseButtons, MouseCursor, MouseEvent,
|
||||||
MouseEventKind, MousePress, Point, Rect, ScreenPoint, WindowDecorations, WindowEvent,
|
MouseEventKind, MousePress, Point, Rect, ScreenPoint, WindowDecorations, WindowEvent,
|
||||||
WindowEventReceiver, WindowEventSender, WindowOps,
|
WindowEventSender, WindowOps,
|
||||||
};
|
};
|
||||||
use anyhow::{bail, Context};
|
use anyhow::{bail, Context};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use config::ConfigHandle;
|
use config::ConfigHandle;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use promise::{Future, Promise};
|
use promise::Future;
|
||||||
use raw_window_handle::windows::WindowsHandle;
|
use raw_window_handle::windows::WindowsHandle;
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||||
use shared_library::shared_library;
|
use shared_library::shared_library;
|
||||||
@ -217,12 +217,10 @@ impl WindowInner {
|
|||||||
let imc = ImmContext::get(self.hwnd.0);
|
let imc = ImmContext::get(self.hwnd.0);
|
||||||
imc.set_position(0, 0);
|
imc.set_position(0, 0);
|
||||||
|
|
||||||
self.events
|
self.events.dispatch(WindowEvent::Resized {
|
||||||
.try_send(WindowEvent::Resized {
|
dimensions: current_dims,
|
||||||
dimensions: current_dims,
|
is_full_screen: self.saved_placement.is_some(),
|
||||||
is_full_screen: self.saved_placement.is_some(),
|
});
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
!same
|
!same
|
||||||
@ -373,7 +371,7 @@ impl Window {
|
|||||||
Ok(hwnd)
|
Ok(hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_window(
|
pub async fn new_window<F>(
|
||||||
class_name: &str,
|
class_name: &str,
|
||||||
name: &str,
|
name: &str,
|
||||||
width: usize,
|
width: usize,
|
||||||
@ -383,9 +381,10 @@ impl Window {
|
|||||||
event_handler: F,
|
event_handler: F,
|
||||||
) -> anyhow::Result<Window>
|
) -> anyhow::Result<Window>
|
||||||
where
|
where
|
||||||
F: 'static + FnMut(WindowEvent),
|
F: 'static + FnMut(WindowEvent, &Window),
|
||||||
{
|
{
|
||||||
let (events, receiver) = async_channel::unbounded();
|
let events = WindowEventSender::new(event_handler);
|
||||||
|
|
||||||
let config = match config {
|
let config = match config {
|
||||||
Some(c) => c.clone(),
|
Some(c) => c.clone(),
|
||||||
None => config::configuration(),
|
None => config::configuration(),
|
||||||
@ -415,6 +414,11 @@ impl Window {
|
|||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let window_handle = Window(hwnd);
|
||||||
|
inner
|
||||||
|
.borrow_mut()
|
||||||
|
.events
|
||||||
|
.assign_window(window_handle.clone());
|
||||||
|
|
||||||
enable_dark_mode(hwnd.0);
|
enable_dark_mode(hwnd.0);
|
||||||
enable_blur_behind(hwnd.0);
|
enable_blur_behind(hwnd.0);
|
||||||
@ -425,10 +429,7 @@ impl Window {
|
|||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(hwnd.clone(), Rc::clone(&inner));
|
.insert(hwnd.clone(), Rc::clone(&inner));
|
||||||
|
|
||||||
let window = Window(hwnd);
|
Ok(window_handle)
|
||||||
// inner.borrow_mut().enable_opengl()?;
|
|
||||||
|
|
||||||
Ok((window, receiver))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,8 +588,7 @@ impl WindowOps for Window {
|
|||||||
Connection::with_window_inner(self.0, move |inner| {
|
Connection::with_window_inner(self.0, move |inner| {
|
||||||
inner
|
inner
|
||||||
.events
|
.events
|
||||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
.dispatch(WindowEvent::Notification(Box::new(t)));
|
||||||
.ok();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -725,7 +725,7 @@ unsafe fn wm_ncdestroy(
|
|||||||
if !raw.is_null() {
|
if !raw.is_null() {
|
||||||
let inner = take_rc_from_pointer(raw);
|
let inner = take_rc_from_pointer(raw);
|
||||||
let mut inner = inner.borrow_mut();
|
let mut inner = inner.borrow_mut();
|
||||||
inner.events.try_send(WindowEvent::Destroyed).ok();
|
inner.events.dispatch(WindowEvent::Destroyed);
|
||||||
inner.hwnd = HWindow(null_mut());
|
inner.hwnd = HWindow(null_mut());
|
||||||
SetWindowLongPtrW(hwnd, GWLP_USERDATA, 0);
|
SetWindowLongPtrW(hwnd, GWLP_USERDATA, 0);
|
||||||
}
|
}
|
||||||
@ -875,8 +875,10 @@ unsafe fn wm_set_focus(
|
|||||||
_lparam: LPARAM,
|
_lparam: LPARAM,
|
||||||
) -> Option<LRESULT> {
|
) -> Option<LRESULT> {
|
||||||
if let Some(inner) = rc_from_hwnd(hwnd) {
|
if let Some(inner) = rc_from_hwnd(hwnd) {
|
||||||
let inner = inner.borrow();
|
inner
|
||||||
inner.events.try_send(WindowEvent::FocusChanged(true)).ok();
|
.borrow_mut()
|
||||||
|
.events
|
||||||
|
.dispatch(WindowEvent::FocusChanged(true));
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -888,15 +890,17 @@ unsafe fn wm_kill_focus(
|
|||||||
_lparam: LPARAM,
|
_lparam: LPARAM,
|
||||||
) -> Option<LRESULT> {
|
) -> Option<LRESULT> {
|
||||||
if let Some(inner) = rc_from_hwnd(hwnd) {
|
if let Some(inner) = rc_from_hwnd(hwnd) {
|
||||||
let inner = inner.borrow();
|
inner
|
||||||
inner.events.try_send(WindowEvent::FocusChanged(false)).ok();
|
.borrow_mut()
|
||||||
|
.events
|
||||||
|
.dispatch(WindowEvent::FocusChanged(false));
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn wm_paint(hwnd: HWND, _msg: UINT, _wparam: WPARAM, _lparam: LPARAM) -> Option<LRESULT> {
|
unsafe fn wm_paint(hwnd: HWND, _msg: UINT, _wparam: WPARAM, _lparam: LPARAM) -> Option<LRESULT> {
|
||||||
if let Some(inner) = rc_from_hwnd(hwnd) {
|
if let Some(inner) = rc_from_hwnd(hwnd) {
|
||||||
let inner = inner.borrow();
|
let mut inner = inner.borrow_mut();
|
||||||
|
|
||||||
let mut ps = PAINTSTRUCT {
|
let mut ps = PAINTSTRUCT {
|
||||||
fErase: 0,
|
fErase: 0,
|
||||||
@ -916,7 +920,7 @@ unsafe fn wm_paint(hwnd: HWND, _msg: UINT, _wparam: WPARAM, _lparam: LPARAM) ->
|
|||||||
EndPaint(hwnd, &mut ps);
|
EndPaint(hwnd, &mut ps);
|
||||||
|
|
||||||
// Ask the app to repaint in a bit
|
// Ask the app to repaint in a bit
|
||||||
inner.events.try_send(WindowEvent::NeedRepaint).ok();
|
inner.events.dispatch(WindowEvent::NeedRepaint);
|
||||||
|
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
@ -1020,8 +1024,10 @@ unsafe fn mouse_button(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->
|
|||||||
mouse_buttons,
|
mouse_buttons,
|
||||||
modifiers,
|
modifiers,
|
||||||
};
|
};
|
||||||
let inner = inner.borrow();
|
inner
|
||||||
inner.events.try_send(WindowEvent::MouseEvent(event)).ok();
|
.borrow_mut()
|
||||||
|
.events
|
||||||
|
.dispatch(WindowEvent::MouseEvent(event));
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -1040,8 +1046,10 @@ unsafe fn mouse_move(hwnd: HWND, _msg: UINT, wparam: WPARAM, lparam: LPARAM) ->
|
|||||||
modifiers,
|
modifiers,
|
||||||
};
|
};
|
||||||
|
|
||||||
let inner = inner.borrow();
|
inner
|
||||||
inner.events.try_send(WindowEvent::MouseEvent(event)).ok();
|
.borrow_mut()
|
||||||
|
.events
|
||||||
|
.dispatch(WindowEvent::MouseEvent(event));
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -1095,8 +1103,10 @@ unsafe fn mouse_wheel(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->
|
|||||||
mouse_buttons,
|
mouse_buttons,
|
||||||
modifiers,
|
modifiers,
|
||||||
};
|
};
|
||||||
let inner = inner.borrow();
|
inner
|
||||||
inner.events.try_send(WindowEvent::MouseEvent(event)).ok();
|
.borrow_mut()
|
||||||
|
.events
|
||||||
|
.dispatch(WindowEvent::MouseEvent(event));
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -1153,7 +1163,7 @@ unsafe fn ime_composition(
|
|||||||
lparam: LPARAM,
|
lparam: LPARAM,
|
||||||
) -> Option<LRESULT> {
|
) -> Option<LRESULT> {
|
||||||
if let Some(inner) = rc_from_hwnd(hwnd) {
|
if let Some(inner) = rc_from_hwnd(hwnd) {
|
||||||
let inner = inner.borrow();
|
let mut inner = inner.borrow_mut();
|
||||||
|
|
||||||
if (lparam as DWORD) & GCS_RESULTSTR == 0 {
|
if (lparam as DWORD) & GCS_RESULTSTR == 0 {
|
||||||
// No finished result; continue with the default
|
// No finished result; continue with the default
|
||||||
@ -1186,7 +1196,7 @@ unsafe fn ime_composition(
|
|||||||
key_is_down: true,
|
key_is_down: true,
|
||||||
}
|
}
|
||||||
.normalize_shift();
|
.normalize_shift();
|
||||||
inner.events.try_send(WindowEvent::KeyEvent(key)).ok();
|
inner.events.dispatch(WindowEvent::KeyEvent(key));
|
||||||
|
|
||||||
return Some(1);
|
return Some(1);
|
||||||
}
|
}
|
||||||
@ -1743,7 +1753,7 @@ unsafe fn key(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option<L
|
|||||||
.normalize_shift()
|
.normalize_shift()
|
||||||
.normalize_ctrl();
|
.normalize_ctrl();
|
||||||
|
|
||||||
inner.events.try_send(WindowEvent::KeyEvent(key)).ok();
|
inner.events.dispatch(WindowEvent::KeyEvent(key));
|
||||||
|
|
||||||
// And then we'll perform normal processing on the
|
// And then we'll perform normal processing on the
|
||||||
// current key press
|
// current key press
|
||||||
@ -1853,7 +1863,7 @@ unsafe fn key(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option<L
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
inner.events.try_send(WindowEvent::KeyEvent(key)).ok();
|
inner.events.dispatch(WindowEvent::KeyEvent(key));
|
||||||
return Some(0);
|
return Some(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1886,14 +1896,10 @@ unsafe fn do_wnd_proc(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->
|
|||||||
WM_ERASEBKGND => Some(1),
|
WM_ERASEBKGND => Some(1),
|
||||||
WM_CLOSE => {
|
WM_CLOSE => {
|
||||||
if let Some(inner) = rc_from_hwnd(hwnd) {
|
if let Some(inner) = rc_from_hwnd(hwnd) {
|
||||||
let inner = inner.borrow();
|
let mut inner = inner.borrow_mut();
|
||||||
if inner.events.try_send(WindowEvent::CloseRequested).is_err() {
|
inner.events.dispatch(WindowEvent::CloseRequested);
|
||||||
// Close it!
|
// Don't let it close
|
||||||
return None;
|
return Some(0);
|
||||||
} else {
|
|
||||||
// Don't let it close
|
|
||||||
return Some(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user