Copy purify.fvwm2rc to /tmp - add instructions in README.
[fvwm.git] / libs / wcontext.c
blob9d3446bdf4e2f8b79df49b124856c588df2287b9
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 /* ---------------------------- included header files ---------------------- */
19 #include "config.h"
20 #include <stdio.h>
22 #include "libs/charmap.h"
23 #include "libs/wcontext.h"
25 /* ---------------------------- local definitions -------------------------- */
27 /* ---------------------------- local macros ------------------------------- */
29 /* ---------------------------- imports ------------------------------------ */
31 /* ---------------------------- included code files ------------------------ */
33 /* ---------------------------- local types -------------------------------- */
35 /* ---------------------------- forward declarations ----------------------- */
37 /* ---------------------------- local variables ---------------------------- */
39 /* ---------------------------- exported variables (globals) --------------- */
41 /* The keys must be in lower case!
42 Put more common contexts toward the front. */
43 charmap_t win_contexts[] =
45 {'r', C_ROOT},
46 {'t', C_TITLE},
47 {'w', C_WINDOW},
48 {'f', C_FRAME},
49 {'i', C_ICON},
50 {'a', C_ALL},
51 {'1', C_L1},
52 {'2', C_R1},
53 {'3', C_L2},
54 {'4', C_R2},
55 {'5', C_L3},
56 {'6', C_R3},
57 {'7', C_L4},
58 {'8', C_R4},
59 {'9', C_L5},
60 {'0', C_R5},
61 {'d', C_EWMH_DESKTOP},
62 {'<', C_F_TOPLEFT},
63 {'^', C_F_TOPRIGHT},
64 {'>', C_F_BOTTOMRIGHT},
65 {'v', C_F_BOTTOMLEFT},
66 {'s', C_SIDEBAR},
67 {'[', C_SB_LEFT},
68 {']', C_SB_RIGHT},
69 {'-', C_SB_TOP},
70 {'_', C_SB_BOTTOM},
71 {'m', C_MENU},
72 {'p', C_PLACEMENT},
73 {0, 0}
76 /* ---------------------------- local functions ---------------------------- */
78 /* ---------------------------- interface functions ------------------------ */
80 /* Converts the input string into a mask with bits for the contexts */
81 int wcontext_string_to_wcontext(char *in_context, int *out_context_mask)
83 int error;
85 error = charmap_string_to_mask(
86 out_context_mask, in_context, win_contexts, "bad context");
88 return error;
91 char wcontext_wcontext_to_char(win_context_t wcontext)
93 char c;
95 c = charmap_mask_to_char((int)wcontext, win_contexts);
97 return c;
100 win_context_t wcontext_merge_border_wcontext(win_context_t wcontext)
102 if (wcontext & C_FRAME)
104 wcontext |= C_FRAME;
106 if (wcontext & C_SIDEBAR)
108 wcontext |= C_SIDEBAR;
111 return wcontext;