aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
blob: 029f280eb699162a16ffb63cabf0e914c6f4f49a (plain)
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
#include "actions.h"
#include "border.h"
#include "config.h"
#include "desktops.h"
#include "exec.h"
#include "fs.h"
#include "entry.h"
#include "keys.h"
#include "ipc.h"
#include "menu.h"
#include "view.h"

#ifdef USE_FERITE
# include "e_ferite.h"
#endif

#include <X11/Xproto.h>

#ifdef E_PROF
Evas_List __e_profiles = NULL;
#endif

static void cb_exit(void);
static void cb_exit(void)
{
   E_PROF_DUMP;
}

static void ch_col(int val, void *data);
static void ch_col(int val, void *data)
{
   E_Desktop *desk;
   double v;
   
   v = (double)val / 10;
   desk = e_desktops_get(e_desktops_get_current());
   e_desktops_scroll(desk, (int)(8 * sin(v)), (int)(8 * cos(v)));
   e_add_event_timer("time", 0.02, ch_col, val + 1, NULL);
   return;
   UN(data);
}

static void wm_running_error(Display * d, XErrorEvent * ev);
static void 
wm_running_error(Display * d, XErrorEvent * ev)
{
   if ((ev->request_code == X_ChangeWindowAttributes) && (ev->error_code == BadAccess))
     {
	fprintf(stderr, "A WM is alreayd running. no point running now is there?\n");
	exit(1);
     }   
   UN(d);
}

void setup(void);
void
setup(void)
{
   e_grab();
   e_sync();
   e_border_adopt_children(0);
   e_ungrab();
/*   e_add_event_timer("timer", 0.02, ch_col, 0, NULL);*/
}

int
main(int argc, char **argv)
{
   char *display = NULL;
   int   i;

   atexit(cb_exit);
   e_exec_set_args(argc, argv);
   
   e_config_init();

   /* Check command line options here: */
   for (i = 1; i < argc; i++)
     {
       if ((!strcmp("-display", argv[i])) && (argc - i > 1))
	 {
	   display = argv[++i];
	 }
       else if ((!strcmp("-help", argv[i]))
		|| (!strcmp("--help", argv[i]))
		|| (!strcmp("-h", argv[i])) || (!strcmp("-?", argv[i])))
	 {
	   printf("enlightenment options:                      \n"
		  "\t-display display_name                     \n"
		  "\t[-v | -version | --version]               \n");
	   exit(0);
	 }
       else if ((!strcmp("-v", argv[i]))
		|| (!strcmp("-version", argv[i]))
		|| (!strcmp("--version", argv[i]))
		|| (!strcmp("-v", argv[i])))
	 {
	   printf("Enlightenment Version: %s\n", ENLIGHTENMENT_VERSION);
	   exit(0);
	 }
     }

   if (!e_display_init(display))
     {
	fprintf(stderr, "cannot connect to display!\n");
	exit(1);
     }

   e_ev_signal_init();
   e_event_filter_init();
   e_ev_x_init();
   
   /* become a wm */
   e_grab();
   e_sync();
   e_set_error_handler(wm_running_error);
   e_window_set_events(0, XEV_CHILD_REDIRECT | XEV_PROPERTY | XEV_COLORMAP);
   e_sync();
   e_reset_error_handler();
   e_ungrab();

   e_fs_init();
   e_desktops_init();
   e_border_init();
   e_action_init();
   e_menu_init();
   e_view_init();
   e_entry_init();
   e_keys_init();
   e_guides_init();
   
#ifdef USE_FERITE
   e_ferite_init();
#endif
   
   setup();
   
   e_event_loop();

#ifdef USE_FERITE
   e_ferite_deinit();
#endif
   
   return 0;
   UN(argc);
   UN(argv);
}