PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/platform/unix/main.d

http://github.com/wilkie/djehuty
D | 122 lines | 71 code | 33 blank | 18 comment | 0 complexity | 1c2564f1857243ee88b8c7b6c7034e4f MD5 | raw file
  1/*
  2 * main.d
  3 *
  4 * This file implements the main routines for the Linux system.
  5 * This file is the entry point for a Linux application.
  6 *
  7 * Author: Dave Wilkinson
  8 *
  9 */
 10
 11module platform.unix.main;
 12
 13import platform.unix.common;
 14import platform.application;
 15
 16import scaffold.console;
 17import scaffold.directory;
 18
 19import platform.vars.window;
 20
 21import gui.application;
 22import gui.window;
 23
 24import core.definitions;
 25import core.main;
 26import core.string;
 27import core.arguments;
 28
 29import graphics.view;
 30
 31import synch.thread;
 32
 33import analyzing.debugger;
 34
 35import io.console;
 36
 37import cui.application;
 38import cui.window;
 39
 40struct DjehutyPlatformVars {
 41	X.Display* display;
 42	X.Visual* visual;
 43	int screen;
 44
 45	X.Atom wm_destroy_window;
 46	X.Atom wm_name;
 47	X.Atom wm_hints;
 48	X.Atom utf8string;
 49	X.Atom private_data;
 50
 51	//for mouse double click timer
 52	static sigevent clickTimerevp = {{0}};
 53	static timer_t clickTimerId = null;
 54	static const itimerspec clickTimertime = {{0, 0}, {0, 250000000}};
 55
 56	//for keys
 57	static const int numSysKeys = 6;
 58	static const X.KeySym[6] sysKey = [Key.Backspace, Key.Delete, Key.Left, Key.Right, Key.Down, Key.Up];
 59
 60	//GTK IMPLEMENTATION:
 61
 62	//for xsettings - GTK
 63	X.Atom x_settings;
 64
 65	X.Window x_manager;
 66
 67	bool running = false;
 68
 69	int argc;
 70	char** argv;
 71}
 72
 73DjehutyPlatformVars* _pfvars() {
 74	static DjehutyPlatformVars pfvars;
 75
 76	return &pfvars;
 77}
 78
 79extern(C) void mousetimerproc(sigval val) {
 80	Mouse* p_mouseProps;
 81
 82	p_mouseProps = cast(Mouse*)val.sival_ptr;
 83
 84	p_mouseProps.clicks = 1;
 85}
 86
 87// segfault handler
 88extern(C) void segfault_handler(int signum) {
 89	throw new Exception("Access Violation");
 90}
 91
 92void AppInit()
 93{
 94	// ------------- */
 95
 96	// UTF-8 SUPPORT
 97//	_pfvars.wm_name = X.XInternAtom(_pfvars.display, "_NET_WM_NAME\0"c.ptr, X.Bool.True);
 98	setlocale(LC_CTYPE, "");
 99
100	// segfault handler
101	signal(SIGSEGV, &segfault_handler);
102}
103
104int main(char[][] args){
105	try	{
106		AppInit();
107
108		Arguments argList = Arguments.instance();
109		foreach(arg; args) {
110			argList.add(arg);
111		}
112
113		ConsoleInit();
114		Djehuty.application.run();
115		ConsoleUninit();
116	}
117	catch(Object o)	{
118		Debugger.raiseException(cast(Exception)o);
119	}
120
121	return ApplicationController.instance.exitCode;
122}