File: main.c

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (154 lines) | stat: -rw-r--r-- 2,560 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * ion/mod_tiling/main.c
 *
 * Copyright (c) Tuomo Valkonen 1999-2007.
 *
 * See the included file LICENSE for details.
 */

#include <libtu/map.h>

#include <ioncore/common.h>
#include <ioncore/reginfo.h>
#include <libextl/readconfig.h>
#include <ioncore/framep.h>
#include <ioncore/bindmaps.h>
#include <ioncore/bindmaps.h>

#include "main.h"
#include "tiling.h"
#include "placement.h"
#include "exports.h"


/*{{{ Module information */


#include "../version.h"

char mod_tiling_ion_api_version[]=NOTION_API_VERSION;


/*}}}*/


/*{{{ Bindmaps and configuration variables */


WBindmap *mod_tiling_tiling_bindmap=NULL;

int mod_tiling_raise_delay=CF_RAISE_DELAY;


/*}}}*/


/*{{{ Configuration */


/*EXTL_DOC
 * Set parameters. Currently only \var{raise_delay} (in milliseconds)
 * is supported.
 */
EXTL_EXPORT
void mod_tiling_set(ExtlTab tab)
{
    int d;
    if(extl_table_gets_i(tab, "raise_delay", &d)){
        if(d>=0)
            mod_tiling_raise_delay=d;
    }
}


/*EXTL_DOC
 * Get parameters. For details see \fnref{mod_tiling.set}.
 */
EXTL_SAFE
EXTL_EXPORT
ExtlTab mod_tiling_get()
{
    ExtlTab tab=extl_create_table();

    extl_table_sets_i(tab, "raise_delay", mod_tiling_raise_delay);

    return tab;
}



/*}}}*/



/*{{{ Module init & deinit */


void mod_tiling_deinit()
{
    mod_tiling_unregister_exports();
    ioncore_unregister_regclass(&CLASSDESCR(WTiling));

    if(mod_tiling_tiling_bindmap!=NULL){
        ioncore_free_bindmap("WTiling", mod_tiling_tiling_bindmap);
        mod_tiling_tiling_bindmap=NULL;
    }

    if(tiling_placement_alt!=NULL){
        destroy_obj((Obj*)tiling_placement_alt);
        tiling_placement_alt=NULL;
    }
}


static bool register_regions()
{
    if(!ioncore_register_regclass(&CLASSDESCR(WTiling),
                                  (WRegionLoadCreateFn*)tiling_load)){
        return FALSE;
    }

    return TRUE;
}


#define INIT_HOOK_(NM)                             \
    NM=mainloop_register_hook(#NM, create_hook()); \
    if(NM==NULL) return FALSE; \
    ((void)0)


static bool init_hooks()
{
    INIT_HOOK_(tiling_placement_alt);
    return TRUE;
}


bool mod_tiling_init()
{
    if(!init_hooks())
        goto err;

    mod_tiling_tiling_bindmap=ioncore_alloc_bindmap("WTiling", NULL);

    if(mod_tiling_tiling_bindmap==NULL)
        goto err;

    if(!mod_tiling_register_exports())
        goto err;

    if(!register_regions())
        goto err;

    extl_read_config("cfg_tiling", NULL, TRUE);

    return TRUE;

err:
    mod_tiling_deinit();
    return FALSE;
}


/*}}}*/