📄 3ddeskd.cpp
字号:
case 101: // e light_position[0] += 0.5; msgout (DEBUG, "light x at %f\n", light_position[0]); break; case 115: // s light_position[1] -= 0.5; msgout (DEBUG, "light y at %f\n", light_position[1]); break; case 100: // d light_position[1] += 0.5; msgout (DEBUG, "light y at %f\n", light_position[1]); break; case 120: // x light_position[2] -= 0.5; msgout (DEBUG, "light z at %f\n", light_position[2]); break; case 99: // c light_position[2] += 0.5; msgout (DEBUG, "light z at %f\n", light_position[2]); break;#endif case 48: if (last_key_pressed == key) { // second time this key was hit so exit. begin_exit(); break; } last_key_pressed = key; state = STATE_GOTO; faces->goto_face(9); break; case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: if (last_key_pressed == key) { // second time this key was hit so exit. begin_exit(); break; } last_key_pressed = key; if (initiate_destroy) { initiate_destroy = 0; faces->exit_movement_cancel(); // FIXME: replace with event something or other state = STATE_GOTO; faces->goto_face(key - 49); } else { state = STATE_GOTO; faces->goto_face(key - 49); } break;#define KEY_ENTER 0xff0d#define KEY_UP 0xff52#define KEY_DOWN 0xff54#define KEY_RIGHT 0xff53#define KEY_LEFT 0xff51#define KEY_ESCAPE 0xff1b case KEY_ENTER: case KEY_ESCAPE: case 113: // 'q' case 32: // space // We're outta here. begin_exit(); // the z_offset translation starts and is carried out by the // render function where we exit when it completes break; case KEY_LEFT: faces->goto_left(); break; case KEY_RIGHT: faces->goto_right(); break; case KEY_DOWN: faces->goto_down(); break; case KEY_UP: faces->goto_up(); break; default: msgout (DEBUG, "KP: No action for %ld / 0x%lx.\n", key, key); break; }} // END key_pressedArrangement *arrangement_array[FACE_TYPE_LAST];// assumes 'a' is Arrangement *a;#define ALLOC_ARRANGEMENT(enum_name, type) \ if (arrangement_array[enum_name]) \ delete (arrangement_array[enum_name]); \ a = new type (vdesks, \ face_width, face_height, \ face_set, cfg); \ if (!a) { \ msgout(ERROR, "out of memory\n"); \ end_program (1); \ } \ arrangement_array[enum_name] = a;static voidinitialize_arrangements (void) { memset(arrangement_array, 0, sizeof(arrangement_array)); #if 0 float aspect; float face_height, face_width; Arrangement *a = NULL; aspect = (float)GLWin.get_screen_width() / (float)GLWin.get_screen_height(); face_width = 4.0; face_height = face_width/aspect; static bool first_time = true; if (first_time) { memset(arrangement_array, 0, sizeof(arrangement_array)); first_time = false; } // tediously allocate each arrangement type and stuff into // "arrangement_array" ALLOC_ARRANGEMENT(FACE_TYPE_CAROUSEL, CarouselArrangement); ALLOC_ARRANGEMENT(FACE_TYPE_CYLINDER, CylinderArrangement); ALLOC_ARRANGEMENT(FACE_TYPE_VIEWMASTER, ViewMasterArrangement); ALLOC_ARRANGEMENT(FACE_TYPE_PRICEISRIGHT, PriceIsRightArrangement); ALLOC_ARRANGEMENT(FACE_TYPE_LINEAR, LinearArrangement); ALLOC_ARRANGEMENT(FACE_TYPE_FLIP, FlipArrangement);#endif} // END initialize_arrangementsstatic Arrangement *demand_load_arrangement (FaceType_t type){ Arrangement *f = arrangement_array [type]; if (!f) { msgout (DEBUG, "DDDDDDDDDDDDDD demand loading %d\n", type); float aspect; float face_height, face_width; aspect = (float)GLWin.get_screen_width() / (float)GLWin.get_screen_height(); face_width = 4.0; face_height = face_width/aspect; switch (type) { case FACE_TYPE_CAROUSEL: f = new CarouselArrangement (vdesks, face_width, face_height, face_set, cfg); break; case FACE_TYPE_CYLINDER: f = new CylinderArrangement (vdesks, face_width, face_height, face_set, cfg); break; case FACE_TYPE_VIEWMASTER: f = new ViewMasterArrangement (vdesks, face_width, face_height, face_set, cfg); break; case FACE_TYPE_PRICEISRIGHT: f = new PriceIsRightArrangement (vdesks, face_width, face_height, face_set, cfg); break; case FACE_TYPE_LINEAR: f = new LinearArrangement (vdesks, face_width, face_height, face_set, cfg); break; case FACE_TYPE_FLIP: f = new FlipArrangement (vdesks, face_width, face_height, face_set, cfg); break; default: f = NULL; } if (!f) { msgout(ERROR, "out of memory\n"); end_program(-1); } arrangement_array[type] = f; } return f;}static voidset_arrangement (float z_offset_distance) { FaceType_t type = cfg->options->face_type; if (type == FACE_TYPE_RANDOM) type = (FaceType_t)get_randomi (1, FACE_TYPE_LAST - 1); if (type == FACE_TYPE_NONE) if (z_offset_distance) faces->set_z_offset_distance(z_offset_distance); if (type < 0 || type >= FACE_TYPE_LAST) { msgout (ERROR, "BUG: Unknown face type (?)\n"); end_program(1); } // type is valid - demand load the arrangement if ((faces = demand_load_arrangement(type)) == NULL) { msgout (ERROR, "BUG: could not demand load arrangement %d!\n", type); end_program(-1); } faces->calculate_faces(vdesks); //msgout (DEBUG, "xxxxxxxx Setting %d (zod %f) at 0x%x\n", // type, z_offset_distance, faces); if (z_offset_distance) faces->set_z_offset_distance(z_offset_distance);} // END set_arrangementstatic void begin_exit (void){ if ( faces->cant_exit_in_goto() && faces->in_goto()) { // if no "zooming" then we don't want to exit until the goto // face is complete msgout (DEBUG, "cant exit in goto....\n"); state = STATE_GOTO; em.add_event (GOTO_FACE_COMPLETE, goto_face_complete); return; } state = STATE_EXIT; em.trigger_event (EXIT_MOVEMENT_START); initiate_destroy = 1; if (do_vpswitch) { if (cfg->early_desktop_switch) { msgout (DEBUG, "Doing VD switch c=%d r=%d\n", faces->get_current_column(), faces->get_current_row() ); vdesks.set_vdesktop (faces->get_current_column(), faces->get_current_row() ); } else { em.add_event (EXIT_MOVEMENT_STOP, switch_desktop_on_exit); } } // the z_offset translation starts and is carried out by the // render function where we exit when it completes}portion_control_t portion_control;static desktop_coords_twait_for_activation(void){ //threedeedesk_command_t msg; int done = 0; int col_count = 1; int row_count = 1; int current_col = 0; int current_row = 0; desktop_coords_t goto_coords; goto_coords.column = NO_GOTO; goto_coords.column = NO_GOTO; state = STATE_SUSPENDED; do {#ifdef SCAN_MODE do { // must setup current_etc for screen portion grab. this // should work by registering notifiers so we can change // the values only when we need to rather then "polling" // for changes vdesks.get_vdesktop_info (¤t_col, ¤t_row, &col_count, &row_count); // do some work here.... grab_portion_of_screen (&portion_control); face_set->load_texture_data(current_col + (current_row * col_count), cfg->texture_size, GLWin.get_screenshot_data_ptr() ); //msgout (DEBUG, ".....grabbed\n"); sleep_ms (20); // non-blocking - returns -1 error and 0 for success or NOMSG if (msgmgr.recieve(MessageManager::NOWAIT) < 0) { msgout (ERROR, "msgrcv failed: %s\n", strerror(errno)); continue; } } while (errno == ENOMSG);#else // should block until message received if (msgmgr.recieve() < 0) { msgout (ERROR, "msgrcv failed: %s\n", strerror(errno)); end_program(-1); }#endif msgout (DEBUG, "MSG: %ld\n", msgmgr.msg.mtype); // must get this now in case the current desktop was changed by // other means vdesks.get_vdesktop_info (¤t_col, ¤t_row, &col_count, &row_count); msgout(DEBUG, "####### current %d x %d\n", current_col, current_row); faces->set_current_face (current_col, current_row); switch (msgmgr.msg.mtype) { case MTYPE_STOP: msgout (DEBUG, "-- quiting\n"); end_program(0); break; case MTYPE_ACQUIRE_CURRENT: if (msgmgr.msg.reload) cfg->reload(); if (GLWin.grab_screenshot_data() < 0) { msgout (ERROR, "couldn't grab screen image\n"); end_program(-1); } face_set->load_texture_data(current_col + (current_row * col_count), cfg->texture_size, GLWin.get_screenshot_data_ptr() ); continue; // don't activate break; case MTYPE_ACQUIRE: if (msgmgr.msg.reload) cfg->reload(); // loop through all desktops and grab them. int i, j; for (i = 0; i < row_count; i++) { for (j = 0; j < col_count; j++) { vdesks.set_vdesktop (j, i); if (msgmgr.msg.acquire_sleep > 1) { msgout (DEBUG, "acquire sleep is %d\n", msgmgr.msg.acquire_sleep); sleep_ms (msgmgr.msg.acquire_sleep); } if (GLWin.grab_screenshot_data() < 0) { msgout (ERROR, "couldn't grab screen image\n"); end_program(-1); } face_set->load_texture_data(j + (i * col_count), cfg->texture_size, GLWin.get_screenshot_data_ptr() ); } } // go back to current vdesks.set_vdesktop (current_col, current_row); continue; // don't activate break; case MTYPE_ACTIVATE: if (strlen(msgmgr.msg.view)) { // client specified a view - ignore cmd line params except goto cfg->reload(); // always reload cfg if view specified cfg->set_config_set (msgmgr.msg.view); goto_coords.column = cfg->options->goto_column; goto_coords.row = cfg->options->goto_row; } else { // FIXME: track .conf timestamp for reloading efficiency? cfg->reload(); // reload in case "default" changed cfg->set_config_set ("default"); // set is cmd line (default) and let other client // specified options override anything if (msgmgr.msg.zoom != -1) cfg->options->entry_exit_movement = msgmgr.msg.zoom; if (msgmgr.msg.face_change_steps) cfg->options->face_change_steps = msgmgr.msg.face_change_steps; if (msgmgr.msg.zoom_steps) cfg->options->zoom_steps = msgmgr.msg.zoom_steps; msgout (DEBUG, "ZOOM is %d\n", cfg->options->entry_exit_movement); if (msgmgr.msg.face_type != FACE_TYPE_NONE) cfg->options->face_type = msgmgr.msg.face_type; goto_coords.column = msgmgr.msg.goto_column; goto_coords.row = msgmgr.msg.goto_row; } // if we are asked to goto the current row and column then // do nothing if (goto_coords.column == (current_col + 1) && goto_coords.row == (current_row + 1)) continue; // check bounds on goto column if (goto_coords.column > NO_GOTO) { if ( goto_coords.column < 1 || goto_coords.column > col_count ) { msgout (DEBUG, "Ignoring out of bounds goto column of %d\n", goto_coords.column); continue; } } // check bounds on goto row if (goto_coords.row > NO_GOTO) { if ( goto_coords.row < 1 || goto_coords.row > row_count ) { msgout (DEBUG, "Ignoring out of bounds goto row of %d\n", goto_coords.row); continue; } } // we must destroy our current face and create another one // if the indicated face_type is different or the number // of faces has changed if (cfg->options->face_type != faces->get_type() || cfg->options->recalc) { //msgout(DEBUG, "switch faceset %d for %d\n", // faces->get_type(), cfg->options->face_type); face_set->reconfigure(row_count, col_count); set_arrangement (cfg->options->default_z_offset_distance);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -