Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
454 changes: 227 additions & 227 deletions .github/workflows/windows-release.yml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ compile_commands.json
/recordings/
*.log
/imgui.ini
/website/.git-local-history-*
/pr-body.md
/website/pnpm-lock.yaml
/website/pnpm-workspace.yaml
*.partial
1 change: 1 addition & 0 deletions include/klip/capture/graphics_capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class GraphicsCapture {
void Stop() noexcept;
void SetTargetMode(CaptureTargetMode mode);
void SelectTarget(CaptureTargetMode mode, std::uint64_t source_id);
void SetBorderRequired(bool required);
[[nodiscard]] int64_t QpcOrigin() const noexcept { return qpc_origin_; }
[[nodiscard]] int64_t QpcFrequency() const noexcept { return qpc_frequency_; }

Expand Down
1 change: 1 addition & 0 deletions include/klip/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct AppConfig {
std::filesystem::path log_path = "klip.log";
bool microphone_enabled = false;
bool capture_cursor = true;
bool capture_border = true;
std::size_t raw_frame_queue_capacity = 4;
std::size_t encode_queue_capacity = 4;
std::size_t clip_request_queue_capacity = 8;
Expand Down
1 change: 1 addition & 0 deletions include/klip/ui/main_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct UiCommands {
std::function<void(CaptureTargetMode)> set_target_mode;
std::function<void(CaptureTargetMode, std::uint64_t, const std::string&)>
select_capture_source;
std::function<void(bool)> set_capture_border;
std::function<void(bool)> set_microphone_enabled;
std::function<void(float)> set_desktop_audio_gain;
std::function<void(float)> set_microphone_audio_gain;
Expand Down
20 changes: 17 additions & 3 deletions src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,20 @@ bool KlipApplication::Initialize(HINSTANCE instance, int show_command, Error& er
int KlipApplication::Run() {
if (!initialized_.load(std::memory_order_acquire)) return 1;
const auto commands = BuildUiCommands();
auto next_hotkey_retry = std::chrono::steady_clock::now();
while (window_.PumpMessages()) {
const auto ui_deadline =
std::chrono::steady_clock::now() + std::chrono::milliseconds(33);
UpdateRollingMetrics();
bool hotkeys_available = hotkeys_.SaveRegistered() && hotkeys_.RecordRegistered() &&
hotkeys_.ToggleRegistered();
const auto now = std::chrono::steady_clock::now();
if (!hotkeys_available && now >= next_hotkey_retry) {
Error hotkey_error;
hotkeys_available = hotkeys_.Register(window_.Handle(), config_.hotkeys, hotkey_error);
if (hotkeys_available) logger_.Info("Global hotkeys registered");
next_hotkey_retry = now + std::chrono::seconds(3);
}
if (!window_.Visible()) {
std::this_thread::sleep_until(ui_deadline);
continue;
Expand All @@ -129,9 +139,7 @@ int KlipApplication::Run() {
}
}
imgui_.BeginFrame();
panel_.Render(state_.Snapshot(), config_, commands,
hotkeys_.SaveRegistered() && hotkeys_.RecordRegistered() &&
hotkeys_.ToggleRegistered());
panel_.Render(state_.Snapshot(), config_, commands, hotkeys_available);
constexpr float clear_color[4] = {0.06F, 0.07F, 0.09F, 1.0F};
if (graphics_.BeginFrame(clear_color)) {
imgui_.Render();
Expand Down Expand Up @@ -216,6 +224,12 @@ UiCommands KlipApplication::BuildUiCommands() {
capture_.SelectTarget(mode, id);
PersistSettings(config_, false);
},
.set_capture_border =
[this](bool required) {
config_.capture_border = required;
capture_.SetBorderRequired(required);
PersistSettings(config_, false);
},
.set_microphone_enabled =
[this](bool enabled) {
config_.microphone_enabled = enabled;
Expand Down
16 changes: 16 additions & 0 deletions src/capture/graphics_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ void GraphicsCapture::SelectTarget(CaptureTargetMode mode, std::uint64_t source_
target_dirty_.store(true, std::memory_order_release);
}

void GraphicsCapture::SetBorderRequired(bool required) {
std::scoped_lock lock(session_mutex_);
config_.capture_border = required;
if (session_ == nullptr) return;
try {
session_.IsBorderRequired(required);
} catch (const winrt::hresult_error&) {
logger_.Warning("Capture highlight control is unavailable on this Windows build");
}
}

bool GraphicsCapture::CreateInteropDevice(Error& error) {
winrt::com_ptr<IDXGIDevice> dxgi;
auto result = device_->QueryInterface(IID_PPV_ARGS(dxgi.put()));
Expand Down Expand Up @@ -350,6 +361,11 @@ bool GraphicsCapture::StartSessionLocked(const CaptureTarget& target, Error& err
} catch (const winrt::hresult_error&) {
logger_.Warning("Cursor capture control is unavailable on this Windows build");
}
try {
session_.IsBorderRequired(config_.capture_border);
} catch (const winrt::hresult_error&) {
logger_.Warning("Capture highlight control is unavailable on this Windows build");
}
session_.StartCapture();
active_target_ = target;
const auto requested_mode = target_mode_.load(std::memory_order_acquire);
Expand Down
2 changes: 2 additions & 0 deletions src/core/config_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ bool AssignValue(AppConfig& config, const std::string& key, const std::string& v
if (key == "rolling_buffer_bytes") return ParseInteger(value, config.rolling_buffer_bytes);
if (key == "microphone_enabled") return ParseBool(value, config.microphone_enabled);
if (key == "capture_cursor") return ParseBool(value, config.capture_cursor);
if (key == "capture_border") return ParseBool(value, config.capture_border);
if (key == "output_directory") {
config.output_directory = ParsePath(value);
return true;
Expand Down Expand Up @@ -258,6 +259,7 @@ bool SaveConfig(const std::filesystem::path& path, const AppConfig& config,
output << "rolling_buffer_bytes=" << config.rolling_buffer_bytes << '\n';
output << "microphone_enabled=" << (config.microphone_enabled ? "true" : "false") << '\n';
output << "capture_cursor=" << (config.capture_cursor ? "true" : "false") << '\n';
output << "capture_border=" << (config.capture_border ? "true" : "false") << '\n';
output << "capture_mode=" << ModeName(config.target_mode) << '\n';
output << "encoder_quality=" << QualityName(config.encoder_quality) << '\n';
output << "encoder_preferences=" << JoinEncoders(config.encoder_preferences) << '\n';
Expand Down
49 changes: 26 additions & 23 deletions src/ui/imgui_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@ namespace {
void ApplyStyle() {
ImGui::StyleColorsDark();
auto& style = ImGui::GetStyle();
style.WindowRounding = 14.0F;
style.FrameRounding = 10.0F;
style.GrabRounding = 10.0F;
style.PopupRounding = 10.0F;
style.ScrollbarRounding = 10.0F;
style.WindowRounding = 10.0F;
style.FrameRounding = 7.0F;
style.GrabRounding = 7.0F;
style.PopupRounding = 8.0F;
style.ScrollbarRounding = 8.0F;
style.WindowBorderSize = 0.0F;
style.WindowPadding = ImVec2(24.0F, 20.0F);
style.ItemSpacing = ImVec2(10.0F, 9.0F);
style.FramePadding = ImVec2(12.0F, 9.0F);
style.ItemSpacing = ImVec2(11.0F, 10.0F);
style.FramePadding = ImVec2(12.0F, 8.0F);
auto* colors = style.Colors;
colors[ImGuiCol_WindowBg] = ImVec4(0.04F, 0.06F, 0.09F, 1.0F);
colors[ImGuiCol_PopupBg] = ImVec4(0.06F, 0.08F, 0.12F, 0.99F);
colors[ImGuiCol_Border] = ImVec4(0.18F, 0.21F, 0.27F, 1.0F);
colors[ImGuiCol_TitleBg] = ImVec4(0.04F, 0.06F, 0.09F, 1.0F);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.06F, 0.08F, 0.12F, 1.0F);
colors[ImGuiCol_Button] = ImVec4(0.40F, 0.17F, 0.72F, 1.0F);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.52F, 0.24F, 0.88F, 1.0F);
colors[ImGuiCol_ButtonActive] = ImVec4(0.34F, 0.13F, 0.64F, 1.0F);
colors[ImGuiCol_FrameBg] = ImVec4(0.08F, 0.11F, 0.15F, 1.0F);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.11F, 0.14F, 0.19F, 1.0F);
colors[ImGuiCol_Header] = ImVec4(0.35F, 0.14F, 0.62F, 0.75F);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.48F, 0.21F, 0.82F, 0.90F);
colors[ImGuiCol_CheckMark] = ImVec4(0.70F, 0.34F, 1.0F, 1.0F);
colors[ImGuiCol_SliderGrab] = ImVec4(0.64F, 0.29F, 0.96F, 1.0F);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.69F, 0.34F, 1.0F, 1.0F);
colors[ImGuiCol_Text] = ImVec4(0.94F, 0.93F, 0.91F, 1.0F);
colors[ImGuiCol_TextDisabled] = ImVec4(0.46F, 0.47F, 0.44F, 1.0F);
colors[ImGuiCol_WindowBg] = ImVec4(0.035F, 0.043F, 0.039F, 1.0F);
colors[ImGuiCol_PopupBg] = ImVec4(0.055F, 0.058F, 0.067F, 0.99F);
colors[ImGuiCol_Border] = ImVec4(0.22F, 0.22F, 0.24F, 0.86F);
colors[ImGuiCol_TitleBg] = ImVec4(0.035F, 0.043F, 0.039F, 1.0F);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.05F, 0.05F, 0.06F, 1.0F);
colors[ImGuiCol_Button] = ImVec4(0.39F, 0.17F, 0.70F, 1.0F);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.51F, 0.25F, 0.86F, 1.0F);
colors[ImGuiCol_ButtonActive] = ImVec4(0.32F, 0.12F, 0.61F, 1.0F);
colors[ImGuiCol_FrameBg] = ImVec4(0.075F, 0.078F, 0.09F, 1.0F);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.105F, 0.108F, 0.12F, 1.0F);
colors[ImGuiCol_Header] = ImVec4(0.34F, 0.14F, 0.61F, 0.72F);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.48F, 0.22F, 0.80F, 0.90F);
colors[ImGuiCol_CheckMark] = ImVec4(0.72F, 0.46F, 1.0F, 1.0F);
colors[ImGuiCol_SliderGrab] = ImVec4(0.68F, 0.40F, 0.97F, 1.0F);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.72F, 0.43F, 1.0F, 1.0F);
}

} // namespace
Expand All @@ -55,7 +57,8 @@ bool ImGuiHost::Initialize(HWND window, ID3D11Device* device, ID3D11DeviceContex
&font_config);
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguisb.ttf", 17.0F, &font_config);
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeuib.ttf", 30.0F, &font_config);
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguisb.ttf", 42.0F, &font_config);
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeuil.ttf", 44.0F, &font_config);
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\consola.ttf", 13.0F, &font_config);
if (regular == nullptr) io.Fonts->AddFontDefault();
io.FontDefault = regular;
ApplyStyle();
Expand Down
Loading
Loading