示例#1
0
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
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;
	}
}
示例#3
0
文件: misc.c 项目: cneira/wmaker-crm
/* wins is an array of Window, sorted from left to right, the first is
 * going to be moved from (from_x,from_y) to (to_x,to_y) and the
 * following windows are going to be offset by (ICON_SIZE*i,0) */
void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int to_y)
{
	time_t time0 = time(NULL);
	float dx, dy, x = from_x, y = from_y, px, py;
	Bool is_dx_nul, is_dy_nul;
	int dx_is_bigger = 0, dx_int, dy_int;
	int slide_delay, slide_steps, slide_slowdown;
	int i;

	/* animation parameters */
	static const struct {
		int delay;
		int steps;
		int slowdown;
	} apars[5] = {
		{ICON_SLIDE_DELAY_UF, ICON_SLIDE_STEPS_UF, ICON_SLIDE_SLOWDOWN_UF},
		{ICON_SLIDE_DELAY_F,  ICON_SLIDE_STEPS_F,  ICON_SLIDE_SLOWDOWN_F},
		{ICON_SLIDE_DELAY_M,  ICON_SLIDE_STEPS_M,  ICON_SLIDE_SLOWDOWN_M},
		{ICON_SLIDE_DELAY_S,  ICON_SLIDE_STEPS_S,  ICON_SLIDE_SLOWDOWN_S},
		{ICON_SLIDE_DELAY_US, ICON_SLIDE_STEPS_US, ICON_SLIDE_SLOWDOWN_US}
	};

	slide_slowdown = apars[(int)wPreferences.icon_slide_speed].slowdown;
	slide_steps = apars[(int)wPreferences.icon_slide_speed].steps;
	slide_delay = apars[(int)wPreferences.icon_slide_speed].delay;

	dx_int = to_x - from_x;
	dy_int = to_y - from_y;
	is_dx_nul = (dx_int == 0);
	is_dy_nul = (dy_int == 0);
	dx = (float) dx_int;
	dy = (float) dy_int;

	if (abs(dx_int) > abs(dy_int)) {
		dx_is_bigger = 1;
	}

	if (dx_is_bigger) {
		px = dx / slide_slowdown;
		if (px < slide_steps && px > 0)
			px = slide_steps;
		else if (px > -slide_steps && px < 0)
			px = -slide_steps;
		py = (is_dx_nul ? 0.0 : px * dy / dx);
	} else {
		py = dy / slide_slowdown;
		if (py < slide_steps && py > 0)
			py = slide_steps;
		else if (py > -slide_steps && py < 0)
			py = -slide_steps;
		px = (is_dy_nul ? 0.0 : py * dx / dy);
	}

	while (((int)x) != to_x ||
			 ((int)y) != to_y) {
		x += px;
		y += py;
		if ((px < 0 && (int)x < to_x) || (px > 0 && (int)x > to_x))
			x = (float)to_x;
		if ((py < 0 && (int)y < to_y) || (py > 0 && (int)y > to_y))
			y = (float)to_y;

		if (dx_is_bigger) {
			px = px * (1.0 - 1 / (float)slide_slowdown);
			if (px < slide_steps && px > 0)
				px = slide_steps;
			else if (px > -slide_steps && px < 0)
				px = -slide_steps;
			py = (is_dx_nul ? 0.0 : px * dy / dx);
		} else {
			py = py * (1.0 - 1 / (float)slide_slowdown);
			if (py < slide_steps && py > 0)
				py = slide_steps;
			else if (py > -slide_steps && py < 0)
				py = -slide_steps;
			px = (is_dy_nul ? 0.0 : py * dx / dy);
		}

		for (i = 0; i < n; i++) {
			XMoveWindow(dpy, *wins[i], (int)x + i * ICON_SIZE, (int)y);
		}
		XFlush(dpy);
		if (slide_delay > 0) {
			wusleep(slide_delay * 1000L);
		} else {
			wusleep(10);
		}
		if (time(NULL) - time0 > MAX_ANIMATION_TIME)
			break;
	}
	for (i = 0; i < n; i++) {
		XMoveWindow(dpy, *wins[i], to_x + i * ICON_SIZE, to_y);
	}

	XSync(dpy, 0);
	/* compress expose events */
	eatExpose();
}