⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.hpp

📁 一个3D桌面的实现源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
//  ----------------------------------------------------------////  Copyright (C) 2002 Brad Wasson <bard@systemtoolbox.com>////  This file is part of 3ddesktop.////  3ddesktop is free software; you can redistribute it and/or modify it//  under the terms of the GNU General Public License as published by//  the Free Software Foundation; either version 2, or (at your option)//  any later version.////  3ddesktop is distributed in the hope that it will be useful, but//  WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//  GNU General Public License for more details.////  You should have received a copy of the GNU General Public License//  along with 3ddesktop; see the file COPYING.   If not, write to//  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.//#ifndef _CONFIG_HPP#define _CONFIG_HPP#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <sys/stat.h>  // for mkdir#ifndef _GNU_SOURCE#define _GNU_SOURCE#endif#include <dirent.h>  // for PATH_MAX?#include <getopt.h>#include "3ddesk.h"//#include "arrange.hpp"// STLusing namespace std;#include <list>static void usage_and_bye (void){    msgout(INFO,            "usage: 3ddeskd [ OPTIONS ]\n\n"           "  where:\n"           "    --acquire[=#]    Grab images for all the desktops by cycling thru\n"           "                       (sleep for # millisecs at each screen for refresh)\n"           "    --dir=/path      the install dir if different than /usr/share/3ddesktop\n"           "    --texturesize=#  size of textures (larger for more detail) in powers of 2\n"            "    --wm=            Specify the Windowmanager type so all the virtual \n"           "                     desktops are found correctly.  Available options are:\n"           "                       kde2, kde3, gnome1, gnome2, ewmh, fluxbox, windowmaker,\n"           "                       enlightenment, sawfishonly, workspaces\n"           "    --fastest        hog the CPU for smoothest operation\n"           "    -v               verbose/debug information\n\n");    exit (1);} // END usage_and_bye// options by command line or config file class Options {public:    char name[50];    // bits/bools on/off    int acquire : 1;    int show_fps : 1;    int show_digits : 1;    int do_fullscreen : 1;    int entry_exit_movement : 1;    int use_context_switch : 1;    int use_breathing : 1;    int daemonized : 1;    int use_wireframe : 1;    int __early_desktop_switch : 1;    int __disable_keys_in_goto : 1;    int __verbose : 1;    int __texture_size;    int __use_kde : 1;    int __use_ewmh : 1;    int __sawfish_only : 1;    int __use_workspaces : 1;    int __use_viewareas : 1;#if defined(__FreeBSD__)    char base_dir[MAXNAMLEN + 1];#else    char base_dir[PATH_MAX];#endif    int random_fun_delay;    // 15    float animation_speed;  // ms between animations    // steps between face changes (40 * 10ms animation step = 400ms to    // change faces)    float face_change_steps;    float zoom_steps;    FaceType_t face_type;    float default_z_offset_distance;    int goto_column;    int goto_row;    float digit_size;    int digit_color;    int frame_color;    float linear_spacing;    int recalc;  // set if arrangement needs to be recalculated    // ---------    //Arrangement *arrangement;    Options(char *n = NULL) {	if (n)	    strncpy(name, n, sizeof(name));        // defaults        __verbose = 0;        __texture_size = 1024;	__use_kde = 0;	__use_ewmh = 0;        __sawfish_only = 0;        __use_workspaces = 0;        __use_viewareas = 0;        __early_desktop_switch = 1;        __disable_keys_in_goto = 1;        acquire = 0;        show_fps = 0;        show_digits = 1;        do_fullscreen = 1;        entry_exit_movement = 1;        use_context_switch = 1;        use_breathing = 1;        random_fun_delay = 15;        face_type = FACE_TYPE_CAROUSEL;        default_z_offset_distance = 0;        daemonized = 0;        goto_column = NO_GOTO;        goto_row = NO_GOTO;        strcpy(base_dir, SHAREDIR);        digit_size = 50;        digit_color = COLOR_RED;        frame_color = COLOR_GRAY;        use_wireframe = true;        linear_spacing = 2.0;        recalc = 1;        animation_speed = 10;        face_change_steps = 40;        zoom_steps = 45;	// ----        //arrangement = NULL;    };    void set_color (int *v, char *color) {        if (strcmp(color, "red") == 0) {            *v = COLOR_RED;        } else if (strcmp(color, "green") == 0) {            *v = COLOR_GREEN;        } else if (strcmp(color, "blue") == 0) {            *v = COLOR_BLUE;        } else if (strcmp(color, "lightblue") == 0) {            *v = COLOR_LIGHTBLUE;        } else if (strcmp(color, "white") == 0) {            *v = COLOR_WHITE;        } else if (strcmp(color, "gray") == 0) {            *v = COLOR_GRAY;        } else if (strcmp(color, "purple") == 0) {            *v = COLOR_PURPLE;        } else if (strcmp(color, "yellow") == 0) {            *v = COLOR_YELLOW;        } else {            msgout (DEBUG, "conf file: invalid color '%s' (red,green,blue,yellow,white,purple,orange)\n", color);            //*v = COLOR_WHITE;        }    }            int get_boolean (char *value) {        if (!value) return 0;        if (!strcmp(value, "0") ||            !strcmp(value, "false") ||            !strcmp(value, "no") ||            !strcmp(value, "off"))             return 0;                if (!strcmp(value, "1") ||            !strcmp(value, "true") ||            !strcmp(value, "yes") ||            !strcmp(value, "on"))             return 1;        return 0;  // default false (?)    }    int set_option (char *option, char *value, bool from_cmdline) {        int tmpint;        float tmpfloat;	if (!option)	    return 1;	if (strcmp(option, "mode") == 0) {	    if (strcmp(value, "cylinder") == 0) {		face_type = FACE_TYPE_CYLINDER;	    } else if (strcmp(value, "linear") == 0) {		face_type = FACE_TYPE_LINEAR;	    } else if (strcmp(value, "viewmaster") == 0) {		face_type = FACE_TYPE_VIEWMASTER;	    } else if (strcmp(value, "carousel") == 0) {		face_type = FACE_TYPE_CAROUSEL;	    } else if (strcmp(value, "priceisright") == 0) {		face_type = FACE_TYPE_PRICEISRIGHT;	    } else if (strcmp(value, "flip") == 0) {		face_type = FACE_TYPE_FLIP;	    } else if (strcmp(value, "random") == 0) {		face_type = FACE_TYPE_RANDOM;	    } else {		return 1;	    }	} else if (strcmp(option, "zoomspeed") == 0) {            float tmp = atof(value);            if (tmp >= 1.0 && tmp <= 300.0) {                zoom_steps = tmp;            }	} else if (strcmp(option, "changespeed") == 0) {            float tmp = atof(value);            if (tmp >= 1.0 && tmp <= 300.0) {                face_change_steps = tmp;            }	} else if (strcmp(option, "animation_speed") == 0) {            float tmp = atof(value);            if (tmp >= 1.0 && tmp <= 100.0) {                animation_speed = tmp;            }	} else if (strcmp(option, "linear_spacing") == 0) {            float tmp = atof(value);            if (tmp >= 0.0 && tmp <= 20) {                linear_spacing = tmp;                recalc = 1;            }	} else if (strcmp(option, "use_breathing") == 0) {            use_breathing = get_boolean (value);	} else if (strcmp(option, "digit_size") == 0) {	    digit_size = atoi(value);	} else if (strcmp(option, "digit_color") == 0) {            set_color (&digit_color, value);	} else if (strcmp(option, "frame_color") == 0) {            set_color (&frame_color, value);	} else if (strcmp(option, "use_wireframe") == 0) {            use_wireframe = get_boolean (value);	} else if (strcmp(option, "fps") == 0) {	    show_fps = get_boolean (value);	} else if (strcmp(option, "show_digit") == 0) {	    show_digits = get_boolean (value);;	} else if (strcmp(option, "dir") == 0) {	    strncpy(base_dir, value, sizeof(base_dir));	} else if (strcmp(option, "randdelay") == 0) {	    tmpint = atoi (value);	    if (0 <= tmpint && tmpint < 60)		random_fun_delay = tmpint;	} else if (strcmp(option, "workspaces") == 0) {            __use_workspaces = from_cmdline ? 1 : get_boolean (value);	} else if (strcmp(option, "texturesize") == 0) {	    __texture_size = atoi (value);	    switch (__texture_size) {	    case  16: case  32: case   64: case  128:	    case 256: case 512: case 1024: case 2048:		break;	    default:		// I now use gluBuild2DMipmaps so this isn't		// really necessary because it converts it however		// it is sooooo slow.  To use glTexImage2D it is		// necessary.		msgout (ERROR, "Texture size must be a power of 2 (such as 256, 512, 1024 ...)\n");		end_program(-1);  // should I ignore this error?		break;	    }	} else if (strcmp(option, "fastest") == 0) {	    use_context_switch = get_boolean (value);	} else if (strcmp(option, "depth") == 0) {	    tmpfloat = (float)atof(value);	    if (3.5 <= tmpfloat && tmpfloat < 40.0)		default_z_offset_distance = tmpfloat;	} else if (strcmp(option, "win") == 0) {	    do_fullscreen = from_cmdline ? 0 : get_boolean (value);	} else if (strcmp(option, "sawfish") == 0) {	    __sawfish_only = from_cmdline ? 1 : get_boolean (value);        } else if (strcmp(option, "kde") == 0) {            __use_kde = from_cmdline ? 1 : get_boolean (value);        } else if (strcmp(option, "kde2") == 0) {            __use_kde = from_cmdline ? 1 : get_boolean (value);        } else if (strcmp(option, "kde3") == 0) {            __use_ewmh = from_cmdline ? 1 : get_boolean (value);        } else if (strcmp(option, "gnome") == 0) {            // "gnome off" will actaully enable in .conf ... but oh well            __use_ewmh = 0;            __use_workspaces = 1;        } else if (strcmp(option, "gnome1") == 0) {            __use_ewmh = 0;            __use_workspaces = 1;        } else if (strcmp(option, "gnome2") == 0) {            __use_ewmh = from_cmdline ? 1 : get_boolean (value);        } else if (strcmp(option, "ewmh") == 0) {            __use_ewmh = from_cmdline ? 1 : get_boolean (value);	} else if (strcmp(option, "acquire") == 0) {	    acquire = 1;	    if (value) {		tmpint = atoi (value);		// must be between 10ms and 3sec for now		if (10 < tmpint && tmpint < 3000)		    acquire = tmpint;	    }	} else if (strcmp(option, "wm") == 0) {	    if (!value)		return 1;	    if (strcmp (value, "sawfishonly") == 0) {		__sawfish_only = 1;	    } else if (strcmp (value, "kde") == 0 ||                       strcmp (value, "kde2") == 0) {		__use_kde = 1;		__use_ewmh = 0;	    } else if (strcmp (value, "kde3") == 0) {		__use_ewmh = 1;	    } else if (strcmp (value, "gnome") == 0 ||                       strcmp (value, "gnome1") == 0 ||                       strcmp (value, "enlightenment") == 0) {                __use_viewareas = 1;		__use_workspaces = 1;		__use_ewmh = 0;	    } else if (strcmp (value, "gnome2") == 0 ||                       strcmp (value, "ewmh") == 0) {		__use_ewmh = 1;	    } else if (strcmp (value, "gnomeworkspaces") == 0 ||

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -