예제 #1
0
파일: winmenu.c 프로젝트: d-torrance/wmaker
static void makeShortcutCommand(WMenu * menu, WMenuEntry * entry)
{
	WWindow *wwin = (WWindow *) entry->clientdata;
	WScreen *scr = wwin->screen_ptr;
	int index = entry->order - wlengthof(menu_options_entries);

	/* Parameter not used, but tell the compiler that it is ok */
	(void) menu;

	if (scr->shortcutWindows[index]) {
		WMFreeArray(scr->shortcutWindows[index]);
		scr->shortcutWindows[index] = NULL;
	}

	if (wwin->flags.selected && scr->selected_windows) {
		scr->shortcutWindows[index] = WMDuplicateArray(scr->selected_windows);
		/*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
		   WMInsertInArray(scr->shortcutWindows[index], 0, wwin); */
	} else {
		scr->shortcutWindows[index] = WMCreateArray(4);
		WMAddToArray(scr->shortcutWindows[index], wwin);
	}

	wSelectWindow(wwin, !wwin->flags.selected);
	XFlush(dpy);
	wusleep(3000);
	wSelectWindow(wwin, !wwin->flags.selected);
	XFlush(dpy);
}
예제 #2
0
파일: winmenu.c 프로젝트: d-torrance/wmaker
static WMenu *makeOptionsMenu(WScreen * scr)
{
	WMenu *menu;
	WMenuEntry *entry;
	int i;

	menu = wMenuCreate(scr, NULL, False);
	if (!menu) {
		wwarning(_("could not create submenu for window menu"));
		return NULL;
	}

	for (i = 0; i < wlengthof(menu_options_entries); i++) {
		entry = wMenuAddCallback(menu, _(menu_options_entries[i]), execWindowOptionCommand, NULL);
		entry->flags.indicator = 1;
		entry->flags.indicator_type = MI_CHECK;
	}

	for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
		entry = wMenuAddCallback(menu, "", makeShortcutCommand, NULL);
		entry->flags.indicator = 1;
	}

	return menu;
}
예제 #3
0
static int getWheelAction(const char *str)
{
	int i;

	if (!str)
		return -2;

	for (i = 0; i < wlengthof(wheel_actions); i++) {
		if (strcasecmp(str, wheel_actions[i].db_value) == 0)
			return i;
	}

	return -1;
}
예제 #4
0
static void storeData(_Panel * panel)
{
	char buffer[64];
	int i;
	char *tmp, *p;
	WMUserDefaults *udb = WMGetStandardUserDefaults();

	if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) {
		tmp = WMGetTextFieldText(panel->threT);
		if (strlen(tmp) == 0) {
			wfree(tmp);
			tmp = wstrdup("4");
		}

		sprintf(buffer, XSET " m %i/%i %s\n", (int)(panel->acceleration * 10), 10, tmp);
		storeCommandInScript(XSET " m", buffer);

		wfree(tmp);
	}

	tmp = WMGetTextFieldText(panel->ddelaT);
	if (sscanf(tmp, "%i", &i) == 1 && i > 0)
		SetIntegerForKey(i, "DoubleClickTime");
	wfree(tmp);

	SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions");

	for (i = 0; i < wlengthof(button_list); i++) {
		const char *db_value;
		int action;

		action = WMGetPopUpButtonSelectedItem(panel->mouse_action[i].popup);
		if (button_list[i].type == T_BUTTON)
			db_value = button_actions[action].db_value;
		else
			db_value = wheel_actions[action].db_value;
		SetStringForKey(db_value, button_list[i].db_key);
	}

	tmp = WMGetPopUpButtonItem(panel->grabP, WMGetPopUpButtonSelectedItem(panel->grabP));
	tmp = wstrdup(tmp);
	p = strchr(tmp, ' ');
	if (p != NULL)
		*p = '\0';

	SetStringForKey(tmp, "ModifierKey");

	wfree(tmp);
}
예제 #5
0
static void doubleClick(WMWidget * w, void *data)
{
	_Panel *panel = (_Panel *) data;
	int i;
	char buffer[32];

	for (i = 0; i < wlengthof(panel->ddelaB); i++) {
		if (panel->ddelaB[i] == w)
			break;
	}
	WINGsConfiguration.doubleClickDelay = DELAY(i);

	sprintf(buffer, "%i", DELAY(i));
	WMSetTextFieldText(panel->ddelaT, buffer);
}
예제 #6
0
static void toggle_disabling_of_mouse_actions(WMWidget *w, void *client_data)
{
	WMButton *button = (WMButton *) w;
	Panel *panel = (Panel *) client_data;
	Bool do_enable;
	int i;

	if (WMGetButtonSelected(button))
		do_enable = False;
	else
		do_enable = True;

	for (i = 0; i < wlengthof(panel->mouse_action); i++)
		WMSetPopUpButtonEnabled(panel->mouse_action[i].popup, do_enable);
}
예제 #7
0
파일: winmenu.c 프로젝트: d-torrance/wmaker
static WMenu *makeMaximizeMenu(WScreen * scr)
{
	WMenu *menu;
	int i;

	menu = wMenuCreate(scr, NULL, False);
	if (!menu) {
		wwarning(_("could not create submenu for window menu"));
		return NULL;
	}

	for (i = 0; i < wlengthof(menu_maximize_entries); i++)
		wMenuAddCallback(menu, _(menu_maximize_entries[i].label), execMaximizeCommand, NULL);

	return menu;
}
예제 #8
0
/* Check wether a macro exists or not, and marks the parser to ignore the
 * following data accordingly */
static void menu_parser_condition_ifmacro(WMenuParser parser, Bool check_exists)
{
	WParserMacro *macro;
	int idx;
	const char *cmd_name, *macro_name;

	cmd_name = check_exists?"ifdef":"ifndef";
	if (!menu_parser_skip_spaces_and_comments(parser)) {
		WMenuParserError(parser, _("missing macro name argument to #%s"), cmd_name);
		return;
	}

	/* jump to end of provided name for later checks that no extra stuff is following */
	macro_name = parser->rd;
	while (isnamechr(*parser->rd))
		parser->rd++;

	/* Add this condition to the stack of conditions */
	if (parser->cond.depth >= wlengthof(parser->cond.stack)) {
		WMenuParserError(parser, _("too many nested #if sequences") );
		return;
	}

	for (idx = parser->cond.depth - 1; idx >= 0; idx--)
		parser->cond.stack[idx + 1] = parser->cond.stack[idx];

	parser->cond.depth++;

	if (parser->cond.stack[1].skip) {
		parser->cond.stack[0].skip = True;
	} else {
		macro = menu_parser_find_macro(parser, macro_name);
		parser->cond.stack[0].skip =
			((check_exists)  && (macro == NULL)) ||
			((!check_exists) && (macro != NULL)) ;
	}

	strcpy(parser->cond.stack[0].name, cmd_name);
	parser->cond.stack[0].line = parser->line_number;
}
예제 #9
0
파일: winmenu.c 프로젝트: d-torrance/wmaker
static WMenu *createWindowMenu(WScreen * scr)
{
	WMenu *menu;
	int i;

	menu = wMenuCreate(scr, NULL, False);

	for (i = 0; i < wlengthof(window_menu_entries); i++) {
		WMenuEntry *entry;

		entry = wMenuAddCallback(menu, _(window_menu_entries[i].label),
		                         (window_menu_entries[i].generate_submenu == NULL)?execMenuCommand:NULL,
		                         NULL);
		if (window_menu_entries[i].generate_submenu != NULL) {
			WMenu *submenu;

			submenu = window_menu_entries[i].generate_submenu(scr);
			wMenuEntrySetCascade(menu, entry, submenu);
		}
	}

	return menu;
}
예제 #10
0
/* pick a terminal emulator by finding the first existing entry of `terminals'
 * in $PATH. the returned pointer should be wfreed later.
 * if $WMMENU_TERMINAL exists in the environment, it's value overrides this
 * detection.
 */
char *find_terminal_emulator(void)
{
	char *path, *t;
	int i;

	t = getenv("WMMENU_TERMINAL");
	if (t)
		return wstrdup(t);

	path = getenv("PATH");
	if (!path)
		return NULL;

	for (i = 0; i < wlengthof(terminals); i++) {
		t = wfindfile(path, terminals[i]);
		if (t) {
			wfree(t);
			return wstrdup(terminals[i]);
		}
	}

	return NULL;
}
예제 #11
0
static void create_tab_window_advanced(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
	int i = 0;
	char *caption = NULL, *descr = NULL;
	int flag = 0;

	panel->moreFrm = WMCreateFrame(panel->win);
	WMSetFrameTitle(panel->moreFrm, _("Advanced"));
	WMMoveWidget(panel->moreFrm, 15, 45);
	WMResizeWidget(panel->moreFrm, frame_width, 265);

	for (i = 0; i < wlengthof(panel->moreChk); i++) {
		switch (i) {
		case 0:
			caption = _("Do not bind keyboard shortcuts");
			flag = WFLAGP(wwin, no_bind_keys);
			descr = _("Do not bind keyboard shortcuts from Window Maker\n"
				  "when this window is focused. This will allow the\n"
				  "window to receive all key combinations regardless\n"
				  "of your shortcut configuration.");
			break;
		case 1:
			caption = _("Do not bind mouse clicks");
			flag = WFLAGP(wwin, no_bind_mouse);
			descr = _("Do not bind mouse actions, such as `Alt'+drag\n"
				  "in the window (when alt is the modifier you have\n" "configured).");
			break;
		case 2:
			caption = _("Do not show in the window list");
			flag = WFLAGP(wwin, skip_window_list);
			descr = _("Do not list the window in the window list menu.");
			break;
		case 3:
			caption = _("Do not show in the switch panel");
			flag = WFLAGP(wwin, skip_switchpanel);
			descr = _("Do not include in switch panel while cycling windows.");
			break;
		case 4:
			caption = _("Do not let it take focus");
			flag = WFLAGP(wwin, no_focusable);
			descr = _("Do not let the window take keyboard focus when you\n" "click on it.");
			break;
		case 5:
			caption = _("Keep inside screen");
			flag = WFLAGP(wwin, dont_move_off);
			descr = _("Do not allow the window to move itself completely\n"
				  "outside the screen. For bug compatibility.\n");
			break;
		case 6:
			caption = _("Ignore 'Hide Others'");
			flag = WFLAGP(wwin, no_hide_others);
			descr = _("Do not hide the window when issuing the\n" "`HideOthers' command.");
			break;
		case 7:
			caption = _("Ignore 'Save Session'");
			flag = WFLAGP(wwin, dont_save_session);
			descr = _("Do not save the associated application in the\n"
				  "session's state, so that it won't be restarted\n"
				  "together with other applications when Window Maker\n" "starts.");
			break;
		case 8:
			caption = _("Emulate application icon");
			flag = WFLAGP(wwin, emulate_appicon);
			descr = _("Make this window act as an application that provides\n"
				  "enough information to Window Maker for a dockable\n"
				  "application icon to be created.");
			break;
		case 9:
			caption = _("Focus across workspaces");
			flag = WFLAGP(wwin, focus_across_wksp);
			descr = _("Allow Window Maker to switch workspace to satisfy\n"
				  "a focus request (annoying).");
			break;
		case 10:
			caption = _("Do not let it be minimized");
			flag = WFLAGP(wwin, no_miniaturizable);
			descr = _("Do not let the window of this application be\n"
					  "minimized.\n");
			break;
#ifdef XKB_BUTTON_HINT
		case 11:
			caption = _("Disable language button");
			flag = WFLAGP(wwin, no_language_button);
			descr = _("Remove the `toggle language' button of the window.");
			break;
#endif
		}
		panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);
		WMMoveWidget(panel->moreChk[i], 10, 20 * (i + 1));
		WMResizeWidget(panel->moreChk[i], frame_width - 15, 20);
		WMSetButtonSelected(panel->moreChk[i], flag);
		WMSetButtonText(panel->moreChk[i], caption);

		WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i]));
	}
}
예제 #12
0
파일: winmenu.c 프로젝트: d-torrance/wmaker
static void updateMakeShortcutMenu(WMenu * menu, WWindow * wwin)
{
	WMenu *smenu = menu->cascades[menu->entries[MC_OPTIONS]->cascade];
	int i;
	char *buffer;
	int buflen;
	KeyCode kcode;

	if (!smenu)
		return;

	buflen = strlen(_("Set Shortcut")) + 16;
	buffer = wmalloc(buflen);

	for (i = wlengthof(menu_options_entries); i < smenu->entry_no; i++) {
		int shortcutNo = i - wlengthof(menu_options_entries);
		WMenuEntry *entry = smenu->entries[i];
		WMArray *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo];

		snprintf(buffer, buflen, "%s %i", _("Set Shortcut"), shortcutNo + 1);

		if (!shortSelWindows) {
			entry->flags.indicator_on = 0;
		} else {
			entry->flags.indicator_on = 1;
			if (WMCountInArray(shortSelWindows, wwin))
				entry->flags.indicator_type = MI_DIAMOND;
			else
				entry->flags.indicator_type = MI_CHECK;
		}

		if (strcmp(buffer, entry->text) != 0) {
			wfree(entry->text);
			entry->text = wstrdup(buffer);
			smenu->flags.realized = 0;
		}

		kcode = wKeyBindings[WKBD_WINDOW1 + shortcutNo].keycode;

		if (kcode) {
			char *tmp;

			tmp = GetShortcutKey(wKeyBindings[WKBD_WINDOW1 + shortcutNo]);
			if (tmp == NULL) {
				if (entry->rtext != NULL) {
					/* There was a shortcut, but there is no more */
					wfree(entry->rtext);
					entry->rtext = NULL;
					smenu->flags.realized = 0;
				}
			} else if (entry->rtext == NULL) {
				/* There was no shortcut, but there is one now */
				entry->rtext = tmp;
				smenu->flags.realized = 0;
			} else if (strcmp(tmp, entry->rtext) != 0) {
				/* There was a shortcut, but it has changed */
				wfree(entry->rtext);
				entry->rtext = tmp;
				smenu->flags.realized = 0;
			} else {
				/* There was a shortcut but it did not change */
				wfree(tmp);
			}
			wMenuSetEnabled(smenu, i, True);
		} else {
			wMenuSetEnabled(smenu, i, False);
			if (entry->rtext) {
				wfree(entry->rtext);
				entry->rtext = NULL;
				smenu->flags.realized = 0;
			}
		}
		entry->clientdata = wwin;
	}
	wfree(buffer);
	if (!smenu->flags.realized)
		wMenuRealize(smenu);
}
예제 #13
0
static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
	WScreen *scr = wwin->screen_ptr;
	int i = 0, flag = 0, tmp;
	char *caption = NULL, *descr = NULL;


	if (wwin->main_window != None) {
		WApplication *wapp = wApplicationOf(wwin->main_window);

		panel->appFrm = WMCreateFrame(panel->win);
		WMSetFrameTitle(panel->appFrm, _("Application Attributes"));
		WMMoveWidget(panel->appFrm, 15, 50);
		WMResizeWidget(panel->appFrm, frame_width, 240);

		for (i = 0; i < wlengthof(panel->appChk); i++) {
			switch (i) {
			case 0:
				caption = _("Start hidden");
				flag = WFLAGP(wapp->main_window_desc, start_hidden);
				descr = _("Automatically hide application when it's started.");
				break;
			case 1:
				caption = _("No application icon");
				flag = WFLAGP(wapp->main_window_desc, no_appicon);
				descr = _("Disable the application icon for the application.\n"
					  "Note that you won't be able to dock it anymore,\n"
					  "and any icons that are already docked will stop\n"
					  "working correctly.");
				break;
			case 2:
				caption = _("Shared application icon");
				flag = WFLAGP(wapp->main_window_desc, shared_appicon);
				descr = _("Use a single shared application icon for all of\n"
					  "the instances of this application.\n");
				break;
			}
			panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
			WMMoveWidget(panel->appChk[i], 10, 20 * (i + 1));
			WMResizeWidget(panel->appChk[i], 205, 20);
			WMSetButtonSelected(panel->appChk[i], flag);
			WMSetButtonText(panel->appChk[i], caption);
			WMSetBalloonTextForView(descr, WMWidgetView(panel->appChk[i]));
		}

		if (WFLAGP(wwin, emulate_appicon)) {
			WMSetButtonEnabled(panel->appChk[1], False);
			WMSetButtonEnabled(panel->moreChk[7], True);
		} else {
			WMSetButtonEnabled(panel->appChk[1], True);
			WMSetButtonEnabled(panel->moreChk[7], False);
		}
	} else {
		if ((wwin->transient_for != None && wwin->transient_for != scr->root_win)
		    || !wwin->wm_class || !wwin->wm_instance)
			tmp = False;
		else
			tmp = True;

		WMSetButtonEnabled(panel->moreChk[7], tmp);

		WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
		panel->appFrm = NULL;
	}
}
예제 #14
0
static void revertSettings(WMWidget *button, void *client_data)
{
	InspectorPanel *panel = (InspectorPanel *) client_data;
	WWindow *wwin = panel->inspected;
	WApplication *wapp = wApplicationOf(wwin->main_window);
	int i, n, workspace, level;
	char *wm_instance = NULL, *wm_class = NULL;

	/* Parameter not used, but tell the compiler that it is ok */
	(void) button;

	if (panel->instRb && WMGetButtonSelected(panel->instRb) != 0)
		wm_instance = wwin->wm_instance;
	else if (panel->clsRb && WMGetButtonSelected(panel->clsRb) != 0)
		wm_class = wwin->wm_class;
	else if (panel->bothRb && WMGetButtonSelected(panel->bothRb) != 0) {
		wm_instance = wwin->wm_instance;
		wm_class = wwin->wm_class;
	}

	memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
	memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
	memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));

	wWindowSetupInitialAttributes(wwin, &level, &workspace);

	for (i = 0; i < wlengthof(panel->attrChk); i++) {
		int flag = 0;

		switch (i) {
		case 0:
			flag = WFLAGP(wwin, no_titlebar);
			break;
		case 1:
			flag = WFLAGP(wwin, no_resizebar);
			break;
		case 2:
			flag = WFLAGP(wwin, no_close_button);
			break;
		case 3:
			flag = WFLAGP(wwin, no_miniaturize_button);
			break;
		case 4:
			flag = WFLAGP(wwin, no_border);
			break;
		case 5:
			flag = WFLAGP(wwin, floating);
			break;
		case 6:
			flag = WFLAGP(wwin, sunken);
			break;
		case 7:
			flag = WFLAGP(wwin, omnipresent);
			break;
		case 8:
			flag = WFLAGP(wwin, start_miniaturized);
			break;
		case 9:
			flag = WFLAGP(wwin, start_maximized != 0);
			break;
		case 10:
			flag = WFLAGP(wwin, full_maximize);
			break;
		}
		WMSetButtonSelected(panel->attrChk[i], flag);
	}

	for (i = 0; i < wlengthof(panel->moreChk); i++) {
		int flag = 0;

		switch (i) {
		case 0:
			flag = WFLAGP(wwin, no_bind_keys);
			break;
		case 1:
			flag = WFLAGP(wwin, no_bind_mouse);
			break;
		case 2:
			flag = WFLAGP(wwin, skip_window_list);
			break;
		case 3:
			flag = WFLAGP(wwin, skip_switchpanel);
			break;
		case 4:
			flag = WFLAGP(wwin, no_focusable);
			break;
		case 5:
			flag = WFLAGP(wwin, dont_move_off);
			break;
		case 6:
			flag = WFLAGP(wwin, no_hide_others);
			break;
		case 7:
			flag = WFLAGP(wwin, dont_save_session);
			break;
		case 8:
			flag = WFLAGP(wwin, emulate_appicon);
			break;
		case 9:
			flag = WFLAGP(wwin, focus_across_wksp);
			break;
		case 10:
			flag = WFLAGP(wwin, no_miniaturizable);
			break;
#ifdef XKB_BUTTON_HINT
		case 11:
			flag = WFLAGP(wwin, no_language_button);
			break;
#endif
		}
		WMSetButtonSelected(panel->moreChk[i], flag);
	}
	if (panel->appFrm && wapp) {
		for (i = 0; i < wlengthof(panel->appChk); i++) {
			int flag = 0;

			switch (i) {
			case 0:
				flag = WFLAGP(wapp->main_window_desc, start_hidden);
				break;
			case 1:
				flag = WFLAGP(wapp->main_window_desc, no_appicon);
				break;
			case 2:
				flag = WFLAGP(wapp->main_window_desc, shared_appicon);
				break;
			}
			WMSetButtonSelected(panel->appChk[i], flag);
		}
	}
	WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));

	showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class, REVERT_TO_DEFAULT);

	n = wDefaultGetStartWorkspace(wm_instance, wm_class);

	if (n >= 0 && n < w_global.workspace.count)
		WMSetPopUpButtonSelectedItem(panel->wsP, n + 1);
	else
		WMSetPopUpButtonSelectedItem(panel->wsP, 0);

	/* must auto apply, so that there wno't be internal
	 * inconsistencies between the state in the flags and
	 * the actual state of the window */
	applySettings(panel->applyBtn, panel);
}
예제 #15
0
static void createPanel(Panel * p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	WMPixmap *icon;
	char *buf1, *buf2;
	int i;
	RColor color;
	char *path;

	color.red = 0xae;
	color.green = 0xaa;
	color.blue = 0xae;

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

    /**************** Mouse Speed ****************/
	panel->speedF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->speedF, 219, 85);
	WMMoveWidget(panel->speedF, 9, 54);
	WMSetFrameTitle(panel->speedF, _("Mouse Speed"));

	panel->speedL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->speedL, 40, 46);
	WMMoveWidget(panel->speedL, 8, 10);
	WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
	path = LocateImage(SPEED_ICON_FILE);
	if (path) {
		icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
		if (icon) {
			WMSetLabelImage(panel->speedL, icon);
			WMReleasePixmap(icon);
		} else {
			wwarning(_("could not load icon %s"), path);
		}
		wfree(path);
	}

	panel->speedS = WMCreateSlider(panel->speedF);
	WMResizeWidget(panel->speedS, 150, 15);
	WMMoveWidget(panel->speedS, 58, 30);
	WMSetSliderMinValue(panel->speedS, 0);
	WMSetSliderMaxValue(panel->speedS, 40);
	WMSetSliderContinuous(panel->speedS, False);
	WMSetSliderAction(panel->speedS, speedChange, panel);

	panel->acceL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->acceL, 50, 16);
	WMMoveWidget(panel->acceL, 8, 58);
	WMSetLabelTextAlignment(panel->acceL, WARight);
	WMSetLabelText(panel->acceL, _("Accel.:"));

	panel->acceT = WMCreateTextField(panel->speedF);
	WMResizeWidget(panel->acceT, 40, 20);
	WMMoveWidget(panel->acceT, 58, 56);
	WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->acceT);

	panel->threL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->threL, 80, 16);
	WMMoveWidget(panel->threL, 98, 58);
	WMSetLabelTextAlignment(panel->threL, WARight);
	WMSetLabelText(panel->threL, _("Threshold:"));

	panel->threT = WMCreateTextField(panel->speedF);
	WMResizeWidget(panel->threT, 30, 20);
	WMMoveWidget(panel->threT, 178, 56);
	WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->threT);

	WMMapSubwidgets(panel->speedF);

	/* ************** Grab Modifier **************** */
	panel->grabF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->grabF, 219, 46);
	WMMoveWidget(panel->grabF, 9, 5);
	WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));

	WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
				  "involve dragging windows with the mouse,\n"
				  "clicking inside the window."), WMWidgetView(panel->grabF));

	panel->grabP = WMCreatePopUpButton(panel->grabF);
	WMResizeWidget(panel->grabP, 178, 20);
	WMMoveWidget(panel->grabP, 20, 17);

	fillModifierPopUp(panel->grabP);
	WMMapSubwidgets(panel->grabF);

	/***************** Doubleclick Delay ****************/

	panel->ddelaF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->ddelaF, 219, 80);
	WMMoveWidget(panel->ddelaF, 9, 142);
	WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));

	buf1 = wmalloc(strlen(DELAY_ICON) + 2);
	buf2 = wmalloc(strlen(DELAY_ICON_S) + 2);

	for (i = 0; i < wlengthof(panel->ddelaB); i++) {
		panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask);
		WMResizeWidget(panel->ddelaB[i], 25, 25);
		WMMoveWidget(panel->ddelaB[i], 18 + (40 * i), 18);
		WMSetButtonBordered(panel->ddelaB[i], False);
		WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
		WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
		if (i > 0) {
			WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
		}
		sprintf(buf1, DELAY_ICON, i + 1);
		sprintf(buf2, DELAY_ICON_S, i + 1);
		path = LocateImage(buf1);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonImage(panel->ddelaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
		path = LocateImage(buf2);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonAltImage(panel->ddelaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
	}
	wfree(buf1);
	wfree(buf2);

	panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
	WMResizeWidget(panel->tester, 84, 24);
	WMMoveWidget(panel->tester, 20, 48);

	panel->ddelaT = WMCreateTextField(panel->ddelaF);
	WMResizeWidget(panel->ddelaT, 40, 20);
	WMMoveWidget(panel->ddelaT, 130, 50);

	panel->ddelaL = WMCreateLabel(panel->ddelaF);
	WMResizeWidget(panel->ddelaL, 40, 16);
	WMMoveWidget(panel->ddelaL, 173, 54);
	{
		WMFont *font;
		WMColor *color;

		font = WMSystemFontOfSize(scr, 10);
		color = WMDarkGrayColor(scr);
		WMSetLabelTextColor(panel->ddelaL, color);
		WMSetLabelFont(panel->ddelaL, font);
		WMReleaseFont(font);
		WMReleaseColor(color);
	}
	WMSetLabelText(panel->ddelaL, _("ms"));

	WMMapSubwidgets(panel->ddelaF);

	/* ************** Workspace Action Buttons **************** */

	panel->menuF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->menuF, 276, 217);
	WMMoveWidget(panel->menuF, 236, 5);
	WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));

	panel->disaB = WMCreateSwitchButton(panel->menuF);
	WMResizeWidget(panel->disaB, 254, 18);
	WMMoveWidget(panel->disaB, 10, 15);
	WMSetButtonText(panel->disaB, _("Disable mouse actions"));
	WMSetButtonAction(panel->disaB, toggle_disabling_of_mouse_actions, panel);

	for (i = 0; i < wlengthof(button_list); i++) {
		int j;

		panel->mouse_action[i].label = WMCreateLabel(panel->menuF);
		WMResizeWidget(panel->mouse_action[i].label, 115, 20);
		WMMoveWidget(panel->mouse_action[i].label, 4, 37 + 25 * i);
		WMSetLabelTextAlignment(panel->mouse_action[i].label, WARight);
		WMSetLabelText(panel->mouse_action[i].label, _(button_list[i].display_label));

		panel->mouse_action[i].popup = WMCreatePopUpButton(panel->menuF);
		WMResizeWidget(panel->mouse_action[i].popup, 145, 20);
		WMMoveWidget(panel->mouse_action[i].popup, 121, 37 + 25 * i);

		if (button_list[i].type == T_BUTTON) {
			for (j = 0; j < wlengthof(button_actions); j++)
				WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(button_actions[j].label));
		} else {
			for (j = 0; j < wlengthof(wheel_actions); j++)
				WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(wheel_actions[j].label));
		}
	}
	WMMapSubwidgets(panel->menuF);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);

	showData(panel);
}
예제 #16
0
static void showData(_Panel * panel)
{
	char *str;
	int i;
	int a = -1, b = -1;
	float accel;
	char buffer[32];
	Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent));

	for (i = 0; i < wlengthof(button_list); i++) {
		int action;

		str = GetStringForKey(button_list[i].db_key);
		if (button_list[i].type == T_BUTTON)
			action = getButtonAction(str);
		else
			action = getWheelAction(str);

		if (action < 0) {
			if (action == -1)
				wwarning(_("bad value %s for option %s"), str, button_list[i].db_key);
			action = button_list[i].default_action;
		}
		WMSetPopUpButtonSelectedItem(panel->mouse_action[i].popup, action);
	}

	WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions"));
	toggle_disabling_of_mouse_actions(panel->disaB, panel);

	 /**/ getMouseParameters(dpy, &accel, &a);
	panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy));
	if (a > panel->maxThreshold) {
		panel->maxThreshold = a;
	}
	sprintf(buffer, "%i", a);
	WMSetTextFieldText(panel->threT, buffer);

	WMSetSliderValue(panel->speedS, (accel - 0.25F) / 0.25F);

	panel->acceleration = accel;
	sprintf(buffer, "%.2f", (double)accel);
	WMSetTextFieldText(panel->acceT, buffer);

	 /**/ b = GetIntegerForKey("DoubleClickTime");
	/* find best match */
	a = -1;
	for (i = 0; i < wlengthof(panel->ddelaB); i++) {
		if (DELAY(i) == b)
			a = i;
	}
	if (a >= 0)
		WMPerformButtonClick(panel->ddelaB[a]);
	sprintf(buffer, "%i", b);
	WMSetTextFieldText(panel->ddelaT, buffer);

	 /**/ str = GetStringForKey("ModifierKey");
	if (!str)
		str = "mod1";
	a = ModifierFromKey(dpy, str);

	if (a != -1) {
		str = modifierNames[a];

		a = 0;
		for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->grabP); i++) {
			if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) {
				WMSetPopUpButtonSelectedItem(panel->grabP, i);
				a = 1;
				break;
			}
		}
	}

	if (a < 1) {
		char *previous;

		previous = WMGetPopUpButtonItem(panel->grabP, 0);
		if (previous != NULL)
			WMSetPopUpButtonSelectedItem(panel->grabP, 0);
		wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"),
					str, previous?previous:"(empty)");
	}
}
예제 #17
0
static void create_tab_window_attributes(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
	int i = 0;
	char *caption = NULL, *descr = NULL;
	int flag = 0;

	panel->attrFrm = WMCreateFrame(panel->win);
	WMSetFrameTitle(panel->attrFrm, _("Attributes"));
	WMMoveWidget(panel->attrFrm, 15, 45);
	WMResizeWidget(panel->attrFrm, frame_width, 250);

	for (i = 0; i < wlengthof(panel->attrChk); i++) {
		switch (i) {
		case 0:
			caption = _("Disable titlebar");
			flag = WFLAGP(wwin, no_titlebar);
			descr = _("Remove the titlebar of this window.\n"
				  "To access the window commands menu of a window\n"
				  "without it's titlebar, press Control+Esc (or the\n"
				  "equivalent shortcut, if you changed the default\n" "settings).");
			break;
		case 1:
			caption = _("Disable resizebar");
			flag = WFLAGP(wwin, no_resizebar);
			descr = _("Remove the resizebar of this window.");
			break;
		case 2:
			caption = _("Disable close button");
			flag = WFLAGP(wwin, no_close_button);
			descr = _("Remove the `close window' button of this window.");
			break;
		case 3:
			caption = _("Disable miniaturize button");
			flag = WFLAGP(wwin, no_miniaturize_button);
			descr = _("Remove the `miniaturize window' button of the window.");
			break;
		case 4:
			caption = _("Disable border");
			flag = WFLAGP(wwin, no_border);
			descr = _("Remove the 1 pixel black border around the window.");
			break;
		case 5:
			caption = _("Keep on top (floating)");
			flag = WFLAGP(wwin, floating);
			descr = _("Keep the window over other windows, not allowing\n" "them to cover it.");
			break;
		case 6:
			caption = _("Keep at bottom (sunken)");
			flag = WFLAGP(wwin, sunken);
			descr = _("Keep the window under all other windows.");
			break;
		case 7:
			caption = _("Omnipresent");
			flag = WFLAGP(wwin, omnipresent);
			descr = _("Make window present in all workspaces.");
			break;
		case 8:
			caption = _("Start miniaturized");
			flag = WFLAGP(wwin, start_miniaturized);
			descr = _("Make the window be automatically miniaturized when it's\n" "first shown.");
			break;
		case 9:
			caption = _("Start maximized");
			flag = WFLAGP(wwin, start_maximized != 0);
			descr = _("Make the window be automatically maximized when it's\n" "first shown.");
			break;
		case 10:
			caption = _("Full screen maximization");
			flag = WFLAGP(wwin, full_maximize);
			descr = _("Make the window use the whole screen space when it's\n"
				  "maximized. The titlebar and resizebar will be moved\n"
				  "to outside the screen.");
			break;
		}
		panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
		WMMoveWidget(panel->attrChk[i], 10, 20 * (i + 1));
		WMResizeWidget(panel->attrChk[i], frame_width - 15, 20);
		WMSetButtonSelected(panel->attrChk[i], flag);
		WMSetButtonText(panel->attrChk[i], caption);

		WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i]));
	}
}
예제 #18
0
파일: widgets.c 프로젝트: awmaker/awmaker
WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * context)
{
	W_Screen *scrPtr;
	XGCValues gcv;
	Pixmap stipple;
	static int initialized = 0;
	static char *atomNames[] = {
		"_GNUSTEP_WM_ATTR",
		"WM_DELETE_WINDOW",
		"WM_PROTOCOLS",
		"CLIPBOARD",
		"XdndAware",
		"XdndSelection",
		"XdndEnter",
		"XdndLeave",
		"XdndPosition",
		"XdndDrop",
		"XdndFinished",
		"XdndTypeList",
		"XdndActionList",
		"XdndActionDescription",
		"XdndStatus",
		"XdndActionCopy",
		"XdndActionMove",
		"XdndActionLink",
		"XdndActionAsk",
		"XdndActionPrivate",
		"_WINGS_DND_MOUSE_OFFSET",
		"WM_STATE",
		"UTF8_STRING",
		"_NET_WM_NAME",
		"_NET_WM_ICON_NAME",
		"_NET_WM_ICON",
	};
	Atom atoms[wlengthof(atomNames)];
	int i;

	if (!initialized) {

		initialized = 1;

		W_ReadConfigurations();

		assert(W_ApplicationInitialized());
	}

	scrPtr = malloc(sizeof(W_Screen));
	if (!scrPtr)
		return NULL;
	memset(scrPtr, 0, sizeof(W_Screen));

	scrPtr->aflags.hasAppIcon = 1;

	scrPtr->display = display;
	scrPtr->screen = screen;
	scrPtr->rcontext = context;

	scrPtr->depth = context->depth;

	scrPtr->visual = context->visual;
	scrPtr->lastEventTime = 0;

	scrPtr->colormap = context->cmap;

	scrPtr->rootWin = RootWindow(display, screen);

	scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);

	scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr), scrPtr->visual, scrPtr->colormap);

	/* Create missing CUT_BUFFERs */
	{
		Atom *rootWinProps;
		int exists[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
		int count;

		rootWinProps = XListProperties(display, scrPtr->rootWin, &count);
		for (i = 0; i < count; i++) {
			switch (rootWinProps[i]) {
			case XA_CUT_BUFFER0:
				exists[0] = 1;
				break;
			case XA_CUT_BUFFER1:
				exists[1] = 1;
				break;
			case XA_CUT_BUFFER2:
				exists[2] = 1;
				break;
			case XA_CUT_BUFFER3:
				exists[3] = 1;
				break;
			case XA_CUT_BUFFER4:
				exists[4] = 1;
				break;
			case XA_CUT_BUFFER5:
				exists[5] = 1;
				break;
			case XA_CUT_BUFFER6:
				exists[6] = 1;
				break;
			case XA_CUT_BUFFER7:
				exists[7] = 1;
				break;
			default:
				break;
			}
		}
		if (rootWinProps) {
			XFree(rootWinProps);
		}
		for (i = 0; i < 8; i++) {
			if (!exists[i]) {
				XStoreBuffer(display, "", 0, i);
			}
		}
	}

	scrPtr->ignoredModifierMask = 0;
	{
		int i;
		XModifierKeymap *modmap;
		KeyCode nlock, slock;
		static int mask_table[8] = {
			ShiftMask, LockMask, ControlMask, Mod1Mask,
			Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
		};
		unsigned int numLockMask = 0, scrollLockMask = 0;

		nlock = XKeysymToKeycode(display, XK_Num_Lock);
		slock = XKeysymToKeycode(display, XK_Scroll_Lock);

		/*
		 * Find out the masks for the NumLock and ScrollLock modifiers,
		 * so that we can bind the grabs for when they are enabled too.
		 */
		modmap = XGetModifierMapping(display);

		if (modmap != NULL && modmap->max_keypermod > 0) {
			for (i = 0; i < 8 * modmap->max_keypermod; i++) {
				if (modmap->modifiermap[i] == nlock && nlock != 0)
					numLockMask = mask_table[i / modmap->max_keypermod];
				else if (modmap->modifiermap[i] == slock && slock != 0)
					scrollLockMask = mask_table[i / modmap->max_keypermod];
			}
		}

		if (modmap)
			XFreeModifiermap(modmap);

		scrPtr->ignoredModifierMask = numLockMask | scrollLockMask | LockMask;
	}

	/* initially allocate some colors */
	WMWhiteColor(scrPtr);
	WMBlackColor(scrPtr);
	WMGrayColor(scrPtr);
	WMDarkGrayColor(scrPtr);

	gcv.graphics_exposures = False;

	gcv.function = GXxor;
	gcv.foreground = W_PIXEL(scrPtr->white);
	if (gcv.foreground == 0)
		gcv.foreground = 1;
	scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
				  | GCGraphicsExposures | GCForeground, &gcv);

	gcv.function = GXxor;
	gcv.foreground = W_PIXEL(scrPtr->gray);
	gcv.subwindow_mode = IncludeInferiors;
	scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
				   | GCGraphicsExposures | GCForeground | GCSubwindowMode, &gcv);

	gcv.function = GXcopy;
	scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv);

	scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv);

	stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr), STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
	gcv.foreground = W_PIXEL(scrPtr->darkGray);
	gcv.background = W_PIXEL(scrPtr->gray);
	gcv.fill_style = FillStippled;
	gcv.stipple = stipple;
	scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
				      GCForeground | GCBackground | GCStipple
				      | GCFillStyle | GCGraphicsExposures, &gcv);

	scrPtr->drawStringGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCGraphicsExposures, &gcv);
	scrPtr->drawImStringGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCGraphicsExposures, &gcv);

	/* we need a 1bpp drawable for the monoGC, so borrow this one */
	scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);

	scrPtr->stipple = stipple;

	scrPtr->antialiasedText = WINGsConfiguration.antialiasedText;

	scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 0);

	scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 0);

	if (!scrPtr->boldFont)
		scrPtr->boldFont = scrPtr->normalFont;

	if (!scrPtr->normalFont) {
		wwarning(_("could not load any fonts. Make sure your font installation"
			   " and locale settings are correct."));

		return NULL;
	}

	/* create input method stuff */
	W_InitIM(scrPtr);

	scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
						CHECK_BUTTON_ON_WIDTH, CHECK_BUTTON_ON_HEIGHT, False);

	scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
						 CHECK_BUTTON_OFF_WIDTH, CHECK_BUTTON_OFF_HEIGHT, False);

	scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
						RADIO_BUTTON_ON_WIDTH, RADIO_BUTTON_ON_HEIGHT, False);

	scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
						 RADIO_BUTTON_OFF_WIDTH, RADIO_BUTTON_OFF_HEIGHT, False);

	scrPtr->tristateButtonImageOn = makePixmap(scrPtr, TRISTATE_BUTTON_ON,
	                                           TRISTATE_BUTTON_ON_WIDTH, TRISTATE_BUTTON_ON_HEIGHT, False);

	scrPtr->tristateButtonImageOff = makePixmap(scrPtr, TRISTATE_BUTTON_OFF,
	                                            TRISTATE_BUTTON_OFF_WIDTH, TRISTATE_BUTTON_OFF_HEIGHT, False);

	scrPtr->tristateButtonImageTri = makePixmap(scrPtr, TRISTATE_BUTTON_TRI,
	                                            TRISTATE_BUTTON_TRI_WIDTH, TRISTATE_BUTTON_TRI_HEIGHT, False);

	scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW, BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT, False);

	scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
					       BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT, False);

	scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
					    SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, False);

	scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
				     SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True);

	scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
				       SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True);

	scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
				       SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True);

	scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
					SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True);

	scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
				       SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True);

	scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
					 SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True);

	scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
					 SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True);

	scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
					  SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True);

	scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
					    POPUP_INDICATOR_WIDTH, POPUP_INDICATOR_HEIGHT, True);

	scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
					       PULLDOWN_INDICATOR_WIDTH, PULLDOWN_INDICATOR_HEIGHT, True);

	scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK, CHECK_MARK_WIDTH, CHECK_MARK_HEIGHT, True);

	loadPixmaps(scrPtr);

	scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);

	scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);

	{
		XColor bla;
		Pixmap blank;

		blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
		XSetForeground(display, scrPtr->monoGC, 0);
		XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);

		scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank, &bla, &bla, 0, 0);
		XFreePixmap(display, blank);
	}

#ifdef HAVE_XINTERNATOMS
	XInternAtoms(display, atomNames, wlengthof(atomNames), False, atoms);
#else
	for (i = 0; i < wlengthof(atomNames); i++) {
		atoms[i] = XInternAtom(display, atomNames[i], False);
	}
#endif

	i = 0;
	scrPtr->attribsAtom = atoms[i++];

	scrPtr->deleteWindowAtom = atoms[i++];

	scrPtr->protocolsAtom = atoms[i++];

	scrPtr->clipboardAtom = atoms[i++];

	scrPtr->xdndAwareAtom = atoms[i++];
	scrPtr->xdndSelectionAtom = atoms[i++];
	scrPtr->xdndEnterAtom = atoms[i++];
	scrPtr->xdndLeaveAtom = atoms[i++];
	scrPtr->xdndPositionAtom = atoms[i++];
	scrPtr->xdndDropAtom = atoms[i++];
	scrPtr->xdndFinishedAtom = atoms[i++];
	scrPtr->xdndTypeListAtom = atoms[i++];
	scrPtr->xdndActionListAtom = atoms[i++];
	scrPtr->xdndActionDescriptionAtom = atoms[i++];
	scrPtr->xdndStatusAtom = atoms[i++];

	scrPtr->xdndActionCopy = atoms[i++];
	scrPtr->xdndActionMove = atoms[i++];
	scrPtr->xdndActionLink = atoms[i++];
	scrPtr->xdndActionAsk = atoms[i++];
	scrPtr->xdndActionPrivate = atoms[i++];

	scrPtr->wmIconDragOffsetAtom = atoms[i++];

	scrPtr->wmStateAtom = atoms[i++];

	scrPtr->utf8String = atoms[i++];
	scrPtr->netwmName = atoms[i++];
	scrPtr->netwmIconName = atoms[i++];
	scrPtr->netwmIcon = atoms[i++];

	scrPtr->rootView = W_CreateRootView(scrPtr);

	scrPtr->balloon = W_CreateBalloon(scrPtr);

	W_InitApplication(scrPtr);

	return scrPtr;
}
예제 #19
0
파일: Menu.c 프로젝트: awmaker/awmaker
static void createPanel(_Panel * p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	WMColor *black = WMBlackColor(scr);
	WMColor *white = WMWhiteColor(scr);
	WMColor *gray = WMGrayColor(scr);
	WMFont *bold = WMBoldSystemFontOfSize(scr, 12);
	WMFont *font = WMSystemFontOfSize(scr, 12);
	WMLabel *label;
	int width;

	menuDelegate.data = panel;

	panel->boldFont = bold;
	panel->normalFont = font;

	panel->black = black;
	panel->white = white;
	panel->gray = gray;

	{
		Pixmap pix;
		Display *dpy = WMScreenDisplay(scr);
		GC gc;
		WMPixmap *pixm;

		pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True);

		pix = WMGetPixmapXID(pixm);

		XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3);
		XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6);
		/*
		   XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3);
		   XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3);
		   XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6);
		 */

		pix = WMGetPixmapMaskXID(pixm);

		gc = XCreateGC(dpy, pix, 0, NULL);

		XSetForeground(dpy, gc, 0);
		XFillRectangle(dpy, pix, gc, 0, 0, 7, 7);

		XSetForeground(dpy, gc, 1);
		XDrawLine(dpy, pix, gc, 0, 3, 6, 3);
		XDrawLine(dpy, pix, gc, 3, 0, 3, 6);

		panel->markerPix[ExternalInfo] = pixm;
		panel->markerPix[PipeInfo] = pixm;
		panel->markerPix[PLPipeInfo] = pixm;
		panel->markerPix[DirectoryInfo] = pixm;
		panel->markerPix[WSMenuInfo] = pixm;
		panel->markerPix[WWindowListInfo] = pixm;

		XFreeGC(dpy, gc);
	}

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

	panel->typeP = WMCreatePopUpButton(panel->box);
	WMResizeWidget(panel->typeP, 150, 20);
	WMMoveWidget(panel->typeP, 10, 10);

	WMAddPopUpButtonItem(panel->typeP, _("New Items"));
	WMAddPopUpButtonItem(panel->typeP, _("Sample Commands"));
	WMAddPopUpButtonItem(panel->typeP, _("Sample Submenus"));

	WMSetPopUpButtonAction(panel->typeP, changedItemPad, panel);

	WMSetPopUpButtonSelectedItem(panel->typeP, 0);

	{
		WEditMenu *pad;

		pad = makeFactoryMenu(panel->box, 150);
		WMMoveWidget(pad, 10, 40);

		putNewItem(panel, pad, ExecInfo, _("Run Program"));
		putNewItem(panel, pad, CommandInfo, _("Internal Command"));
		putNewSubmenu(pad, _("Submenu"));
		putNewItem(panel, pad, ExternalInfo, _("External Submenu"));
		putNewItem(panel, pad, PipeInfo, _("Generated Submenu"));
		putNewItem(panel, pad, PLPipeInfo, _("Generated PL Menu"));
		putNewItem(panel, pad, DirectoryInfo, _("Directory Contents"));
		putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu"));
		putNewItem(panel, pad, WWindowListInfo, _("Window List Menu"));

		panel->itemPad[0] = pad;
	}

	{
		WEditMenu *pad;
		ItemData *data;
		WMScrollView *sview;

		sview = WMCreateScrollView(panel->box);
		WMResizeWidget(sview, 150, 180);
		WMMoveWidget(sview, 10, 40);
		WMSetScrollViewHasVerticalScroller(sview, True);

		pad = makeFactoryMenu(panel->box, 130);

		WMSetScrollViewContentView(sview, WMWidgetView(pad));

		data = putNewItem(panel, pad, ExecInfo, _("XTerm"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white";

		data = putNewItem(panel, pad, ExecInfo, _("rxvt"));
		data->param.exec.command = "rxvt";

		data = putNewItem(panel, pad, ExecInfo, _("ETerm"));
		data->param.exec.command = "eterm";

		data = putNewItem(panel, pad, ExecInfo, _("Run..."));
		data->param.exec.command = _("%A(Run,Type command to run)");

		data = putNewItem(panel, pad, ExecInfo, _("Firefox"));
		data->param.exec.command = "firefox";

		data = putNewItem(panel, pad, ExecInfo, _("gimp"));
		data->param.exec.command = "gimp";

		data = putNewItem(panel, pad, ExecInfo, _("epic"));
		data->param.exec.command = "xterm -e epic";

		data = putNewItem(panel, pad, ExecInfo, _("ee"));
		data->param.exec.command = "ee";

		data = putNewItem(panel, pad, ExecInfo, _("xv"));
		data->param.exec.command = "xv";

		data = putNewItem(panel, pad, ExecInfo, _("Evince"));
		data->param.exec.command = "evince";

		data = putNewItem(panel, pad, ExecInfo, _("ghostview"));
		data->param.exec.command = "gv";

		data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker"));
		data->param.command.command = 3;

		WMMapWidget(pad);

		panel->itemPad[1] = sview;
	}

	{
		WEditMenu *pad, *smenu;
		ItemData *data;
		WMScrollView *sview;

		sview = WMCreateScrollView(panel->box);
		WMResizeWidget(sview, 150, 180);
		WMMoveWidget(sview, 10, 40);
		WMSetScrollViewHasVerticalScroller(sview, True);

		pad = makeFactoryMenu(panel->box, 130);

		WMSetScrollViewContentView(sview, WMWidgetView(pad));

		data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu"));
		data->param.pipe.command = "/etc/GNUstep/Defaults/menu.hook";

		data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu"));
		data->param.pipe.command = "wmconfig --output wmaker";

		data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva"));
		data->param.pipe.command = "wmconfig --output wmaker";

		data = putNewItem(panel, pad, DirectoryInfo, _("Themes"));
		data->param.directory.command = "setstyle";
		data->param.directory.directory =
		    "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes";
		data->param.directory.stripExt = 1;

		data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)"));
		data->param.directory.command = "wmsetbg -u -s";
		data->param.directory.directory =
		    "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds";
		data->param.directory.stripExt = 1;

		data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)"));
		data->param.directory.command = "wmsetbg -u -t";
		data->param.directory.directory =
		    "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds";
		data->param.directory.stripExt = 1;

		smenu = putNewSubmenu(pad, _("Assorted XTerms"));

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'";

		data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS"));
		data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20";

		WMMapWidget(pad);

		panel->itemPad[2] = sview;
	}

	width = FRAME_WIDTH - 20 - 150 - 10 - 2;

	panel->optionsF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->optionsF, width, FRAME_HEIGHT - 15);
	WMMoveWidget(panel->optionsF, 10 + 150 + 10, 5);

	width -= 20;

	/* command */

	panel->commandF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->commandF, width, 50);
	WMMoveWidget(panel->commandF, 10, 20);
	WMSetFrameTitle(panel->commandF, _("Program to Run"));
	WMSetFrameTitlePosition(panel->commandF, WTPAtTop);

	panel->commandT = WMCreateTextField(panel->commandF);
	WMResizeWidget(panel->commandT, width - 95, 20);
	WMMoveWidget(panel->commandT, 10, 20);

	panel->browseB = WMCreateCommandButton(panel->commandF);
	WMResizeWidget(panel->browseB, 70, 24);
	WMMoveWidget(panel->browseB, width - 80, 18);
	WMSetButtonText(panel->browseB, _("Browse"));
	WMSetButtonAction(panel->browseB, browseForFile, panel);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->commandT);

#if 0
	panel->xtermC = WMCreateSwitchButton(panel->commandF);
	WMResizeWidget(panel->xtermC, width - 20, 20);
	WMMoveWidget(panel->xtermC, 10, 50);
	WMSetButtonText(panel->xtermC, _("Run the program inside a Xterm"));
#endif
	WMMapSubwidgets(panel->commandF);

	/* path */

	panel->pathF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->pathF, width, 150);
	WMMoveWidget(panel->pathF, 10, 40);
	WMSetFrameTitle(panel->pathF, _("Path for Menu"));

	panel->pathT = WMCreateTextField(panel->pathF);
	WMResizeWidget(panel->pathT, width - 20, 20);
	WMMoveWidget(panel->pathT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pathT);

	label = WMCreateLabel(panel->pathF);
	WMResizeWidget(label, width - 20, 80);
	WMMoveWidget(label, 10, 50);
	WMSetLabelText(label, _("Enter the path for a file containing a menu\n"
				"or a list of directories with the programs you\n"
				"want to have listed in the menu. Ex:\n"
				"~/GNUstep/Library/WindowMaker/menu\n" "or\n" "/usr/bin ~/xbin"));

	WMMapSubwidgets(panel->pathF);

	/* pipe */

	panel->pipeF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->pipeF, width, 155);
	WMMoveWidget(panel->pipeF, 10, 30);
	WMSetFrameTitle(panel->pipeF, _("Command"));

	panel->pipeT = WMCreateTextField(panel->pipeF);
	WMResizeWidget(panel->pipeT, width - 20, 20);
	WMMoveWidget(panel->pipeT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pipeT);

	label = WMCreateLabel(panel->pipeF);
	WMResizeWidget(label, width - 20, 40);
	WMMoveWidget(label, 10, 50);
	WMSetLabelText(label, _("Enter a command that outputs a menu\n" "definition to stdout when invoked."));

	panel->pipeCacheB = WMCreateSwitchButton(panel->pipeF);
	WMResizeWidget(panel->pipeCacheB, width - 20, 40);
	WMMoveWidget(panel->pipeCacheB, 10, 110);
	WMSetButtonText(panel->pipeCacheB, _("Cache menu contents after opening for\n" "the first time"));

	WMMapSubwidgets(panel->pipeF);

	/* proplist pipe */

	panel->plpipeF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->plpipeF, width, 155);
	WMMoveWidget(panel->plpipeF, 10, 30);
	WMSetFrameTitle(panel->plpipeF, _("Command"));

	panel->plpipeT = WMCreateTextField(panel->plpipeF);
	WMResizeWidget(panel->plpipeT, width - 20, 20);
	WMMoveWidget(panel->plpipeT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->plpipeT);

	label = WMCreateLabel(panel->plpipeF);
	WMResizeWidget(label, width - 20, 40);
	WMMoveWidget(label, 10, 50);
	WMSetLabelText(label, _("Enter a command that outputs a proplist menu\n" "definition to stdout when invoked."));

	panel->plpipeCacheB = WMCreateSwitchButton(panel->plpipeF);
	WMResizeWidget(panel->plpipeCacheB, width - 20, 40);
	WMMoveWidget(panel->plpipeCacheB, 10, 110);
	WMSetButtonText(panel->plpipeCacheB, _("Cache menu contents after opening for\n" "the first time"));

	WMMapSubwidgets(panel->plpipeF);

	/* directory menu */

	panel->dcommandF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->dcommandF, width, 90);
	WMMoveWidget(panel->dcommandF, 10, 25);
	WMSetFrameTitle(panel->dcommandF, _("Command to Open Files"));

	panel->dcommandT = WMCreateTextField(panel->dcommandF);
	WMResizeWidget(panel->dcommandT, width - 20, 20);
	WMMoveWidget(panel->dcommandT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dcommandT);

	label = WMCreateLabel(panel->dcommandF);
	WMResizeWidget(label, width - 20, 45);
	WMMoveWidget(label, 10, 40);
	WMSetLabelText(label, _("Enter the command you want to use to open the\n"
				"files in the directories listed below."));

	WMMapSubwidgets(panel->dcommandF);

	panel->dpathF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->dpathF, width, 80);
	WMMoveWidget(panel->dpathF, 10, 125);
	WMSetFrameTitle(panel->dpathF, _("Directories with Files"));

	panel->dpathT = WMCreateTextField(panel->dpathF);
	WMResizeWidget(panel->dpathT, width - 20, 20);
	WMMoveWidget(panel->dpathT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dpathT);

	panel->dstripB = WMCreateSwitchButton(panel->dpathF);
	WMResizeWidget(panel->dstripB, width - 20, 20);
	WMMoveWidget(panel->dstripB, 10, 50);
	WMSetButtonText(panel->dstripB, _("Strip extensions from file names"));

	WMSetButtonAction(panel->dstripB, buttonClicked, panel);

	WMMapSubwidgets(panel->dpathF);

	/* shortcut */

	panel->shortF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->shortF, width, 50);
	WMMoveWidget(panel->shortF, 10, 160);
	WMSetFrameTitle(panel->shortF, _("Keyboard Shortcut"));

	panel->shortT = WMCreateTextField(panel->shortF);
	WMResizeWidget(panel->shortT, width - 20 - 150, 20);
	WMMoveWidget(panel->shortT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->shortT);

	panel->sgrabB = WMCreateCommandButton(panel->shortF);
	WMResizeWidget(panel->sgrabB, 70, 24);
	WMMoveWidget(panel->sgrabB, width - 80, 18);
	WMSetButtonText(panel->sgrabB, _("Capture"));
	WMSetButtonAction(panel->sgrabB, sgrabClicked, panel);

	panel->sclearB = WMCreateCommandButton(panel->shortF);
	WMResizeWidget(panel->sclearB, 70, 24);
	WMMoveWidget(panel->sclearB, width - 155, 18);
	WMSetButtonText(panel->sclearB, _("Clear"));
	WMSetButtonAction(panel->sclearB, sgrabClicked, panel);

	WMMapSubwidgets(panel->shortF);

	/* internal command */

	panel->icommandL = WMCreateList(panel->optionsF);
	WMResizeWidget(panel->icommandL, width, 80);
	WMMoveWidget(panel->icommandL, 10, 20);

	WMSetListAction(panel->icommandL, icommandLClicked, panel);

	WMAddNotificationObserver(dataChanged, panel, WMListSelectionDidChangeNotification, panel->icommandL);

	WMInsertListItem(panel->icommandL, 0, _("Arrange Icons"));
	WMInsertListItem(panel->icommandL, 1, _("Hide All Windows Except For The Focused One"));
	WMInsertListItem(panel->icommandL, 2, _("Show All Windows"));

	WMInsertListItem(panel->icommandL, 3, _("Exit Window Maker"));
	WMInsertListItem(panel->icommandL, 4, _("Exit X Session"));
	WMInsertListItem(panel->icommandL, 5, _("Restart Window Maker"));
	WMInsertListItem(panel->icommandL, 6, _("Start Another Window Manager   : ("));

	WMInsertListItem(panel->icommandL, 7, _("Save Current Session"));
	WMInsertListItem(panel->icommandL, 8, _("Clear Saved Session"));
	WMInsertListItem(panel->icommandL, 9, _("Refresh Screen"));
	WMInsertListItem(panel->icommandL, 10, _("Open Info Panel"));
	WMInsertListItem(panel->icommandL, 11, _("Open Copyright Panel"));

	panel->paramF = WMCreateFrame(panel->optionsF);
	WMResizeWidget(panel->paramF, width, 50);
	WMMoveWidget(panel->paramF, 10, 105);
	WMSetFrameTitle(panel->paramF, _("Window Manager to Start"));

	panel->paramT = WMCreateTextField(panel->paramF);
	WMResizeWidget(panel->paramT, width - 20, 20);
	WMMoveWidget(panel->paramT, 10, 20);

	WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->paramT);

	WMMapSubwidgets(panel->paramF);

	panel->quickB = WMCreateSwitchButton(panel->optionsF);
	WMResizeWidget(panel->quickB, width, 20);
	WMMoveWidget(panel->quickB, 10, 120);
	WMSetButtonText(panel->quickB, _("Do not confirm action."));
	WMSetButtonAction(panel->quickB, buttonClicked, panel);

	label = WMCreateLabel(panel->optionsF);
	WMResizeWidget(label, width + 5, FRAME_HEIGHT - 50);
	WMMoveWidget(label, 7, 20);
	WMSetLabelText(label,
		       _("Instructions:\n\n"
			 " - drag items from the left to the menu to add new items\n"
			 " - drag items out of the menu to remove items\n"
			 " - drag items in menu to change their position\n"
			 " - drag items with Control pressed to copy them\n"
			 " - double click in a menu item to change the label\n"
			 " - click on a menu item to change related information"));
	WMMapWidget(label);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);
	WMMapWidget(panel->box);

	{
		int i;
		for (i = 0; i < wlengthof(panel->itemPad); i++)
			WMUnmapWidget(panel->itemPad[i]);
	}
	changedItemPad(panel->typeP, panel);

	panel->sections[NoInfo][0] = label;

	panel->sections[ExecInfo][0] = panel->commandF;
	panel->sections[ExecInfo][1] = panel->shortF;

	panel->sections[CommandInfo][0] = panel->icommandL;
	panel->sections[CommandInfo][1] = panel->shortF;

	panel->sections[ExternalInfo][0] = panel->pathF;

	panel->sections[PipeInfo][0] = panel->pipeF;

	panel->sections[PLPipeInfo][0] = panel->plpipeF;

	panel->sections[DirectoryInfo][0] = panel->dpathF;
	panel->sections[DirectoryInfo][1] = panel->dcommandF;

	panel->currentType = NoInfo;

	showData(panel);

	{
		WMPoint pos;

		pos = WMGetViewScreenPosition(WMWidgetView(panel->box));

		if (pos.x < 200) {
			pos.x += FRAME_WIDTH + 20;
		} else {
			pos.x = 10;
		}

		pos.y = WMAX(pos.y - 100, 0);

		if (panel->menu)
			WEditMenuShowAt(panel->menu, pos.x, pos.y);
	}
}
예제 #20
0
파일: startup.c 프로젝트: jafd/wmaker
/*
 *----------------------------------------------------------
 * StartUp--
 * 	starts the window manager and setup global data.
 * Called from main() at startup.
 *
 * Side effects:
 * global data declared in main.c is initialized
 *----------------------------------------------------------
 */
void StartUp(Bool defaultScreenOnly)
{
	struct sigaction sig_action;
	int i, j, max;
	char **formats;
	Atom atom[wlengthof(atomNames)];

	/*
	 * Ignore CapsLock in modifiers
	 */
	w_global.shortcut.modifiers_mask = 0xff & ~LockMask;

	getOffendingModifiers();
	/*
	 * Ignore NumLock and ScrollLock too
	 */
	w_global.shortcut.modifiers_mask &= ~(_NumLockMask | _ScrollLockMask);

	memset(&wKeyBindings, 0, sizeof(wKeyBindings));

	w_global.context.client_win = XUniqueContext();
	w_global.context.app_win = XUniqueContext();
	w_global.context.stack = XUniqueContext();

	/*    _XA_VERSION = XInternAtom(dpy, "VERSION", False); */

#ifdef HAVE_XINTERNATOMS
	XInternAtoms(dpy, atomNames, wlengthof(atomNames), False, atom);
#else

	{
		int i;
		for (i = 0; i < wlengthof(atomNames); i++)
			atom[i] = XInternAtom(dpy, atomNames[i], False);
	}
#endif

	w_global.atom.wm.state = atom[0];
	w_global.atom.wm.change_state = atom[1];
	w_global.atom.wm.protocols = atom[2];
	w_global.atom.wm.take_focus = atom[3];
	w_global.atom.wm.delete_window = atom[4];
	w_global.atom.wm.save_yourself = atom[5];
	w_global.atom.wm.client_leader = atom[6];
	w_global.atom.wm.colormap_windows = atom[7];
	w_global.atom.wm.colormap_notify = atom[8];

	w_global.atom.wmaker.menu = atom[9];
	w_global.atom.wmaker.state = atom[10];
	w_global.atom.wmaker.wm_protocols = atom[11];
	w_global.atom.wmaker.wm_function = atom[12];
	w_global.atom.wmaker.noticeboard = atom[13];
	w_global.atom.wmaker.command = atom[14];
	w_global.atom.wmaker.icon_size = atom[15];
	w_global.atom.wmaker.icon_tile = atom[16];

	w_global.atom.gnustep.wm_attr = atom[17];
	w_global.atom.gnustep.wm_miniaturize_window = atom[18];
	w_global.atom.gnustep.titlebar_state = atom[19];

	w_global.atom.wm.ignore_focus_events = atom[20];

#ifdef XDND
	wXDNDInitializeAtoms();
#endif

	/* cursors */
	wPreferences.cursor[WCUR_NORMAL] = None;	/* inherit from root */
	wPreferences.cursor[WCUR_ROOT] = XCreateFontCursor(dpy, XC_left_ptr);
	wPreferences.cursor[WCUR_ARROW] = XCreateFontCursor(dpy, XC_top_left_arrow);
	wPreferences.cursor[WCUR_MOVE] = XCreateFontCursor(dpy, XC_fleur);
	wPreferences.cursor[WCUR_RESIZE] = XCreateFontCursor(dpy, XC_sizing);
	wPreferences.cursor[WCUR_TOPLEFTRESIZE] = XCreateFontCursor(dpy, XC_top_left_corner);
	wPreferences.cursor[WCUR_TOPRIGHTRESIZE] = XCreateFontCursor(dpy, XC_top_right_corner);
	wPreferences.cursor[WCUR_BOTTOMLEFTRESIZE] = XCreateFontCursor(dpy, XC_bottom_left_corner);
	wPreferences.cursor[WCUR_BOTTOMRIGHTRESIZE] = XCreateFontCursor(dpy, XC_bottom_right_corner);
	wPreferences.cursor[WCUR_VERTICALRESIZE] = XCreateFontCursor(dpy, XC_sb_v_double_arrow);
	wPreferences.cursor[WCUR_HORIZONRESIZE] = XCreateFontCursor(dpy, XC_sb_h_double_arrow);
	wPreferences.cursor[WCUR_WAIT] = XCreateFontCursor(dpy, XC_watch);
	wPreferences.cursor[WCUR_QUESTION] = XCreateFontCursor(dpy, XC_question_arrow);
	wPreferences.cursor[WCUR_TEXT] = XCreateFontCursor(dpy, XC_xterm);	/* odd name??? */
	wPreferences.cursor[WCUR_SELECT] = XCreateFontCursor(dpy, XC_cross);

	Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1);
	GC gc = XCreateGC(dpy, cur, 0, NULL);
	XColor black;
	memset(&black, 0, sizeof(XColor));
	XSetForeground(dpy, gc, 0);
	XFillRectangle(dpy, cur, gc, 0, 0, 16, 16);
	XFreeGC(dpy, gc);
	wPreferences.cursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0);
	XFreePixmap(dpy, cur);

	/* emergency exit... */
	sig_action.sa_handler = handleSig;
	sigemptyset(&sig_action.sa_mask);

	sig_action.sa_flags = SA_RESTART;
	sigaction(SIGQUIT, &sig_action, NULL);
	/* instead of catching these, we let the default handler abort the
	 * program. The new monitor process will take appropriate action
	 * when it detects the crash.
	 sigaction(SIGSEGV, &sig_action, NULL);
	 sigaction(SIGBUS, &sig_action, NULL);
	 sigaction(SIGFPE, &sig_action, NULL);
	 sigaction(SIGABRT, &sig_action, NULL);
	 */

	sig_action.sa_handler = handleExitSig;

	/* Here we set SA_RESTART for safety, because SIGUSR1 may not be handled
	 * immediately. -Dan */
	sig_action.sa_flags = SA_RESTART;
	sigaction(SIGTERM, &sig_action, NULL);
	sigaction(SIGINT, &sig_action, NULL);
	sigaction(SIGHUP, &sig_action, NULL);
	sigaction(SIGUSR1, &sig_action, NULL);
	sigaction(SIGUSR2, &sig_action, NULL);

	/* ignore dead pipe */
	/* Because POSIX mandates that only signal with handlers are reset
	 * accross an exec*(), we do not want to propagate ignoring SIGPIPEs
	 * to children. Hence the dummy handler.
	 * Philippe Troin <*****@*****.**>
	 */
	sig_action.sa_handler = &dummyHandler;
	sig_action.sa_flags = SA_RESTART;
	sigaction(SIGPIPE, &sig_action, NULL);

	/* handle dead children */
	sig_action.sa_handler = buryChild;
	sig_action.sa_flags = SA_NOCLDSTOP | SA_RESTART;
	sigaction(SIGCHLD, &sig_action, NULL);

	/* Now we unblock all signals, that may have been blocked by the parent
	 * who exec()-ed us. This can happen for example if Window Maker crashes
	 * and restarts itself or another window manager from the signal handler.
	 * In this case, the new proccess inherits the blocked signal mask and
	 * will no longer react to that signal, until unblocked.
	 * This is because the signal handler of the proccess who crashed (parent)
	 * didn't return, and the signal remained blocked. -Dan
	 */
	sigfillset(&sig_action.sa_mask);
	sigprocmask(SIG_UNBLOCK, &sig_action.sa_mask, NULL);

	/* handle X shutdowns a such */
	XSetIOErrorHandler(handleXIO);

	/* set hook for out event dispatcher in WINGs event dispatcher */
	WMHookEventHandler(DispatchEvent);

	/* initialize defaults stuff */
	w_global.domain.wmaker = wDefaultsInitDomain("WindowMaker", True);
	if (!w_global.domain.wmaker->dictionary)
		wwarning(_("could not read domain \"%s\" from defaults database"), "WindowMaker");

	/* read defaults that don't change until a restart and are
	 * screen independent */
	wReadStaticDefaults(w_global.domain.wmaker ? w_global.domain.wmaker->dictionary : NULL);

	/* check sanity of some values */
	if (wPreferences.icon_size < 16) {
		wwarning(_("icon size is configured to %i, but it's too small. Using 16 instead"),
			 wPreferences.icon_size);
		wPreferences.icon_size = 16;
	}

	/* init other domains */
	w_global.domain.root_menu = wDefaultsInitDomain("WMRootMenu", False);
	if (!w_global.domain.root_menu->dictionary)
		wwarning(_("could not read domain \"%s\" from defaults database"), "WMRootMenu");

	wDefaultsMergeGlobalMenus(w_global.domain.root_menu);

	w_global.domain.window_attr = wDefaultsInitDomain("WMWindowAttributes", True);
	if (!w_global.domain.window_attr->dictionary)
		wwarning(_("could not read domain \"%s\" from defaults database"), "WMWindowAttributes");

	XSetErrorHandler((XErrorHandler) catchXError);

#ifdef USE_XSHAPE
	/* ignore j */
	w_global.xext.shape.supported = XShapeQueryExtension(dpy, &w_global.xext.shape.event_base, &j);
#endif

#ifdef USE_XRANDR
	w_global.xext.randr.supported = XRRQueryExtension(dpy, &w_global.xext.randr.event_base, &j);
#endif

#ifdef KEEP_XKB_LOCK_STATUS
	w_global.xext.xkb.supported = XkbQueryExtension(dpy, NULL, &w_global.xext.xkb.event_base, NULL, NULL, NULL);
	if (wPreferences.modelock && !w_global.xext.xkb.supported) {
		wwarning(_("XKB is not supported. KbdModeLock is automatically disabled."));
		wPreferences.modelock = 0;
	}
#endif

	if (defaultScreenOnly)
		max = 1;
	else
		max = ScreenCount(dpy);

	wScreen = wmalloc(sizeof(WScreen *) * max);

	w_global.screen_count = 0;

	/* Check if TIFF images are supported */
	formats = RSupportedFileFormats();
	if (formats) {
		for (i = 0; formats[i] != NULL; i++) {
			if (strcmp(formats[i], "TIFF") == 0) {
				wPreferences.supports_tiff = 1;
				break;
			}
		}
	}

	/* manage the screens */
	for (j = 0; j < max; j++) {
		if (defaultScreenOnly || max == 1) {
			wScreen[w_global.screen_count] = wScreenInit(DefaultScreen(dpy));
			if (!wScreen[w_global.screen_count]) {
				wfatal(_("it seems that there is already a window manager running"));
				Exit(1);
			}
		} else {
			wScreen[w_global.screen_count] = wScreenInit(j);
			if (!wScreen[w_global.screen_count]) {
				wwarning(_("could not manage screen %i"), j);
				continue;
			}
		}
		w_global.screen_count++;
	}

	InitializeSwitchMenu();

	/* initialize/restore state for the screens */
	for (j = 0; j < w_global.screen_count; j++) {
		int lastDesktop;

		lastDesktop = wNETWMGetCurrentDesktopFromHint(wScreen[j]);

		wScreenRestoreState(wScreen[j]);

		/* manage all windows that were already here before us */
		if (!wPreferences.flags.nodock && wScreen[j]->dock)
			wScreen[j]->last_dock = wScreen[j]->dock;

		manageAllWindows(wScreen[j], wPreferences.flags.restarting == 2);

		/* restore saved menus */
		wMenuRestoreState(wScreen[j]);

		/* If we're not restarting, restore session */
		if (wPreferences.flags.restarting == 0 && !wPreferences.flags.norestore)
			wSessionRestoreState(wScreen[j]);

		if (!wPreferences.flags.noautolaunch) {
			/* auto-launch apps */
			if (!wPreferences.flags.nodock && wScreen[j]->dock) {
				wScreen[j]->last_dock = wScreen[j]->dock;
				wDockDoAutoLaunch(wScreen[j]->dock, 0);
			}
			/* auto-launch apps in clip */
			if (!wPreferences.flags.noclip) {
				int i;
				for (i = 0; i < w_global.workspace.count; i++) {
					if (w_global.workspace.array[i]->clip) {
						wScreen[j]->last_dock = w_global.workspace.array[i]->clip;
						wDockDoAutoLaunch(w_global.workspace.array[i]->clip, i);
					}
				}
			}
			/* auto-launch apps in drawers */
			if (!wPreferences.flags.nodrawer) {
				WDrawerChain *dc;
				for (dc = wScreen[j]->drawers; dc; dc = dc->next) {
					wScreen[j]->last_dock = dc->adrawer;
					wDockDoAutoLaunch(dc->adrawer, 0);
				}
			}
		}

		/* go to workspace where we were before restart */
		if (lastDesktop >= 0)
			wWorkspaceForceChange(wScreen[j], lastDesktop);
		else
			wSessionRestoreLastWorkspace(wScreen[j]);
	}

	if (w_global.screen_count == 0) {
		wfatal(_("could not manage any screen"));
		Exit(1);
	}

#ifndef HAVE_INOTIFY
	/* setup defaults file polling */
	if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates)
		WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL);
#endif

}