A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
//! Forçar Encerrar Aplicativos (src\forcar\main.cpp): os apps abertos, "(Não Respondendo)" nos travados, a folha de
//! confirmação e o modo --memoria (ordenado pelo quanto cada app gasta, com os processos filhos).
#![windows_subsystem = "windows"]
use std::collections::HashMap;
use std::ffi::c_void;
use comum::app2d::{self, *};
use comum::windows::core::*;
use comum::windows::Win32::Foundation::*;
use comum::windows::Win32::Graphics::Direct2D::*;
use comum::windows::Win32::Graphics::DirectWrite::*;
use comum::windows::Win32::Graphics::Dwm::*;
use comum::windows::Win32::Storage::FileSystem::*;
use comum::windows::Win32::System::Diagnostics::ToolHelp::*;
use comum::windows::Win32::System::ProcessStatus::*;
use comum::windows::Win32::System::Threading::*;
use comum::windows::Win32::UI::Input::KeyboardAndMouse::*;
use comum::windows::Win32::UI::Controls::WM_MOUSELEAVE;
use comum::windows::Win32::UI::WindowsAndMessaging::*;
use comum::*;
const PAD: f32 = 20.0;
#[derive(Clone, Default)]
struct AppP {
pid: u32,
name: String,
path: String,
hung: bool,
mem: u64,
}
struct Pal {
bg: Cor,
list: Cor,
border: Cor,
text: Cor,
text2: Cor,
sel: Cor,
red: Cor,
btn: Cor,
btn_text: Cor,
dim: Cor,
}
struct Layout {
head: RectF,
list: RectF,
note: RectF,
btn: RectF,
sheet: RectF,
s_cancel: RectF,
s_ok: RectF,
}
#[derive(Default)]
struct St {
apps: Vec<AppP>,
sel: u32,
memory: bool,
sheet: i32,
target: AppP,
hover: i32,
scroll: f32,
icons: HashMap<String, Option<ID2D1Bitmap>>,
icons_rt: usize,
tf: HashMap<&'static str, IDWriteTextFormat>,
}
static A: Global<Option<St>> = Global::new(None);
fn a() -> &'static mut St {
A.get().as_mut().unwrap()
}
fn tf(n: &str) -> &'static IDWriteTextFormat {
&a().tf[n]
}
fn gg() -> bool {
semaforo::aqua()
}
fn row_h() -> f32 {
if gg() {
22.0
} else {
24.0
}
}
fn btn_h() -> f32 {
if gg() {
28.0
} else {
24.0
}
}
fn our_name(exe: &str) -> String {
const T: [(&str, &str, &str); 18] = [
("wacosfinder.exe", "Finder", "Finder"),
("wacossettings.exe", "Ajustes do Sistema", "System Settings"),
("wacosactivitymonitor.exe", "Monitor de Atividade", "Activity Monitor"),
("wacosterminal.exe", "Terminal", "Terminal"),
("wacoscalculator.exe", "Calculadora", "Calculator"),
("wacosnotes.exe", "Notas", "Notes"),
("wacosscreenshot.exe", "Captura de Tela", "Screenshot"),
("wacospreview.exe", "Pré-Visualização", "Preview"),
("wacosreminders.exe", "Lembretes", "Reminders"),
("wacoscalendar.exe", "Calendário", "Calendar"),
("wacostextedit.exe", "TextEdit", "TextEdit"),
("wacosclock.exe", "Relógio", "Clock"),
("wacosweather.exe", "Clima", "Weather"),
("wacoscontacts.exe", "Contatos", "Contacts"),
("wacosphotos.exe", "Fotos", "Photos"),
("wacostimemachine.exe", "Time Machine", "Time Machine"),
("wacosmusic.exe", "Música", "Music"),
("wacosquicktime.exe", "QuickTime Player", "QuickTime Player"),
];
T.iter().find(|t| t.0 == exe).map(|t| tr_pick(t.1, t.2)).unwrap_or_default()
}
fn describe(path: &str) -> String {
unsafe {
let p = wz(path);
let n = GetFileVersionInfoSizeW(pc(&p), None);
if n == 0 {
return String::new();
}
let mut buf = vec![0u8; n as usize];
if GetFileVersionInfoW(pc(&p), 0, n, buf.as_mut_ptr() as *mut c_void).is_err() {
return String::new();
}
let mut lc: *mut u16 = std::ptr::null_mut();
let mut len = 0u32;
if !VerQueryValueW(buf.as_ptr() as *const c_void, w!("\\VarFileInfo\\Translation"), &mut lc as *mut _ as *mut *mut c_void, &mut len).as_bool() || len < 4 {
return String::new();
}
let (lang, cp) = (*lc, *lc.add(1));
let key = wz(&format!("\\StringFileInfo\\{lang:04x}{cp:04x}\\FileDescription"));
let mut v: *mut u16 = std::ptr::null_mut();
if !VerQueryValueW(buf.as_ptr() as *const c_void, pc(&key), &mut v as *mut _ as *mut *mut c_void, &mut len).as_bool() || v.is_null() {
return String::new();
}
from_pcwstr(PCWSTR(v))
}
}
fn path_of(pid: u32) -> String {
unsafe {
let Ok(h) = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) else { return String::new() };
let mut b = [0u16; 1024];
let mut n = b.len() as u32;
let r = if QueryFullProcessImageNameW(h, PROCESS_NAME_WIN32, PWSTR(b.as_mut_ptr()), &mut n).is_ok() { String::from_utf16_lossy(&b[..n as usize]) } else { String::new() };
let _ = CloseHandle(h);
r
}
}
fn private_of(pid: u32) -> u64 {
unsafe {
let Ok(h) = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) else { return 0 };
let mut pm = PROCESS_MEMORY_COUNTERS_EX { cb: std::mem::size_of::<PROCESS_MEMORY_COUNTERS_EX>() as u32, ..Default::default() };
let r = if GetProcessMemoryInfo(h, &mut pm as *mut _ as *mut PROCESS_MEMORY_COUNTERS, pm.cb).is_ok() { pm.PrivateUsage as u64 } else { 0 };
let _ = CloseHandle(h);
r
}
}
fn exe_of(path: &str) -> String {
path.rsplit('\\').next().unwrap_or("").to_lowercase()
}
struct Found {
apps: HashMap<u32, AppP>,
me: u32,
}
extern "system" fn child_pid(c: HWND, l: LPARAM) -> BOOL {
unsafe {
let p = &mut *(l.0 as *mut (u32, u32));
let mut pid = 0;
GetWindowThreadProcessId(c, Some(&mut pid));
if pid != 0 && pid != p.0 {
p.1 = pid;
return FALSE;
}
TRUE
}
}
extern "system" fn on_win(h: HWND, l: LPARAM) -> BOOL {
unsafe {
let f = &mut *(l.0 as *mut Found);
if !IsWindowVisible(h).as_bool() || GetWindow(h, GW_OWNER).map(|o| !o.0.is_null()).unwrap_or(false) {
return TRUE;
}
let st = GetWindowLongW(h, GWL_STYLE) as u32;
let ex = GetWindowLongW(h, GWL_EXSTYLE) as u32;
if ex & WS_EX_TOOLWINDOW.0 != 0 || st & WS_CAPTION.0 != WS_CAPTION.0 {
return TRUE;
}
let mut cl = BOOL(0);
let _ = DwmGetWindowAttribute(h, DWMWA_CLOAKED, &mut cl as *mut _ as *mut c_void, 4);
if cl.as_bool() && !IsIconic(h).as_bool() {
return TRUE;
}
if GetWindowTextLengthW(h) == 0 {
return TRUE;
}
let mut pid = 0;
GetWindowThreadProcessId(h, Some(&mut pid));
if pid == 0 || pid == f.me {
return TRUE;
}
let mut path = path_of(pid);
let mut exe = exe_of(&path);
if exe == "applicationframehost.exe" {
let mut p = (pid, 0u32);
let _ = EnumChildWindows(h, Some(child_pid), LPARAM(&mut p as *mut _ as isize));
if p.1 == 0 {
return TRUE;
}
pid = p.1;
path = path_of(pid);
exe = exe_of(&path);
}
if path.is_empty() || ["explorer.exe", "wacosshell.exe", "wacoswindow32host.exe", "wacosforcequit.exe"].contains(&exe.as_str()) {
return TRUE;
}
let ap = f.apps.entry(pid).or_default();
if ap.pid == 0 {
ap.pid = pid;
ap.path = path.clone();
ap.name = our_name(&exe);
if ap.name.is_empty() {
ap.name = describe(&path);
}
if ap.name.contains('.') && !ap.name.contains(' ') {
let mut t = [0u16; 128];
GetWindowTextW(h, &mut t);
let s = from_w(&t);
if !s.is_empty() && s.chars().count() < 40 {
ap.name = s;
}
}
if ap.name.is_empty() {
let n = path.rsplit('\\').next().unwrap_or("");
ap.name = n.rsplit_once('.').map(|(a, _)| a.to_string()).unwrap_or(n.to_string());
}
}
if IsHungAppWindow(h).as_bool() {
ap.hung = true;
}
TRUE
}
}
fn refresh() {
let mut f = Found { apps: HashMap::new(), me: std::process::id() };
unsafe {
let _ = EnumWindows(Some(on_win), LPARAM(&mut f as *mut _ as isize));
}
let mut parent: HashMap<u32, u32> = HashMap::new();
unsafe {
if let Ok(snap) = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) {
let mut pe = PROCESSENTRY32W { dwSize: std::mem::size_of::<PROCESSENTRY32W>() as u32, ..Default::default() };
let mut ok = Process32FirstW(snap, &mut pe).is_ok();
while ok {
parent.insert(pe.th32ProcessID, pe.th32ParentProcessID);
ok = Process32NextW(snap, &mut pe).is_ok();
}
let _ = CloseHandle(snap);
}
}
if a().memory {
for &pid in parent.keys() {
let mut cur = pid;
for _ in 0..6 {
if cur == 0 {
break;
}
if let Some(ap) = f.apps.get_mut(&cur) {
ap.mem += private_of(pid);
break;
}
match parent.get(&cur) {
Some(&p) if p != cur => cur = p,
_ => break,
}
}
}
}
let mut v: Vec<AppP> = f.apps.into_values().collect();
if a().memory {
v.sort_by(|x, y| y.mem.cmp(&x.mem));
} else {
v.sort_by_key(|x| x.name.to_lowercase());
}
if !v.iter().any(|x| x.pid == a().sel) {
a().sel = 0;
}
a().apps = v;
invalidate();
}
fn icon(path: &str) -> Option<ID2D1Bitmap> {
let rid = app2d::rt().as_raw() as usize;
if a().icons_rt != rid {
a().icons.clear();
a().icons_rt = rid;
}
a().icons.entry(path.to_string()).or_insert_with(|| icon_bitmap(path, true)).clone()
}
fn bytes(b: u64) -> String {
let s = if b >= 1 << 30 { format!("{:.2} GB", b as f64 / 1073741824.0) } else { format!("{:.0} MB", b as f64 / 1048576.0) };
if idioma::decimal_comma() {
s.replace('.', ",")
} else {
s
}
}
fn pal() -> Pal {
let d = dark();
let p = |bg, list, border, text, text2, sel, red, btn, btn_text, dim| Pal { bg, list, border, text, text2, sel, red, btn, btn_text, dim };
if gg() {
if d {
p(rgb(30, 30, 30, 1.0), rgb(30, 30, 30, 1.0), rgb(255, 255, 255, 0.14), rgb(255, 255, 255, 0.88), rgb(255, 255, 255, 0.55), rgb(0, 100, 220, 1.0), rgb(255, 69, 58, 1.0), rgb(255, 255, 255, 0.14), rgb(255, 255, 255, 0.9), rgb(0, 0, 0, 0.35))
} else {
p(rgb(255, 255, 255, 1.0), rgb(255, 255, 255, 1.0), rgb(0, 0, 0, 0.16), rgb(0, 0, 0, 0.85), rgb(0, 0, 0, 0.5), rgb(0, 100, 220, 1.0), rgb(255, 59, 48, 1.0), rgb(0, 0, 0, 0.06), rgb(0, 0, 0, 0.85), rgb(0, 0, 0, 0.18))
}
} else if d {
p(rgb(44, 44, 46, 1.0), rgb(30, 30, 31, 1.0), rgb(255, 255, 255, 0.12), rgb(255, 255, 255, 0.88), rgb(255, 255, 255, 0.55), rgb(0, 88, 208, 1.0), rgb(255, 69, 58, 1.0), rgb(255, 255, 255, 0.16), rgb(255, 255, 255, 0.9), rgb(0, 0, 0, 0.35))
} else {
p(rgb(236, 236, 236, 1.0), rgb(255, 255, 255, 1.0), rgb(0, 0, 0, 0.14), rgb(0, 0, 0, 0.85), rgb(0, 0, 0, 0.5), rgb(0, 100, 225, 1.0), rgb(255, 59, 48, 1.0), rgb(255, 255, 255, 1.0), rgb(0, 0, 0, 0.85), rgb(0, 0, 0, 0.18))
}
}
fn layout() -> Layout {
let s = size();
let head_h = if a().memory { 74.0 } else { 54.0 };
let head = rf(PAD, 14.0, s.width - PAD, 14.0 + head_h);
let list = rf(PAD, head.bottom + 4.0, s.width - PAD, s.height - if gg() { 61.0 } else { 56.0 });
let bw = (text_w(tf("btn"), &tr("Forçar Encerrar")) + if gg() { 36.0 } else { 28.0 }).max(if gg() { 84.0 } else { 110.0 });
let btn = if gg() { rf(s.width - 16.0 - bw, s.height - 16.0 - btn_h(), s.width - 16.0, s.height - 16.0) } else { rf(s.width - PAD - bw, s.height - 40.0, s.width - PAD, s.height - 40.0 + btn_h()) };
let note = rf(PAD, s.height - if gg() { 50.0 } else { 44.0 }, btn.left - 12.0, s.height - 12.0);
let sw = (s.width - 40.0).min(320.0);
let sh = 196.0;
let sheet = rf((s.width - sw) / 2.0, 0.0, (s.width + sw) / 2.0, sh);
let half = (sw - 48.0) / 2.0;
let s_cancel = rf(sheet.left + 16.0, sh - 44.0, sheet.left + 16.0 + half, sh - 16.0);
let s_ok = rf(s_cancel.right + 16.0, sh - 44.0, sheet.right - 16.0, sh - 16.0);
Layout { head, list, note, btn, sheet, s_cancel, s_ok }
}
fn button(r: RectF, label: &str, primary: bool, enabled: bool, hover: bool, p: &Pal) {
let h2 = (r.bottom - r.top) / 2.0;
let rad = if gg() || h2 < 7.0 { h2 } else { 6.0 };
if primary && enabled {
fill(r, if hover { rgb(20, 120, 245, 1.0) } else { rgb(0, 122, 255, 1.0) }, rad);
} else {
fill(r, p.btn, rad);
stroke_rect(rf(r.left + 0.5, r.top + 0.5, r.right - 0.5, r.bottom - 0.5), p.border, rad, 1.0);
}
text(label, tf("btn"), r, if primary && enabled { rgb(255, 255, 255, 1.0) } else if enabled { p.btn_text } else { p.text2 });
}
fn visible() -> i32 {
let l = layout();
((l.list.bottom - l.list.top - 2.0) / row_h()) as i32
}
fn draw_icon(path: &str, r: RectF) {
if let Some(b) = icon(path) {
unsafe { app2d::rt().DrawBitmap(&b, Some(&r), 1.0, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, None) }
}
}
fn paint() {
if !begin_paint() {
return;
}
let p = pal();
let l = layout();
clear(p.bg);
if a().memory {
text(&tr("Seu sistema ficou sem memória para aplicativos."), tf("bold"), rf(l.head.left, l.head.top, l.head.right, l.head.top + 22.0), p.text);
text(&tr("Para evitar problemas com o computador, encerre os aplicativos que não estiver usando."), tf("body"), rf(l.head.left, l.head.top + 24.0, l.head.right, l.head.bottom), p.text);
} else {
text(&tr("Se um aplicativo não responder por algum tempo, selecione o nome dele e clique em Forçar Encerrar."), tf("body"), l.head, p.text);
}
let rad = if gg() { 0.0 } else { 5.0 };
fill(l.list, p.list, rad);
push_clip(l.list);
let rh = row_h();
let mut y = l.list.top + 1.0;
for i in a().scroll as usize..a().apps.len() {
if y >= l.list.bottom {
break;
}
let ap = a().apps[i].clone();
let r = rf(l.list.left + 1.0, y, l.list.right - 1.0, y + rh);
let sel = ap.pid == a().sel;
if sel {
if gg() {
fill(r, p.sel, 0.0);
} else {
fill(rf(r.left + 4.0, r.top + 1.0, r.right - 4.0, r.bottom - 1.0), p.sel, 5.0);
}
}
let iy = (r.top + r.bottom) / 2.0;
draw_icon(&ap.path, if gg() { rf(r.left + 7.0, iy - 8.5, r.left + 24.0, iy + 8.5) } else { rf(r.left + 10.0, r.top + 3.0, r.left + 28.0, r.top + 21.0) });
let tx = r.left + if gg() { 29.0 } else { 36.0 };
let mut right = r.right - 10.0;
let branco = rgb(255, 255, 255, 1.0);
if a().memory {
let m = bytes(ap.mem);
let mw = text_w(tf("mem"), &m);
text(&m, tf("mem"), rf(right - mw, r.top, right, r.bottom), if sel { branco } else { p.text2 });
right -= mw + 12.0;
}
let nw = text_w(tf("row"), &ap.name).min(right - tx);
text(&ap.name, tf("row"), rf(tx, r.top, tx + nw + 1.0, r.bottom), if sel { branco } else { p.text });
if ap.hung {
text(&tr("(Não Respondendo)"), tf("row"), rf(tx + nw + 5.0, r.top, right, r.bottom), if sel { rgb(255, 210, 205, 1.0) } else { p.red });
}
y += rh;
}
pop_clip();
stroke_rect(rf(l.list.left + 0.5, l.list.top + 0.5, l.list.right - 0.5, l.list.bottom - 0.5), p.border, rad, 1.0);
text(&tr("Você pode abrir esta janela pressionando Ctrl\u{00A0}+\u{00A0}Alt\u{00A0}+\u{00A0}Esc."), tf("small"), l.note, p.text2);
button(l.btn, &tr("Forçar Encerrar"), true, a().sel != 0 && a().sheet == 0, a().hover == -2, &p);
if a().sheet != 0 {
let s = size();
fill(rf(0.0, 0.0, s.width, s.height), p.dim, 0.0);
let sh = l.sheet;
fill(rf(sh.left, sh.top - 10.0, sh.right, sh.bottom), if dark() { rgb(58, 58, 60, 1.0) } else { rgb(246, 246, 246, 1.0) }, 10.0);
stroke_rect(rf(sh.left + 0.5, sh.top - 10.0, sh.right - 0.5, sh.bottom - 0.5), p.border, 10.0, 1.0);
let tg = a().target.clone();
let cx = (sh.left + sh.right) / 2.0;
draw_icon(&tg.path, rf(cx - 24.0, sh.top + 14.0, cx + 24.0, sh.top + 62.0));
let (title, info) = if a().sheet == 1 {
(format!("{}{}{}", tr("Deseja forçar o encerramento de “"), tg.name, tr("”?")), tr("Você perderá as alterações não salvas."))
} else {
(format!("{}{}”.", tr("Não foi possível forçar o encerramento de “"), tg.name), tr("O aplicativo pode estar rodando como administrador."))
};
text(&title, tf("sheettitle"), rf(sh.left + 16.0, sh.top + 68.0, sh.right - 16.0, sh.top + 108.0), p.text);
text(&info, tf("sheet"), rf(sh.left + 16.0, sh.top + 108.0, sh.right - 16.0, sh.top + 140.0), p.text);
if a().sheet == 1 {
button(l.s_cancel, &tr("Cancelar"), false, true, a().hover == -3, &p);
button(l.s_ok, &tr("Forçar Encerrar"), true, true, a().hover == -4, &p);
} else {
button(rf(sh.left + 16.0, l.s_ok.top, sh.right - 16.0, l.s_ok.bottom), "OK", true, true, a().hover == -4, &p);
}
}
end_paint();
}
fn ask() {
if let Some(ap) = a().apps.iter().find(|x| x.pid == a().sel).cloned() {
a().target = ap;
a().sheet = 1;
invalidate();
}
}
fn kill() {
let mut ok = false;
unsafe {
if let Ok(h) = OpenProcess(PROCESS_TERMINATE, false, a().target.pid) {
ok = TerminateProcess(h, 1).is_ok();
let _ = CloseHandle(h);
}
}
a().sheet = if ok { 0 } else { 2 };
if ok {
a().sel = 0;
std::thread::sleep(std::time::Duration::from_millis(150));
refresh();
}
invalidate();
}
fn mover(d: i32) {
if a().apps.is_empty() {
return;
}
let i = a().apps.iter().position(|x| x.pid == a().sel).map(|i| i as i32).unwrap_or(-1);
let i = (if i < 0 { 0 } else { i + d }).clamp(0, a().apps.len() as i32 - 1);
a().sel = a().apps[i as usize].pid;
let vis = visible();
if i < a().scroll as i32 {
a().scroll = i as f32;
}
if i >= a().scroll as i32 + vis {
a().scroll = (i - vis + 1) as f32;
}
invalidate();
}
fn hit_test(x: f32, y: f32) -> i32 {
let l = layout();
match a().sheet {
1 => {
return if in_rect(&l.s_cancel, x, y) {
-3
} else if in_rect(&l.s_ok, x, y) {
-4
} else {
-9
}
}
2 => return if in_rect(&rf(l.sheet.left + 16.0, l.s_ok.top, l.sheet.right - 16.0, l.s_ok.bottom), x, y) { -4 } else { -9 },
_ => {}
}
if in_rect(&l.btn, x, y) {
return -2;
}
if in_rect(&l.list, x, y) {
let i = a().scroll as i32 + ((y - l.list.top - 1.0) / row_h()) as i32;
if i >= 0 && (i as usize) < a().apps.len() {
return i;
}
}
-1
}
extern "system" fn proc_(h: HWND, m: u32, w_: WPARAM, l: LPARAM) -> LRESULT {
unsafe {
if m == reg_msg("SequoiaForcarEncerrarModo") {
a().memory = w_.0 != 0;
a().sheet = 0;
refresh();
if IsIconic(h).as_bool() {
let _ = ShowWindow(h, SW_RESTORE);
}
let _ = SetForegroundWindow(h);
return LRESULT(0);
}
let s_ = sc();
match m {
WM_PAINT => return wm_paint(h, paint),
WM_ERASEBKGND => return LRESULT(1),
WM_SIZE => on_size(l),
WM_DPICHANGED => on_dpi(w_, l),
WM_SETTINGCHANGE => invalidate(),
WM_TIMER => {
if a().sheet == 0 {
refresh();
}
}
WM_MOUSEMOVE => {
let k = hit_test(get_x_lparam(l) as f32 / s_, get_y_lparam(l) as f32 / s_);
let hv = if k < -1 { k } else { -1 };
if hv != a().hover {
a().hover = hv;
invalidate();
}
let mut t = TRACKMOUSEEVENT { cbSize: std::mem::size_of::<TRACKMOUSEEVENT>() as u32, dwFlags: TME_LEAVE, hwndTrack: h, dwHoverTime: 0 };
let _ = TrackMouseEvent(&mut t);
}
WM_MOUSELEAVE => {
if a().hover != -1 {
a().hover = -1;
invalidate();
}
}
WM_LBUTTONDOWN | WM_LBUTTONDBLCLK => {
let k = hit_test(get_x_lparam(l) as f32 / s_, get_y_lparam(l) as f32 / s_);
if k >= 0 {
a().sel = a().apps[k as usize].pid;
if m == WM_LBUTTONDBLCLK {
ask();
}
} else if k == -2 {
ask();
} else if k == -3 {
a().sheet = 0;
} else if k == -4 {
if a().sheet == 1 {
kill();
} else {
a().sheet = 0;
}
}
invalidate();
}
WM_MOUSEWHEEL => {
if a().sheet == 0 {
let mx = (a().apps.len() as f32 - visible() as f32).max(0.0);
a().scroll = (a().scroll - wheel_delta(w_) / 120.0 * 3.0).clamp(0.0, mx).floor();
invalidate();
}
}
WM_KEYDOWN => {
let k = w_.0 as u16;
if key_down(VK_CONTROL.0) && k == 'W' as u16 {
let _ = DestroyWindow(h);
return LRESULT(0);
}
if a().sheet != 0 {
if k == VK_ESCAPE.0 {
a().sheet = 0;
} else if k == VK_RETURN.0 {
if a().sheet == 1 {
kill();
} else {
a().sheet = 0;
}
}
invalidate();
return LRESULT(0);
}
if k == VK_ESCAPE.0 {
let _ = DestroyWindow(h);
} else if k == VK_UP.0 {
mover(-1);
} else if k == VK_DOWN.0 {
mover(1);
} else if k == VK_RETURN.0 {
ask();
}
}
WM_DESTROY => PostQuitMessage(0),
_ => return DefWindowProcW(h, m, w_, l),
}
LRESULT(0)
}
}
fn main() {
let memory = tem_arg("--memoria");
if !modo_foto() {
if let Some(other) = find_window("ForcarEncerrarJanela") {
unsafe {
let _ = PostMessageW(other, reg_msg("SequoiaForcarEncerrarModo"), WPARAM(memory as usize), LPARAM(0));
let _ = SetForegroundWindow(other);
}
return;
}
}
if !app2d::init() {
std::process::exit(1);
}
*A.get() = Some(St { memory, hover: -1, ..Default::default() });
use DWRITE_TEXT_ALIGNMENT_CENTER as C;
use DWRITE_TEXT_ALIGNMENT_LEADING as L;
let f = |s: f32, w_: DWRITE_FONT_WEIGHT, al: DWRITE_TEXT_ALIGNMENT, wrap: bool| fmt_full(s, w_, al, wrap, None);
let n = DWRITE_FONT_WEIGHT_NORMAL;
let b = DWRITE_FONT_WEIGHT_BOLD;
let body = f(13.0, n, L, true);
unsafe {
let _ = body.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
}
let t = &mut a().tf;
for (k, v) in [
("body", body),
("bold", f(13.0, b, L, false)),
("row", f(13.0, n, L, false)),
("mem", f(12.0, n, DWRITE_TEXT_ALIGNMENT_TRAILING, false)),
("small", f(11.0, n, L, true)),
("btn", f(13.0, n, C, false)),
("sheettitle", f(13.0, b, C, true)),
("sheet", f(11.5, n, C, true)),
] {
t.insert(k, v);
}
let g = gg();
let Some(h) = create_main("ForcarEncerrarJanela", &tr("Forçar Encerrar Aplicativos"), proc_, if g { 370 } else { 440 }, if g { 310 } else { 470 }) else { std::process::exit(1) };
unsafe {
let st = GetWindowLongW(h, GWL_STYLE) as u32 & !(WS_THICKFRAME.0 | WS_MAXIMIZEBOX.0);
SetWindowLongW(h, GWL_STYLE, st as i32);
let _ = SetWindowPos(h, None, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}
refresh();
unsafe {
SetTimer(h, 1, 2000, None);
}
show(h, SW_SHOWNORMAL);
if !modo_foto() {
unsafe {
let _ = SetForegroundWindow(h);
}
}
std::process::exit(run());
}