Skip to content

Commit

Permalink
win-capture: Fix display capture capturing on create
Browse files Browse the repository at this point in the history
Prevents Display capture from capturing the first display on creation.
This issue is due to the properties view combo box automatically
selecting the first item in the list by default, but this needs explicit
text anyway to indicate display, so this adds a "[Select a display]"
item that will prevent that from happening and tell the user to select a
display.
  • Loading branch information
Lain-B committed Sep 3, 2024
1 parent e9c8e10 commit a1db1e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/win-capture/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CaptureAudio="Capture Audio (BETA)"
CaptureAudio.TT="When enabled, creates an \"Application Audio Capture\" source that automatically updates to the currently captured window/application.\nNote that if Desktop Audio is configured, this could result in doubled audio."
AudioSuffix="Audio"
SelectAWindow="[Select a window to capture]"
SelectADisplay="[Select a display to capture]"

# Generic compatibility messages
Compatibility.GameCapture.Admin="%name% may require OBS to be run as admin to use Game Capture."
Expand Down
11 changes: 10 additions & 1 deletion plugins/win-capture/duplicator-monitor-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#define RESET_INTERVAL_SEC 3.0f

#define INVALID_DISPLAY "DUMMY"

typedef BOOL (*PFN_winrt_capture_supported)();
typedef BOOL (*PFN_winrt_capture_cursor_toggle_supported)();
typedef struct winrt_capture *(*PFN_winrt_capture_init_monitor)(
Expand Down Expand Up @@ -416,7 +418,7 @@ static void duplicator_capture_destroy(void *data)
static void duplicator_capture_defaults(obs_data_t *settings)
{
obs_data_set_default_int(settings, "method", METHOD_AUTO);
obs_data_set_default_string(settings, "monitor_id", "DUMMY");
obs_data_set_default_string(settings, "monitor_id", INVALID_DISPLAY);
obs_data_set_default_int(settings, "monitor_wgc", 0);
obs_data_set_default_bool(settings, "capture_cursor", true);
obs_data_set_default_bool(settings, "force_sdr", false);
Expand Down Expand Up @@ -905,6 +907,13 @@ static obs_properties_t *duplicator_capture_properties(void *data)
props, "monitor_id", TEXT_MONITOR, OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);

if (capture && strcmp(capture->monitor_id, INVALID_DISPLAY) == 0) {
obs_property_list_add_string(monitors,
obs_module_text("SelectADisplay"),
INVALID_DISPLAY);
obs_property_list_item_disable(monitors, 0, true);
}

obs_properties_add_bool(props, "capture_cursor", TEXT_CAPTURE_CURSOR);
obs_properties_add_bool(props, "force_sdr", TEXT_FORCE_SDR);

Expand Down

0 comments on commit a1db1e8

Please sign in to comment.