struct list_head link;
struct wl_resource *wl_buffer;
tbm_surface_h buffer;
+ int need_reset;
} tdm_server_voutput_buffer;
typedef struct _tdm_server_voutput_info {
len = fread(pname, sizeof(char), TDM_NAME_LEN, h);
if (len == 0) {
- char *p = strncpy(pname, "NO NAME", sizeof(pname) - 1);
- len = p - pname;
+ strncpy(pname, "NO NAME", sizeof(pname));
+ pname[sizeof(pname) - 1] = '\0';
}
- pname[len - 1] = '\0';
- strncpy(name, pname, size - 1);
+ strncpy(name, pname, size);
name[size - 1] = '\0';
fclose(h);
tdm_server_voutput_info *voutput_info = NULL;
tdm_output *output = NULL;
tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
- const tdm_output_mode *modes, *mode;
-
+ const tdm_output_mode *modes, *mode, *current_mode;
+ tdm_server_voutput_buffer *vb = NULL, *vbb = NULL;
int count = 0;
tdm_error ret;
mode = &modes[index];
TDM_DBG("mode set request to index:%d (%dx%d, %d)", index, mode->hdisplay, mode->vdisplay, mode->vrefresh);
- ret = tdm_output_set_mode(output, mode);
+ ret = tdm_output_get_mode(output, ¤t_mode);
TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ if (mode == current_mode) {
+ TDM_DBG("same mode");
+ return;
+ }
+
+ if (current_mode && ((mode->hdisplay != current_mode->hdisplay) || (mode->vdisplay != current_mode->vdisplay))) {
+ LIST_FOR_EACH_ENTRY_SAFE(vb, vbb, &voutput_info->buffer_list, link) {
+ if (vb->wl_buffer == voutput_info->attach_buffer->wl_buffer)
+ voutput_info->attach_buffer->need_reset = 1;
+ else
+ wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, vb->wl_buffer);
+ }
+ }
tdm_output_request_mode_set(voutput_info->output, index);
}
voutput_info->mmwidth = 0;
voutput_info->mmheight = 0;
+ if (voutput_info->request_commit == 1) {
+ tdm_output_unset_voutput_commit(voutput_info->voutput);
+ voutput_info->request_commit = 0;
+ }
+
if (voutput_info->attach_buffer) {
tbm_surface_h buffer = voutput_info->attach_buffer->buffer;
tbm_surface_internal_unref(buffer);
voutput_info->committing = 0;
+ if (voutput_info->attach_buffer->need_reset)
+ wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, voutput_info->attach_buffer->wl_buffer);
voutput_info->attach_buffer = NULL;
- }
-
- if (voutput_info->request_commit == 1) {
- tdm_output_unset_voutput_commit(voutput_info->voutput);
- voutput_info->request_commit = 0;
+ tdm_voutput_commit_done(voutput_info->voutput);
}
tdm_voutput_disconnect(voutput_info->voutput);
buffer = voutput_info->attach_buffer->buffer;
tbm_surface_internal_unref(buffer);
voutput_info->committing = 0;
+ if (voutput_info->attach_buffer->need_reset)
+ wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, voutput_info->attach_buffer->wl_buffer);
voutput_info->attach_buffer = NULL;
if (voutput_info->request_commit == 1)
LIST_FOR_EACH_ENTRY(vb, &voutput_info->buffer_list, link) {
if (vb && vb->buffer == buffer) {
- tbm_surface_internal_ref(vb->buffer);
return vb;
}
}
tdm_output_unset_voutput_commit(voutput_info->voutput);
if (voutput) {
+ if (voutput_info->request_commit == 1) {
+ tdm_output_unset_voutput_commit(voutput_info->voutput);
+ voutput_info->request_commit = 0;
+ tdm_voutput_disconnect(voutput_info->voutput);
+ }
+
ret = tdm_voutput_destroy(voutput);
if (ret != TDM_ERROR_NONE)
TDM_ERR("_tdm_voutput_cb_destroy fail");
return;
}
- voutput = tdm_voutput_create(private_server->private_loop->dpy, name, &ret);
+ voutput = tdm_display_voutput_create(private_server->private_loop->dpy, name, &ret);
if (!voutput) {
TDM_ERR("voutput creation fail(%s)(%d).", name, ret);
wl_resource_post_error(resource, WL_DISPLAY_ERROR_NO_MEMORY,
char buffer[TDM_DEBUG_REPLY_MSG_LEN];
int copylen = TDM_MIN(size, sizeof(buffer) - 1);
- strncpy(buffer, m, copylen);
+ memcpy(buffer, m, sizeof(buffer));
+ buffer[sizeof(buffer) - 1] = '\0';
+
m += copylen;
size -= copylen;