Ejemplo n.º 1
0
void wWorkspaceRelativeChange(WScreen * scr, int amount)
{
	int w;

	/* While the deiconify animation is going on the window is
	 * still "flying" to its final position and we don't want to
	 * change workspace before the animation finishes, otherwise
	 * the window will land in the new workspace */
	if (w_global.workspace.ignore_change)
		return;

	w = w_global.workspace.current + amount;

	if (amount < 0) {
		if (w >= 0) {
			wWorkspaceChange(scr, w);
		} else if (wPreferences.ws_cycle) {
			wWorkspaceChange(scr, w_global.workspace.count + w);
		}
	} else if (amount > 0) {
		if (w < w_global.workspace.count) {
			wWorkspaceChange(scr, w);
		} else if (wPreferences.ws_advance) {
			wWorkspaceChange(scr, WMIN(w, MAX_WORKSPACES - 1));
		} else if (wPreferences.ws_cycle) {
			wWorkspaceChange(scr, w % w_global.workspace.count);
		}
	}
}
Ejemplo n.º 2
0
static unsigned hashPropList(const void *param)
{
	WMPropList *plist= (WMPropList *) param;
	unsigned ret = 0;
	unsigned ctr = 0;
	const char *key;
	int i, len;

	switch (plist->type) {
	case WPLString:
		key = plist->d.string;
		len = WMIN(strlen(key), MaxHashLength);
		for (i = 0; i < len; i++) {
			ret ^= tolower(key[i]) << ctr;
			ctr = (ctr + 1) % sizeof(char *);
		}
		/*while (*key) {
		   ret ^= tolower(*key++) << ctr;
		   ctr = (ctr + 1) % sizeof (char *);
		   } */
		break;

	case WPLData:
		key = WMDataBytes(plist->d.data);
		len = WMIN(WMGetDataLength(plist->d.data), MaxHashLength);
		for (i = 0; i < len; i++) {
			ret ^= key[i] << ctr;
			ctr = (ctr + 1) % sizeof(char *);
		}
		break;

	default:
		wwarning(_("Only string or data is supported for a proplist dictionary key"));
		wassertrv(False, 0);
		break;
	}

	return ret;
}
Ejemplo n.º 3
0
static void slideWindow(Display * dpy, Window win, int srcX, int srcY, int dstX, int dstY)
{
	double x, y, dx, dy;
	int i;
	int iterations;

	iterations = WMIN(MAX_SLIDEBACK_ITER, WMAX(abs(dstX - srcX), abs(dstY - srcY)));

	x = srcX;
	y = srcY;

	dx = (double)(dstX - srcX) / iterations;
	dy = (double)(dstY - srcY) / iterations;

	for (i = 0; i <= iterations; i++) {
		XMoveWindow(dpy, win, x, y);
		XFlush(dpy);

		wusleep(800);

		x += dx;
		y += dy;
	}
}
Ejemplo n.º 4
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);
	}
}