Skip to content

Commit

Permalink
Expose output connector name and id
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Aug 15, 2015
1 parent 5cf352b commit a687827
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/wlc/wlc.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ const wlc_handle* wlc_get_outputs(size_t *out_memb);
/** Get focused output. */
wlc_handle wlc_get_focused_output(void);

/** Get connector name. */
const char* wlc_output_get_connector_name(wlc_handle output);

/** Get connector id. */
uint32_t wlc_output_get_connector_id(wlc_handle output);

/** Get sleep state. */
bool wlc_output_get_sleep(wlc_handle output);

Expand Down
41 changes: 40 additions & 1 deletion src/compositor/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@
// FIXME: this is a hack
static EGLNativeDisplayType INVALID_DISPLAY = (EGLNativeDisplayType)~0;

static const char*
name_for_connector(enum wlc_output_connector connector)
{
static const char *names[] = {
"None",
"VGA",
"DVI",
"DVI",
"DVI",
"Composite",
"TV",
"LVDS",
"CTV",
"DIN",
"DP",
"HDMI",
"HDMI",
"TV",
"eDP",
};

return (connector < LENGTH(names) ? names[connector] : "UNKNOWN");
}

bool
wlc_output_information_add_mode(struct wlc_output_information *info, struct wlc_output_mode *mode)
{
Expand Down Expand Up @@ -527,7 +551,8 @@ wlc_output_set_information(struct wlc_output *output, struct wlc_output_informat
{
struct wlc_output_mode *mode;
except(mode = chck_iter_pool_get(&output->information.modes, output->active.mode));
wlc_log(WLC_LOG_INFO, "Chose mode (%u) %dx%d", output->active.mode, mode->width, mode->height);
const char *name = name_for_connector(output->information.connector);
wlc_log(WLC_LOG_INFO, "%s-%d Chose mode (%u) %dx%d", name, output->information.connector_id, output->active.mode, mode->width, mode->height);
wlc_output_set_resolution_ptr(output, &(struct wlc_size){ mode->width, mode->height });
}
}
Expand Down Expand Up @@ -802,6 +827,20 @@ wlc_output_focus(wlc_handle output)
wlc_output_focus_ptr(convert_from_wlc_handle(output, "output"));
}

WLC_API const char*
wlc_output_get_connector_name(wlc_handle output)
{
struct wlc_output *o = convert_from_wlc_handle(output, "output");
return (o ? name_for_connector(o->information.connector) : NULL);
}

WLC_API uint32_t
wlc_output_get_connector_id(wlc_handle output)
{
struct wlc_output *o = convert_from_wlc_handle(output, "output");
return (o ? o->information.connector_id : 0);
}

void
wlc_output_terminate(struct wlc_output *output)
{
Expand Down
20 changes: 20 additions & 0 deletions src/compositor/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ enum output_link {
LINK_ABOVE,
};

enum wlc_output_connector {
CONNECTOR_NONE,
CONNECTOR_VGA,
CONNECTOR_DVI1,
CONNECTOR_DVI2,
CONNECTOR_DVI3,
CONNECTOR_COMPOSITE,
CONNECTOR_TV1,
CONNECTOR_LVDS,
CONNECTOR_CTV,
CONNECTOR_DIN,
CONNECTOR_DP,
CONNECTOR_HDMI1,
CONNECTOR_HDMI2,
CONNECTOR_TV2,
CONNECTOR_eDP,
};

struct wlc_output_mode {
int32_t refresh;
int32_t width, height;
Expand All @@ -33,7 +51,9 @@ struct wlc_output_information {
int32_t physical_width, physical_height;
int32_t subpixel;
int32_t scale;
uint32_t connector_id;
enum wl_output_transform transform;
enum wlc_output_connector connector;
};

struct wlc_output {
Expand Down
2 changes: 2 additions & 0 deletions src/platform/backend/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ query_drm(int fd, struct chck_iter_pool *out_infos)
info->info.physical_height = connector->mmHeight;
info->info.subpixel = connector->subpixel;
info->info.scale = 1; // weston gets this from config?
info->info.connector_id = connector->connector_type_id;
info->info.connector = (enum wlc_output_connector)connector->connector_type;

for (int i = 0; i < connector->count_modes; ++i) {
struct wlc_output_mode mode = {0};
Expand Down
8 changes: 5 additions & 3 deletions src/platform/backend/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,15 @@ x11_event(int fd, uint32_t mask, void *data)
}

static void
fake_information(struct wlc_output_information *info)
fake_information(struct wlc_output_information *info, uint32_t id)
{
assert(info);
wlc_output_information(info);
chck_string_set_cstr(&info->make, "Xorg", false);
chck_string_set_cstr(&info->model, "X11 Window", false);
info->scale = 1;
info->connector = CONNECTOR_DP;
info->connector_id = id;

struct wlc_output_mode mode = {0};
mode.refresh = 60 * 1000; // mHz
Expand Down Expand Up @@ -576,12 +578,12 @@ update_outputs(struct chck_pool *outputs)
}

struct wlc_output_information info;
fake_information(&info);
fake_information(&info, i);
count += (add_output(window, &info) ? 1 : 0);
}
} else {
struct wlc_output_information info;
fake_information(&info);
fake_information(&info, 0);
count += (add_output(x11.screen->root, &info) ? 1 : 0);
}

Expand Down

0 comments on commit a687827

Please sign in to comment.