Exemple #1
0
void W_ResizeView(W_View * view, unsigned int width, unsigned int height)
{
	/*int shrinked; */

	if (view->delegate && view->delegate->willResize) {
		(*view->delegate->willResize) (view->delegate, view, &width, &height);
	}

	assert(width > 0);
	assert(height > 0);

	if (view->size.width == width && view->size.height == height)
		return;

	/*shrinked = width < view->size.width || height < view->size.height; */

	if (view->flags.realized) {
		XResizeWindow(view->screen->display, view->window, width, height);
	}
	view->size.width = width;
	view->size.height = height;

	if (view->delegate && view->delegate->didResize) {
		(*view->delegate->didResize) (view->delegate, view);
	}

	/* // TODO. replace in WINGs code, with the didResize delegate */
	if (view->flags.notifySizeChanged)
		WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL);
}
Exemple #2
0
static void autoScroll(void *clientData)
{
	Scroller *sPtr = (Scroller *) clientData;

	if (sPtr->action) {
		(*sPtr->action) (sPtr, sPtr->clientData);
		WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
	}
	sPtr->timerID = WMAddTimerHandler(AUTOSCROLL_DELAY, autoScroll, clientData);
}
Exemple #3
0
int wWorkspaceNew(WScreen *scr)
{
	WWorkspace *wspace, **list;
	int i;

	if (w_global.workspace.count < MAX_WORKSPACES) {
		w_global.workspace.count++;

		wspace = wmalloc(sizeof(WWorkspace));
		wspace->name = NULL;
		wspace->clip = NULL;

		if (!wspace->name) {
			static const char *new_name = NULL;
			static size_t name_length;

			if (new_name == NULL) {
				new_name = _("Workspace %i");
				name_length = strlen(new_name) + 8;
			}
			wspace->name = wmalloc(name_length);
			snprintf(wspace->name, name_length, new_name, w_global.workspace.count);
		}

		if (!wPreferences.flags.noclip)
			wspace->clip = wDockCreate(scr, WM_CLIP, NULL);

		list = wmalloc(sizeof(WWorkspace *) * w_global.workspace.count);

		for (i = 0; i < w_global.workspace.count - 1; i++)
			list[i] = w_global.workspace.array[i];

		list[i] = wspace;
		if (w_global.workspace.array)
			wfree(w_global.workspace.array);

		w_global.workspace.array = list;

		wWorkspaceMenuUpdate(w_global.workspace.menu);
		wWorkspaceMenuUpdate(w_global.clip.ws_menu);
		wNETWMUpdateDesktop(scr);
		WMPostNotificationName(WMNWorkspaceCreated, scr, (void *)(uintptr_t) (w_global.workspace.count - 1));
		XFlush(dpy);

		return w_global.workspace.count - 1;
	}

	return -1;
}
Exemple #4
0
void wWorkspaceRename(WScreen *scr, int workspace, const char *name)
{
	char buf[MAX_WORKSPACENAME_WIDTH + 1];
	char *tmp;

	if (workspace >= w_global.workspace.count)
		return;

	/* trim white spaces */
	tmp = wtrimspace(name);

	if (strlen(tmp) == 0) {
		snprintf(buf, sizeof(buf), _("Workspace %i"), workspace + 1);
	} else {
		strncpy(buf, tmp, MAX_WORKSPACENAME_WIDTH);
	}
	buf[MAX_WORKSPACENAME_WIDTH] = 0;
	wfree(tmp);

	/* update workspace */
	wfree(w_global.workspace.array[workspace]->name);
	w_global.workspace.array[workspace]->name = wstrdup(buf);

	if (w_global.clip.ws_menu) {
		if (strcmp(w_global.clip.ws_menu->entries[workspace + MC_WORKSPACE1]->text, buf) != 0) {
			wfree(w_global.clip.ws_menu->entries[workspace + MC_WORKSPACE1]->text);
			w_global.clip.ws_menu->entries[workspace + MC_WORKSPACE1]->text = wstrdup(buf);
			wMenuRealize(w_global.clip.ws_menu);
		}
	}
	if (w_global.workspace.menu) {
		if (strcmp(w_global.workspace.menu->entries[workspace + MC_WORKSPACE1]->text, buf) != 0) {
			wfree(w_global.workspace.menu->entries[workspace + MC_WORKSPACE1]->text);
			w_global.workspace.menu->entries[workspace + MC_WORKSPACE1]->text = wstrdup(buf);
			wMenuRealize(w_global.workspace.menu);
		}
	}

	if (w_global.clip.icon)
		wClipIconPaint();

	WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) workspace);
}
Exemple #5
0
void W_RealizeView(W_View * view)
{
	Window parentWID;
	Display *dpy = view->screen->display;
	W_View *ptr;

	assert(view->size.width > 0);
	assert(view->size.height > 0);

	if (view->parent && !view->parent->flags.realized) {
		wwarning("trying to realize widget of unrealized parent");
		return;
	}

	if (!view->flags.realized) {
		parentWID = view->parent->window;
		view->window = XCreateWindow(dpy, parentWID, view->pos.x, view->pos.y,
					     view->size.width, view->size.height, 0,
					     view->screen->depth, InputOutput,
					     view->screen->visual, view->attribFlags, &view->attribs);

		XSaveContext(dpy, view->window, ViewContext, (XPointer) view);

		view->flags.realized = 1;

		if (view->flags.mapWhenRealized) {
			W_MapView(view);
			view->flags.mapWhenRealized = 0;
		}

		WMPostNotificationName(WMViewRealizedNotification, view, NULL);
	}

	/* realize children */
	ptr = view->childrenList;
	while (ptr != NULL) {
		W_RealizeView(ptr);

		ptr = ptr->nextSister;
	}
}
Exemple #6
0
static void handleMotion(Scroller * sPtr, int mouseX, int mouseY)
{
	if (sPtr->flags.draggingKnob) {
		float newFloatValue;
		int point;

		if (sPtr->flags.horizontal) {
			point = mouseX;
		} else {
			point = mouseY;
		}

#ifndef STRICT_NEXT_BEHAVIOUR
		point -= sPtr->dragPoint;
#endif

		newFloatValue = floatValueForPoint(sPtr, point);
		WMSetScrollerParameters(sPtr, newFloatValue, sPtr->knobProportion);
		if (sPtr->action) {
			(*sPtr->action) (sPtr, sPtr->clientData);
			WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
		}
	} else {
		int part;

		part = locatePointInScroller(sPtr, mouseX, mouseY, False);

		sPtr->flags.hitPart = part;

		if (part == WSIncrementLine && sPtr->flags.decrDown) {
			sPtr->flags.decrDown = 0;
			sPtr->flags.incrDown = 1;
		} else if (part == WSDecrementLine && sPtr->flags.incrDown) {
			sPtr->flags.incrDown = 0;
			sPtr->flags.decrDown = 1;
		} else if (part != WSIncrementLine && part != WSDecrementLine) {
			sPtr->flags.incrDown = 0;
			sPtr->flags.decrDown = 0;
		}
	}
}
Exemple #7
0
void wWorkspaceRestoreState(WScreen *scr)
{
	WMPropList *parr, *pstr, *wks_state, *clip_state;
	int i, j;

	make_keys();

	if (w_global.session_state == NULL)
		return;

	parr = WMGetFromPLDictionary(w_global.session_state, dWorkspaces);

	if (!parr)
		return;

	for (i = 0; i < WMIN(WMGetPropListItemCount(parr), MAX_WORKSPACES); i++) {
		wks_state = WMGetFromPLArray(parr, i);
		if (WMIsPLDictionary(wks_state))
			pstr = WMGetFromPLDictionary(wks_state, dName);
		else
			pstr = wks_state;

		if (i >= w_global.workspace.count)
			wWorkspaceNew(scr);

		if (w_global.workspace.menu) {
			wfree(w_global.workspace.menu->entries[i + MC_WORKSPACE1]->text);
			w_global.workspace.menu->entries[i + MC_WORKSPACE1]->text = wstrdup(WMGetFromPLString(pstr));
			w_global.workspace.menu->flags.realized = 0;
		}

		wfree(w_global.workspace.array[i]->name);
		w_global.workspace.array[i]->name = wstrdup(WMGetFromPLString(pstr));
		if (!wPreferences.flags.noclip) {
			int added_omnipresent_icons = 0;

			clip_state = WMGetFromPLDictionary(wks_state, dClip);
			if (w_global.workspace.array[i]->clip)
				wDockDestroy(w_global.workspace.array[i]->clip);

			w_global.workspace.array[i]->clip = wDockRestoreState(scr, clip_state, WM_CLIP);
			if (i > 0)
				wDockHideIcons(w_global.workspace.array[i]->clip);

			/* We set the global icons here, because scr->workspaces[i]->clip
			 * was not valid in wDockRestoreState().
			 * There we only set icon->omnipresent to know which icons we
			 * need to set here.
			 */
			for (j = 0; j < w_global.workspace.array[i]->clip->max_icons; j++) {
				WAppIcon *aicon = w_global.workspace.array[i]->clip->icon_array[j];
				int k;

				if (!aicon || !aicon->omnipresent)
					continue;
				aicon->omnipresent = 0;
				if (wClipMakeIconOmnipresent(aicon, True) != WO_SUCCESS)
					continue;
				if (i == 0)
					continue;

				/* Move this appicon from workspace i to workspace 0 */
				w_global.workspace.array[i]->clip->icon_array[j] = NULL;
				w_global.workspace.array[i]->clip->icon_count--;

				added_omnipresent_icons++;
				/* If there are too many omnipresent appicons, we are in trouble */
				assert(w_global.workspace.array[0]->clip->icon_count + added_omnipresent_icons
				       <= w_global.workspace.array[0]->clip->max_icons);
				/* Find first free spot on workspace 0 */
				for (k = 0; k < w_global.workspace.array[0]->clip->max_icons; k++)
					if (w_global.workspace.array[0]->clip->icon_array[k] == NULL)
						break;
				w_global.workspace.array[0]->clip->icon_array[k] = aicon;
				aicon->dock = w_global.workspace.array[0]->clip;
			}
			w_global.workspace.array[0]->clip->icon_count += added_omnipresent_icons;
		}

		WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) i);
	}
}
Exemple #8
0
void wWorkspaceForceChange(WScreen * scr, int workspace)
{
	WWindow *tmp, *foc = NULL, *foc2 = NULL;
	WWindow **toUnmap;
	int toUnmapSize, toUnmapCount;

	if (workspace >= MAX_WORKSPACES || workspace < 0)
		return;

	SendHelperMessage(scr, 'C', workspace + 1, NULL);

	if (workspace > w_global.workspace.count - 1)
		wWorkspaceMake(scr, workspace - w_global.workspace.count + 1);

	wClipUpdateForWorkspaceChange(scr, workspace);

	w_global.workspace.last_used = w_global.workspace.current;
	w_global.workspace.current = workspace;

	wWorkspaceMenuUpdate(w_global.workspace.menu);

	wWorkspaceMenuUpdate(w_global.clip.ws_menu);

	toUnmapSize = 16;
	toUnmapCount = 0;
	toUnmap = wmalloc(toUnmapSize * sizeof(WWindow *));

	if ((tmp = scr->focused_window) != NULL) {
		if ((IS_OMNIPRESENT(tmp) && (tmp->flags.mapped || tmp->flags.shaded) &&
		     !WFLAGP(tmp, no_focusable)) || tmp->flags.changing_workspace) {
			foc = tmp;
		}

		/* foc2 = tmp; will fix annoyance with gnome panel
		 * but will create annoyance for every other application
		 */
		while (tmp) {
			if (tmp->frame->workspace != workspace && !tmp->flags.selected) {
				/* unmap windows not on this workspace */
				if ((tmp->flags.mapped || tmp->flags.shaded) &&
				    !IS_OMNIPRESENT(tmp) && !tmp->flags.changing_workspace) {
					if (toUnmapCount == toUnmapSize)
					{
						toUnmapSize *= 2;
						toUnmap = wrealloc(toUnmap, toUnmapSize * sizeof(WWindow *));
					}
					toUnmap[toUnmapCount++] = tmp;
				}
				/* also unmap miniwindows not on this workspace */
				if (!wPreferences.sticky_icons && tmp->flags.miniaturized &&
				    tmp->icon && !IS_OMNIPRESENT(tmp)) {
					XUnmapWindow(dpy, tmp->icon->core->window);
					tmp->icon->mapped = 0;
				}
				/* update current workspace of omnipresent windows */
				if (IS_OMNIPRESENT(tmp)) {
					WApplication *wapp = wApplicationOf(tmp->main_window);

					tmp->frame->workspace = workspace;

					if (wapp) {
						wapp->last_workspace = workspace;
					}
					if (!foc2 && (tmp->flags.mapped || tmp->flags.shaded)) {
						foc2 = tmp;
					}
				}
			} else {
				/* change selected windows' workspace */
				if (tmp->flags.selected) {
					wWindowChangeWorkspace(tmp, workspace);
					if (!tmp->flags.miniaturized && !foc) {
						foc = tmp;
					}
				} else {
					if (!tmp->flags.hidden) {
						if (!(tmp->flags.mapped || tmp->flags.miniaturized)) {
							/* remap windows that are on this workspace */
							wWindowMap(tmp);
							if (!foc && !WFLAGP(tmp, no_focusable)) {
								foc = tmp;
							}
						}
						/* Also map miniwindow if not omnipresent */
						if (!wPreferences.sticky_icons &&
						    tmp->flags.miniaturized && !IS_OMNIPRESENT(tmp) && tmp->icon) {
							tmp->icon->mapped = 1;
							XMapWindow(dpy, tmp->icon->core->window);
						}
					}
				}
			}
			tmp = tmp->prev;
		}

		while (toUnmapCount > 0)
		{
			wWindowUnmap(toUnmap[--toUnmapCount]);
		}
		wfree(toUnmap);

		/* Gobble up events unleashed by our mapping & unmapping.
		 * These may trigger various grab-initiated focus &
		 * crossing events. However, we don't care about them,
		 * and ignore their focus implications altogether to avoid
		 * flicker.
		 */
		scr->flags.ignore_focus_events = 1;
		ProcessPendingEvents();
		scr->flags.ignore_focus_events = 0;

		if (!foc)
			foc = foc2;

		if (scr->focused_window->flags.mapped && !foc) {
			foc = scr->focused_window;
		}
		if (wPreferences.focus_mode == WKF_CLICK) {
			wSetFocusTo(scr, foc);
		} else {
			unsigned int mask;
			int foo;
			Window bar, win;
			WWindow *tmp;

			tmp = NULL;
			if (XQueryPointer(dpy, scr->root_win, &bar, &win, &foo, &foo, &foo, &foo, &mask)) {
				tmp = wWindowFor(win);
			}

			/* If there's a window under the pointer, focus it.
			 * (we ate all other focus events above, so it's
			 * certainly not focused). Otherwise focus last
			 * focused, or the root (depending on sloppiness)
			 */
			if (!tmp && wPreferences.focus_mode == WKF_SLOPPY) {
				wSetFocusTo(scr, foc);
			} else {
				wSetFocusTo(scr, tmp);
			}
		}
	}

	/* We need to always arrange icons when changing workspace, even if
	 * no autoarrange icons, because else the icons in different workspaces
	 * can be superposed.
	 * This can be avoided if appicons are also workspace specific.
	 */
	if (!wPreferences.sticky_icons)
		wArrangeIcons(scr, False);

	if (scr->dock)
		wAppIconPaint(scr->dock->icon_array[0]);

	if (!wPreferences.flags.noclip && (w_global.workspace.array[workspace]->clip->auto_collapse ||
					   w_global.workspace.array[workspace]->clip->auto_raise_lower)) {
		/* to handle enter notify. This will also */
		XUnmapWindow(dpy, w_global.clip.icon->icon->core->window);
		XMapWindow(dpy, w_global.clip.icon->icon->core->window);
	}
	else if (w_global.clip.icon != NULL) {
		wClipIconPaint();
	}
	wScreenUpdateUsableArea(scr);
	wNETWMUpdateDesktop(scr);
	showWorkspaceName(scr, workspace);

	WMPostNotificationName(WMNWorkspaceChanged, scr, (void *)(uintptr_t) workspace);

	/*   XSync(dpy, False); */
}
Exemple #9
0
Bool wWorkspaceDelete(WScreen * scr, int workspace)
{
	WWindow *tmp;
	WWorkspace **list;
	int i, j;

	if (workspace <= 0)
		return False;

	/* verify if workspace is in use by some window */
	tmp = scr->focused_window;
	while (tmp) {
		if (!IS_OMNIPRESENT(tmp) && tmp->frame->workspace == workspace)
			return False;
		tmp = tmp->prev;
	}

	if (!wPreferences.flags.noclip) {
		wDockDestroy(w_global.workspace.array[workspace]->clip);
		w_global.workspace.array[workspace]->clip = NULL;
	}

	list = wmalloc(sizeof(WWorkspace *) * (w_global.workspace.count - 1));
	j = 0;
	for (i = 0; i < w_global.workspace.count; i++) {
		if (i != workspace) {
			list[j++] = w_global.workspace.array[i];
		} else {
			if (w_global.workspace.array[i]->name)
				wfree(w_global.workspace.array[i]->name);
			wfree(w_global.workspace.array[i]);
		}
	}
	wfree(w_global.workspace.array);
	w_global.workspace.array = list;

	w_global.workspace.count--;

	/* update menu */
	wWorkspaceMenuUpdate(w_global.workspace.menu);
	/* clip workspace menu */
	wWorkspaceMenuUpdate(w_global.clip.ws_menu);

	/* update also window menu */
	if (w_global.workspace.submenu) {
		WMenu *menu = w_global.workspace.submenu;

		i = menu->entry_no;
		while (i > w_global.workspace.count)
			wMenuRemoveItem(menu, --i);
		wMenuRealize(menu);
	}
	/* and clip menu */
	if (w_global.clip.submenu) {
		WMenu *menu = w_global.clip.submenu;

		i = menu->entry_no;
		while (i > w_global.workspace.count)
			wMenuRemoveItem(menu, --i);
		wMenuRealize(menu);
	}
	wNETWMUpdateDesktop(scr);
	WMPostNotificationName(WMNWorkspaceDestroyed, scr, (void *)(uintptr_t) (w_global.workspace.count - 1));

	if (w_global.workspace.current >= w_global.workspace.count)
		wWorkspaceChange(scr, w_global.workspace.count - 1);
	if (w_global.workspace.last_used >= w_global.workspace.count)
		w_global.workspace.last_used = 0;

	return True;
}
Exemple #10
0
static void handleActionEvents(XEvent * event, void *data)
{
	Scroller *sPtr = (Scroller *) data;
	int wheelDecrement, wheelIncrement;
	int id, dd;

	/* check if we're really dealing with a scroller, as something
	 * might have gone wrong in the event dispatching stuff */
	CHECK_CLASS(sPtr, WC_Scroller);

	id = sPtr->flags.incrDown;
	dd = sPtr->flags.decrDown;

	switch (event->type) {
	case EnterNotify:
		break;

	case LeaveNotify:
		if (sPtr->timerID) {
			WMDeleteTimerHandler(sPtr->timerID);
			sPtr->timerID = NULL;
		}
		sPtr->flags.incrDown = 0;
		sPtr->flags.decrDown = 0;
		break;

	case ButtonPress:
		/* FIXME: change Mod1Mask with something else */
		if (sPtr->flags.documentFullyVisible)
			break;

		if (sPtr->flags.horizontal) {
			wheelDecrement = WINGsConfiguration.mouseWheelDown;
			wheelIncrement = WINGsConfiguration.mouseWheelUp;
		} else {
			wheelDecrement = WINGsConfiguration.mouseWheelUp;
			wheelIncrement = WINGsConfiguration.mouseWheelDown;
		}

		if (event->xbutton.button == wheelDecrement) {
			if (event->xbutton.state & ControlMask) {
				sPtr->flags.hitPart = WSDecrementPage;
			} else if (event->xbutton.state & ShiftMask) {
				sPtr->flags.hitPart = WSDecrementLine;
			} else {
				sPtr->flags.hitPart = WSDecrementWheel;
			}
			if (sPtr->action) {
				(*sPtr->action) (sPtr, sPtr->clientData);
				WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
			}
		} else if (event->xbutton.button == wheelIncrement) {
			if (event->xbutton.state & ControlMask) {
				sPtr->flags.hitPart = WSIncrementPage;
			} else if (event->xbutton.state & ShiftMask) {
				sPtr->flags.hitPart = WSIncrementLine;
			} else {
				sPtr->flags.hitPart = WSIncrementWheel;
			}
			if (sPtr->action) {
				(*sPtr->action) (sPtr, sPtr->clientData);
				WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
			}
		} else {
			handlePush(sPtr, event->xbutton.x, event->xbutton.y, (event->xbutton.state & Mod1Mask)
				   || event->xbutton.button == Button2);
			/* continue scrolling if pushed on the buttons */
			if (sPtr->flags.hitPart == WSIncrementLine || sPtr->flags.hitPart == WSDecrementLine) {
				sPtr->timerID = WMAddTimerHandler(AUTOSCROLL_INITIAL_DELAY, autoScroll, sPtr);
			}
		}
		break;

	case ButtonRelease:
		if (sPtr->flags.draggingKnob) {
			if (sPtr->action) {
				(*sPtr->action) (sPtr, sPtr->clientData);
				WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
			}
		}
		if (sPtr->timerID) {
			WMDeleteTimerHandler(sPtr->timerID);
			sPtr->timerID = NULL;
		}
		sPtr->flags.incrDown = 0;
		sPtr->flags.decrDown = 0;
		sPtr->flags.draggingKnob = 0;
		break;

	case MotionNotify:
		handleMotion(sPtr, event->xbutton.x, event->xbutton.y);
		if (sPtr->timerID && sPtr->flags.hitPart != WSIncrementLine
		    && sPtr->flags.hitPart != WSDecrementLine) {
			WMDeleteTimerHandler(sPtr->timerID);
			sPtr->timerID = NULL;
		}
		break;
	}
	if (id != sPtr->flags.incrDown || dd != sPtr->flags.decrDown)
		paintScroller(sPtr);
}
Exemple #11
0
static void handlePush(Scroller * sPtr, int pushX, int pushY, int alternate)
{
	WMScrollerPart part;
	int doAction = 0;

	part = locatePointInScroller(sPtr, pushX, pushY, alternate);

	sPtr->flags.hitPart = part;

	switch (part) {
	case WSIncrementLine:
		sPtr->flags.incrDown = 1;
		doAction = 1;
		break;

	case WSIncrementPage:
		doAction = 1;
		break;

	case WSDecrementLine:
		sPtr->flags.decrDown = 1;
		doAction = 1;
		break;

	case WSDecrementPage:
		doAction = 1;
		break;

	case WSKnob:
		sPtr->flags.draggingKnob = 1;
#ifndef STRICT_NEXT_BEHAVIOUR
		if (sPtr->flags.horizontal)
			sPtr->dragPoint = pushX;
		else
			sPtr->dragPoint = pushY;

		{
			int length, knobP;
			int buttonsLen;

			if (sPtr->flags.arrowsPosition != WSANone)
				buttonsLen = 2 * (BUTTON_SIZE + 1);
			else
				buttonsLen = 0;

			if (sPtr->flags.horizontal)
				length = sPtr->view->size.width - 4 - buttonsLen;
			else
				length = sPtr->view->size.height - 4 - buttonsLen;

			knobP = (int)(sPtr->floatValue * (float)(length - knobLength(sPtr)));

			if (sPtr->flags.arrowsPosition == WSAMinEnd)
				sPtr->dragPoint -= 2 + buttonsLen + knobP;
			else
				sPtr->dragPoint -= 2 + knobP;
		}
#endif				/* STRICT_NEXT_BEHAVIOUR */
		/* This does not seem necesary here since we don't know yet if the
		 * knob will be dragged later. -Dan
		 handleMotion(sPtr, pushX, pushY); */
		break;

	case WSDecrementWheel:
	case WSIncrementWheel:
	case WSKnobSlot:
	case WSNoPart:
		/* dummy */
		break;
	}

	if (doAction && sPtr->action) {
		(*sPtr->action) (sPtr, sPtr->clientData);

		WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
	}
}
Exemple #12
0
static void applySettings(WMWidget *button, void *client_data)
{
	InspectorPanel *panel = (InspectorPanel *) client_data;
	WWindow *wwin = panel->inspected;
	WApplication *wapp = wApplicationOf(wwin->main_window);
	int floating, sunken, skip_window_list;
	int old_omnipresent, old_no_bind_keys, old_no_bind_mouse;

	old_omnipresent = WFLAGP(wwin, omnipresent);
	old_no_bind_keys = WFLAGP(wwin, no_bind_keys);
	old_no_bind_mouse = WFLAGP(wwin, no_bind_mouse);

	showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);

	/* Attributes... --> Window Attributes */
	WSETUFLAG(wwin, no_titlebar, WMGetButtonSelected(panel->attrChk[0]));
	WSETUFLAG(wwin, no_resizebar, WMGetButtonSelected(panel->attrChk[1]));
	WSETUFLAG(wwin, no_close_button, WMGetButtonSelected(panel->attrChk[2]));
	WSETUFLAG(wwin, no_miniaturize_button, WMGetButtonSelected(panel->attrChk[3]));
	WSETUFLAG(wwin, no_border, WMGetButtonSelected(panel->attrChk[4]));
	floating = WMGetButtonSelected(panel->attrChk[5]);
	sunken = WMGetButtonSelected(panel->attrChk[6]);
	WSETUFLAG(wwin, omnipresent, WMGetButtonSelected(panel->attrChk[7]));
	WSETUFLAG(wwin, start_miniaturized, WMGetButtonSelected(panel->attrChk[8]));
	WSETUFLAG(wwin, start_maximized, WMGetButtonSelected(panel->attrChk[9]));
	WSETUFLAG(wwin, full_maximize, WMGetButtonSelected(panel->attrChk[10]));

	/* Attributes... --> Advanced Options */
	WSETUFLAG(wwin, no_bind_keys, WMGetButtonSelected(panel->moreChk[0]));
	WSETUFLAG(wwin, no_bind_mouse, WMGetButtonSelected(panel->moreChk[1]));
	skip_window_list = WMGetButtonSelected(panel->moreChk[2]);
	WSETUFLAG(wwin, skip_switchpanel, WMGetButtonSelected(panel->moreChk[3]));
	WSETUFLAG(wwin, no_focusable, WMGetButtonSelected(panel->moreChk[4]));
	WSETUFLAG(wwin, dont_move_off, WMGetButtonSelected(panel->moreChk[5]));
	WSETUFLAG(wwin, no_hide_others, WMGetButtonSelected(panel->moreChk[6]));
	WSETUFLAG(wwin, dont_save_session, WMGetButtonSelected(panel->moreChk[7]));
	WSETUFLAG(wwin, emulate_appicon, WMGetButtonSelected(panel->moreChk[8]));
	WSETUFLAG(wwin, focus_across_wksp, WMGetButtonSelected(panel->moreChk[9]));
	WSETUFLAG(wwin, no_miniaturizable, WMGetButtonSelected(panel->moreChk[10]));
#ifdef XKB_BUTTON_HINT
	WSETUFLAG(wwin, no_language_button, WMGetButtonSelected(panel->moreChk[11]));
#endif
	WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));

	if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
		wUnshadeWindow(wwin);

	WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar));

	if (floating) {
		if (!WFLAGP(wwin, floating))
			ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
	} else if (sunken) {
		if (!WFLAGP(wwin, sunken))
			ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
	} else {
		if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken))
			ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
	}

	WSETUFLAG(wwin, sunken, sunken);
	WSETUFLAG(wwin, floating, floating);
	wwin->flags.omnipresent = 0;

	if (WFLAGP(wwin, skip_window_list) != skip_window_list) {
		WSETUFLAG(wwin, skip_window_list, skip_window_list);
		UpdateSwitchMenu(wwin->screen_ptr, wwin, skip_window_list ? ACTION_REMOVE : ACTION_ADD);
	} else {
		if (WFLAGP(wwin, omnipresent) != old_omnipresent)
			WMPostNotificationName(WMNChangedState, wwin, "omnipresent");
	}

	if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
		if (WFLAGP(wwin, no_bind_keys))
			XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
		else
			wWindowSetKeyGrabs(wwin);
	}

	if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse)
		wWindowResetMouseGrabs(wwin);

	wwin->frame->flags.need_texture_change = 1;
	wWindowConfigureBorders(wwin);
	wFrameWindowPaint(wwin->frame);
	wNETWMUpdateActions(wwin, False);

	/* Can't apply emulate_appicon because it will probably cause problems. */
	if (wapp) {
		/* do application wide stuff */
		WSETUFLAG(wapp->main_window_desc, start_hidden, WMGetButtonSelected(panel->appChk[0]));
		WSETUFLAG(wapp->main_window_desc, no_appicon, WMGetButtonSelected(panel->appChk[1]));
		WSETUFLAG(wapp->main_window_desc, shared_appicon, WMGetButtonSelected(panel->appChk[2]));

		if (WFLAGP(wapp->main_window_desc, no_appicon))
			unpaint_app_icon(wapp);
		else
			paint_app_icon(wapp);

		char *file = WMGetTextFieldText(panel->fileText);
		if (file[0] == 0) {
			wfree(file);
			file = NULL;
		}

		/* If always_user_icon flag is set, but the user icon is not set
		 * we use client supplied icon and we unset the flag */
		if ((WFLAGP(wwin, always_user_icon) && (!file))) {
			/* Show the warning */
			char *buf;
			int len = 100;

			buf = wmalloc(len);
			snprintf(buf, len, _("Ignore client supplied icon is set, but icon filename textbox is empty. Using client supplied icon"));
			wMessageDialog(panel->frame->screen_ptr, _("Warning"), buf, _("OK"), NULL, NULL);
			wfree(buf);
			wfree(file);

			/* Change the flags */
			WSETUFLAG(wwin, always_user_icon, 0);
			WMSetButtonSelected(panel->alwChk, 0);
		}

		/* After test the always_user_icon flag value before,
		 * the "else" block is used only if the flag is set and
		 * the icon text box has an icon path */
		if (!WFLAGP(wwin, always_user_icon)) {
			/* Change App Icon image, using the icon provided by the client */
			if (wapp->app_icon) {
				RImage *image = get_rimage_icon_from_wm_hints(wapp->app_icon->icon);
				if (image) {
					set_icon_image_from_image(wapp->app_icon->icon, image);
					update_icon_pixmap(wapp->app_icon->icon);
				} else {
					wIconUpdate(wapp->app_icon->icon);
				}
			}

			/* Change icon image if the app is minimized,
			 * using the icon provided by the client */
			if (wwin->icon) {
				RImage *image = get_rimage_icon_from_wm_hints(wwin->icon);
				if (image) {
					set_icon_image_from_image(wwin->icon, image);
					update_icon_pixmap(wwin->icon);
				} else {
					wIconUpdate(wwin->icon);
				}
			}
		} else {
			/* Change App Icon image */
			if (wapp->app_icon)
				wIconChangeImageFile(wapp->app_icon->icon, file);

			/* Change icon image if the app is minimized */
			if (wwin->icon)
				wIconChangeImageFile(wwin->icon, file);
		}

		if (file)
			wfree(file);
	}

	wNETFrameExtents(wwin);
}