Fix CursorMove command to correctly honour EdgeScroll settings.
[fvwm.git] / modules / FvwmIconMan / globals.c
blob674359dcd8e2779e83c863dcf96cfd4703e1a407
1 /* -*-c-*- */
2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include "config.h"
19 #include <limits.h>
20 #include "FvwmIconMan.h"
21 #include "xmanager.h"
22 #include "readconfig.h"
24 #define DEFAULT_MOUSE "0 N sendcommand \"Silent Iconify\""
26 GlobalData globals;
27 ContextDefaults contextDefaults[] = {
28 { "plain", BUTTON_UP, { "black", "black" }, { "white", "gray"} },
29 { "focus", BUTTON_UP, { "white", "gray" }, { "black", "black" } },
30 { "select", BUTTON_FLAT, { "black", "black" }, { "white", "gray" } },
31 { "focusandselect", BUTTON_FLAT, { "white", "gray" }, { "black", "black" } },
32 { "title", BUTTON_EDGEUP, { "black", "black"}, {"white", "gray"} },
33 { "icon", BUTTON_FLAT, { "black", "black"}, {"white", "gray"} },
34 { "default", BUTTON_FLAT, { "black", "black"}, {"white", "gray"} }
37 int fvwm_fd[2];
38 int x_fd;
39 char *Module;
40 int ModuleLen;
42 /* This is solely so that we can turn a string constant into something
43 which can be freed */
45 static char *alloc_string(char *string)
47 int len = strlen(string);
48 char *ret = (char *)safemalloc((len + 1) * sizeof(char));
49 strcpy(ret, string);
50 return ret;
53 static void init_win_manager(int id)
55 int i;
57 memset(&globals.managers[id], 0, sizeof(WinManager));
58 globals.managers[id].magic = 0x12344321;
59 globals.managers[id].index = id;
60 globals.managers[id].res = SHOW_PAGE;
61 globals.managers[id].rev = REVERSE_NONE;
62 globals.managers[id].titlename = alloc_string("FvwmIconMan");
63 globals.managers[id].iconname = alloc_string("FvwmIconMan");
64 globals.managers[id].formatstring = alloc_string("%c: %i");
65 globals.managers[id].format_depend = CLASS_NAME | ICON_NAME;
66 init_button_array(&globals.managers[id].buttons);
68 for (i = 0; i < NUM_CONTEXTS; i++)
70 globals.managers[id].buttonState[i] = contextDefaults[i].state;
71 globals.managers[id].colorsets[i] = -1;
73 globals.managers[id].show.mask = ALL_NAME;
74 globals.managers[id].dontshow.mask = ALL_NAME;
75 globals.managers[id].usewinlist = 1;
76 globals.managers[id].sort = SortName;
77 globals.managers[id].weighted_sorts = NULL;
78 globals.managers[id].weighted_sorts_len = 0;
79 globals.managers[id].weighted_sorts_size = 0;
80 globals.managers[id].bindings[MOUSE] = ParseMouseEntry(DEFAULT_MOUSE);
81 globals.managers[id].we_are_drawing = 1;
82 globals.managers[id].showonlyiconic = 0;
83 globals.managers[id].showonlyfocused = 0;
84 globals.managers[id].shownoiconic = 0;
85 globals.managers[id].showtransient = 0;
86 globals.managers[id].relief_thickness = 2;
87 globals.managers[id].max_button_width = 0;
88 globals.managers[id].max_button_width_columns = 0;
89 globals.managers[id].tips = TIPS_NEVER;
90 globals.managers[id].tips_fontname = NULL;
91 globals.managers[id].tips_conf = FTipsNewConfig();
94 void print_managers(void)
96 #ifdef FVWM_DEBUG_MSGS
97 int i;
99 for (i = 0; i < globals.num_managers; i++)
101 ConsoleDebug(CORE, "Manager %d:\n", i + 1);
102 if (globals.managers[i].res == SHOW_GLOBAL)
103 ConsoleDebug(CORE, "ShowGlobal\n");
104 else if (globals.managers[i].res == SHOW_DESKTOP)
105 ConsoleDebug(CORE, "ShowDesktop\n");
106 else if (globals.managers[i].res == SHOW_PAGE)
107 ConsoleDebug(CORE, "ShowPage\n");
108 else if (globals.managers[i].res == SHOW_SCREEN)
109 ConsoleDebug(CORE, "ShowScreen\n");
111 ConsoleDebug(CORE, "DontShow:\n");
112 print_stringlist(&globals.managers[i].dontshow);
113 ConsoleDebug(CORE, "Show:\n");
114 print_stringlist(&globals.managers[i].show);
116 ConsoleDebug(
117 CORE, "Font: %s\n", (globals.managers[i].fontname)?
118 globals.managers[i].fontname : "(NULL)");
119 ConsoleDebug(
120 CORE, "Geometry: %s\n",
121 globals.managers[i].geometry_str);
122 ConsoleDebug(
123 CORE, "Button geometry: %s\n",
124 (globals.managers[i].button_geometry_str)?
125 globals.managers[i].button_geometry_str : "(NULL)");
126 ConsoleDebug(CORE, "\n");
128 #endif
131 int allocate_managers(int num)
133 int i;
135 if (globals.managers) {
136 ConsoleMessage("Already have set the number of managers\n");
137 return 0;
140 if (num < 1) {
141 ConsoleMessage("Can't have %d managers\n", num);
142 return 0;
145 globals.num_managers = num;
146 globals.managers = (WinManager *)safemalloc(num * sizeof(WinManager));
148 for (i = 0; i < num; i++) {
149 init_win_manager(i);
152 return 1;
155 void init_globals(void)
157 globals.desknum = ULONG_MAX;
158 globals.x = ULONG_MAX;
159 globals.y = ULONG_MAX;
160 globals.num_managers = 1;
161 globals.managers = NULL;
162 globals.focus_win = NULL;
163 globals.select_win = NULL;
164 globals.transient = 0;
165 globals.got_window_list = 0;