/** @brief Recover a window chosen from the window menu or in response to a successful _NET_ACTIVE_WINDOW request @param frames workspace the frame is in @param i index of the frame in the workspaces list of frames. @return void **/ void recover_frame(Display *display, struct Workspace *frames, int i /*index*/, struct Separators *seps, const struct Workarea *workarea, struct Themes *themes) { //allow desktop windows to be recovered/tiled. Otherwise the user has no way to recover a desktop window. if(frames->list[i]->mode == desktop) { if(drop_frame(frames, i, False, workarea)) { change_frame_mode(display, frames->list[i], tiling, workarea, themes); resize_frame(display, frames->list[i], workarea, themes); } } else if(frames->list[i]->mode == tiling) { if(drop_frame(frames, i, False, workarea)) { XMapWindow(display, frames->list[i]->widgets[frame_parent].widget); frames->list[i]->state = none; } } else if(frames->list[i]->mode == floating) { if(drop_frame(frames, i, True, workarea)) { XMapWindow(display, frames->list[i]->widgets[frame_parent].widget); frames->list[i]->state = none; } } else { XMapWindow(display, frames->list[i]->widgets[frame_parent].widget); frames->list[i]->state = none; } stack_frame(display, frames->list[i], seps); reset_frame_titlebar(display, frames->list[i]); XFlush(display); }
void prob_get_label_group(prob_client_t pc, ProBState s, int group, int *res) { zmsg_t *request = zmsg_new(); zmsg_addstr(request, "get-state-label-group"); zmsg_addstrf(request, "%d", pc->id_count); zmsg_addstrf(request, "DA%d", group); prob_put_state(request, s); zmsg_send(&request, pc->zocket); zmsg_destroy(&request); zmsg_t *response = zmsg_recv(pc->zocket); drop_frame(response); drop_frame(response); char *result_s; for (int i = 0; (result_s = zmsg_popstr(response)) != NULL; i++) { int r; sscanf(result_s, "%d", &r); res[i] = r; RTfree(result_s); } zmsg_destroy(&response); }
int prob_get_state_label(prob_client_t pc, ProBState s, char *label) { zmsg_t *request = zmsg_new(); zmsg_addstr(request, "get-state-label"); zmsg_addstrf(request, "%d", pc->id_count); zmsg_addstrf(request, "DA%s", label); prob_put_state(request, s); zmsg_send(&request, pc->zocket); zmsg_destroy(&request); zmsg_t *response = zmsg_recv(pc->zocket); drop_frame(response); drop_frame(response); char *result_s = zmsg_popstr(response); int res; sscanf(result_s, "%d", &res); RTfree(result_s); zmsg_destroy(&response); return res; }
static ProBState * prob_next_x(prob_client_t pc, ProBState s, char *transitiongroup, int *size, char *header) { zmsg_t *request = zmsg_new(); zmsg_addstr(request, header); zmsg_addstrf(request, "%d", pc->id_count); zmsg_addstr(request, transitiongroup); prob_put_state(request, s); Debugf("requesting next-state, contents:\n"); #ifdef LTSMIN_DEBUG if (log_active(debug)) zmsg_print(request); #endif zmsg_send(&request, pc->zocket); zmsg_destroy(&request); zmsg_t *response = zmsg_recv(pc->zocket); Debugf("response for next-state, contents:\n"); #ifdef LTSMIN_DEBUG if (log_active(debug)) zmsg_print(response); #endif drop_frame(response); drop_frame(response); char *nr_of_states_s = zmsg_popstr(response); sscanf(nr_of_states_s, "%d", size); RTfree(nr_of_states_s); ProBState *successors = RTmalloc(sizeof(ProBState) * (*size)); int i; for (i = 0; i < (*size); i++) { successors[i] = prob_get_state(response); } zmsg_destroy(&response); return successors; }
/** @brief drop frame is normally called when the mode of the frame is going to change. In that case, we can determine whether we want to try and tile it next to all tiling windows or just panels However, in several cases we are just trying to enforce whatever it's exiting tiling policy is. This function is a wrapper for drop frame that does that. @return True if the frame fits, False otherwise **/ Bool redrop_frame (Display *display, struct Workspace *frames, int clicked_frame, const struct Workarea *workarea, struct Themes *themes) { Bool result = False; if(frames->list[clicked_frame]->mode == floating) { //Floating windows only need to avoid panels result = drop_frame(frames, clicked_frame, True, workarea); } else { result = drop_frame(frames, clicked_frame, False, workarea); } // If anything has been moved or resized we need // to check it's ok and reflect the changes // in the window // These *might* make the window smaller if(result) { check_frame_limits(frames->list[clicked_frame], workarea, themes); resize_frame(display, frames->list[clicked_frame], workarea, themes); XFlush(display); } return result; }
static inline GstVaapiDecoderStatus do_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * base_frame) { GstVaapiParserState *const ps = &decoder->parser_state; GstVaapiParserFrame *const frame = base_frame->user_data; GstVaapiDecoderStatus status; ps->current_frame = base_frame; gst_vaapi_parser_frame_ref (frame); status = do_decode_1 (decoder, frame); gst_vaapi_parser_frame_unref (frame); switch ((guint) status) { case GST_VAAPI_DECODER_STATUS_DROP_FRAME: drop_frame (decoder, base_frame); status = GST_VAAPI_DECODER_STATUS_SUCCESS; break; } return status; }
/** @pre all parameters intitalized and allocated properly. @brief This function changes the user's workspace to the workspace at the specified index. If a negative index is passed (This is done when the currently open workspace is removed), it changes to a default workspace which is currently 0. If a negative index is passed but no workspace is open nothing happens. Generally, it is expected that at least one workspace is open. Windows from other workspaces are unmapped. @post The user's workspace has visibly changed. @return void **/ void change_to_workspace(Display *display, struct Workspace_list *workspaces, int *current_workspace, struct Workspace **frames, int index, struct Separators *seps, const struct Workarea *workarea, struct Themes *themes, struct Atoms *atoms) { struct Workspace *workspace = &workspaces->list[*current_workspace]; if(*current_workspace != -1) *frames = workspace; struct Saved_frame_state *frame_state; if(workspaces->used_workspaces == 0) { *frames = NULL; *current_workspace = -1; return; //don't do anything if no windows are open } if(*current_workspace < workspaces->used_workspaces /*this function is sometimes called to change from an invalid workspace that has been closed */ && *current_workspace >= 0) { for(int i = 0; i < workspace->used; i++) { //So we can figure out where to save the frame state we need to calculate the pointer offset. int real_frame_index = get_offset_in_array(workspace->list[i], workspaces->frame_list, sizeof(struct Frame)); if(workspace->list[i]->sticky == False) { XUnmapWindow(display, workspace->list[i]->widgets[frame_parent].widget); XUnmapWindow(display, workspace->list[i]->menu.item); } //printf("real_frame_index %d, i = %d, current_workspace %d\n", real_frame_index, i, *current_workspace); frame_state = &workspace->states[real_frame_index]; frame_state->need_to_tile = 0; save_frame_state(frame_state, workspace->list[i]); } free(workspace->list); workspace->list = NULL; workspace->used = 0; } XSync(display, False); //if index is -1, change to default workspace which is 0 if(index < 0 && workspaces->used_workspaces > 0) index = 0; *current_workspace = index; workspace = &workspaces->list[*current_workspace]; *frames = workspace; workspace->max = DEFAULT_STARTING_FRAMES; workspace->list = malloc(sizeof(struct Frames *) * workspace->max ); if(!workspace->list) { perror("Couldn't allocate frame list"); return; } //Do all the panels because we want them to be tiled first. for(int i = 0; i < workspaces->used_frames; i++) { if(workspaces->frame_list[i].sticky == True) { if(ensure_empty_frame_reference_slots(workspace) == False) { perror("Couldn't allocate frame list"); return; } int ref_index = workspace->used; struct Frame *frame = workspace->list[ref_index] = &workspaces->frame_list[i]; if(drop_frame(workspace, ref_index, False, workarea)) { //this should be easy as they should already be non-overlapping change_frame_mode(display, frame, tiling, workarea, themes); } else { change_frame_state(display, frame, minimized, seps, workarea, themes, atoms); fprintf(stderr, "Couldn't tile panel! It is called %s\n", frame->window_name); } resize_frame(display, frame, workarea, themes); stack_frame(display, frame, seps); XMapWindow(display, frame->widgets[frame_parent].widget); //Actually only needs to be mapped the first time but doesn't matter workspace->used++; } } for(int i = 0; i < workspaces->used_frames; i++) { frame_state = &workspace->states[i]; if(frame_state->available != 0 && frame_state->sticky == False) { if(ensure_empty_frame_reference_slots(workspace) == False) { perror("Couldn't allocate frame list"); return; } int ref_index = workspace->used; struct Frame *frame = workspace->list[ref_index] = &workspaces->frame_list[i]; load_frame_state(display, frame_state, frame, seps, workarea, themes, atoms); if(workspace->states[i].need_to_tile) { if(drop_frame(workspace, ref_index, False, workarea)) { //this should be easy as they should already be non-overlapping change_frame_mode(display, frame, tiling, workarea, themes); } else { change_frame_state(display, frame, minimized, seps, workarea, themes, atoms); //TODO set urgency hint } workspace->states[i].need_to_tile = 0; } else if(frame->mode == floating) { if(!drop_frame(workspace, ref_index, True, workarea)) { change_frame_state(display, frame, minimized, seps, workarea, themes, atoms); //TODO set urgency hint } } resize_frame(display, frame, workarea, themes); stack_frame(display, frame, seps); if(frame->state != minimized) XMapWindow(display, frame->widgets[frame_parent].widget); XMapWindow(display, workspace->list[ref_index]->menu.item); workspace->used++; } } update_client_list(display, workspace, atoms); // printf("changing focus to one in new workspace\n"); recover_focus(display, workspace, atoms); XFlush(display); }