Пример #1
0
static void appicon_move_to_dock(WDock *originalDock, WDock *lastDock,
				 WAppIcon *aicon, WIcon *icon, int x, int y,
				 int oldX, int oldY, int shad_x, int shad_y,
				 int ix, int iy, Bool *docked, Bool *collapsed)
{
	virtual_screen *vscr = aicon->icon->vscr;
	WScreen *scr = vscr->screen_ptr;

	slide_window(icon->core->window, x, y, shad_x, shad_y);
	XUnmapWindow(dpy, scr->dock_shadow);

	if (originalDock == NULL) {
		/* Docking an undocked appicon */
		*docked = wDockAttachIcon(lastDock, aicon, ix, iy, False);

		if (!*docked) {
			/*
			 * AppIcon got rejected (happens only when we can't get the
			 * command for that appicon, and the user cancels the
			 * wInputDialog asking for one). Make the rejection obvious by
			 * sliding the icon to its old position
			 */
			if (lastDock->type == WM_DRAWER) /* Also fill the gap left in the drawer */
				wDrawerFillTheGap(lastDock, aicon, False);

			slide_window(icon->core->window, x, y, oldX, oldY);
		}
	} else {
		/* moving a docked appicon to a dock */
		if (originalDock == lastDock) {
			*docked = True;
			wDockReattachIcon(originalDock, aicon, ix, iy);
		} else {
			*docked = wDockMoveIconBetweenDocks(originalDock, lastDock, aicon, ix, iy);
			if (!*docked) {
				appicon_move_to_nodock(originalDock, lastDock, aicon, icon, x, y, oldX, oldY);
			} else {
				if (originalDock->auto_collapse && !originalDock->collapsed) {
					originalDock->collapsed = 1;
					wDockHideIcons(originalDock);
				}

				if (originalDock->auto_raise_lower)
					wDockLower(originalDock);
			}
		}
	}

	/* If docked (or tried to dock) to a auto_collapsing dock, unset
	 * collapsed, so that wHandleAppIconMove doesn't collapse it
	 * right away (the timer will take care of it) */
	if (lastDock->auto_collapse)
		*collapsed = 0;
}
Пример #2
0
static void appicon_move_to_nodock(WDock *originalDock, WDock *lastDock,
				   WAppIcon *aicon, WIcon *icon, int x, int y,
				   int oldX, int oldY)
{
	WAppIcon *aiconsToShift[originalDock->icon_count];
	int i, j = 0;

	/*
	 * Possible scenario: user moved an auto-attracted appicon
	 * from the clip to the dock, and cancelled the wInputDialog
	 * asking for a command
	 */
	if (lastDock->type == WM_DRAWER)
		wDrawerFillTheGap(lastDock, aicon, False);

	/* If aicon comes from a drawer, make some room to reattach it */
	if (originalDock->type == WM_DRAWER) {
		for (i = 0; i < originalDock->max_icons; i++) {
			WAppIcon *ai = originalDock->icon_array[i];
			if (ai && ai != aicon &&
			    abs(ai->xindex) >= abs(aicon->xindex))
				aiconsToShift[j++] = ai;
		}

		/* Trust this never happens? */
		if (j != originalDock->icon_count - abs(aicon->xindex) - 1)
			wwarning("Shifting j=%d appicons (instead of %d!) to reinsert aicon at index %d.",
				 j, originalDock->icon_count - abs(aicon->xindex) - 1, aicon->xindex);

		wSlideAppicons(aiconsToShift, j, originalDock->on_right_side);
		/*
		 * Trust the appicon is inserted at exactly the same place,
		 * so its oldX/oldY are consistent with its "new" location?
		 */
	}

	slide_window(icon->core->window, x, y, oldX, oldY);
	wDockReattachIcon(originalDock, aicon, aicon->xindex, aicon->yindex);
}
Пример #3
0
void move_appicon_to_dock(virtual_screen *vscr, WAppIcon *icon, char *wm_class, char *wm_instance)
{
	WAppIcon *aicon;
	int x0, y0;

	/* Create appicon's icon */
	aicon = create_appicon(vscr, NULL, wm_class, wm_instance);
	aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
	aicon->icon->core->descriptor.parent = aicon;
	appicon_map(aicon);

	/* Map it on the screen, in the right possition */
	PlaceIcon(vscr, &x0, &y0, wGetHeadForWindow(aicon->icon->owner));
	wAppIconMove(aicon, x0, y0);
	XMapWindow(dpy, aicon->icon->core->window);
	aicon->launching = 1;
	wAppIconPaint(aicon);

	/* Move to the docked icon and destroy it */
	slide_window(aicon->icon->core->window, x0, y0, icon->x_pos, icon->y_pos);
	XUnmapWindow(dpy, aicon->icon->core->window);
	wAppIconDestroy(aicon);
}
Пример #4
0
void* worker_rx_thread(void *arg)
{
    worker_t *w = (worker_t*)arg;
    monitor_t *m = w->m;
    mpudp_packet_t *p = malloc(sizeof(mpudp_packet_t));
    mpudp_packet_t *target;
    int res;

    while(1)
    {
        if(worker_recv_packet(w, p))
        {
            if(p->type == MPUDP_CONFIG)
            {
                mpudp_config_t *config = malloc(sizeof(mpudp_config_t));
                res = mpudp_chars2config(config, p->payload, p->len);

                if(res == -1)
                    continue;

                pthread_mutex_lock(&w->m->remote_config_mx);
                if(config->id > w->m->remote_config->id)
                {
                    /* printf("[%d] - We have a new config!\n", w->id); */
                    w->m->remote_config = config;

                    pthread_cond_signal(&w->m->remote_config_changed);
                }
                pthread_mutex_unlock(&w->m->remote_config_mx);

            }
            else if(p->type == MPUDP_DATA)
            {
                /* printf("[%d] - got data packet %d!\n", w->id, p->id); */
                pthread_mutex_lock(&w->m->rx_mx);
                while(w->m->rx_num >= BUFF_LEN)
                    pthread_cond_wait(&w->m->rx_not_full, &w->m->rx_mx);

                if((w->m->rx_data[p->id % BUFF_LEN] == NULL) &&
                        (p->id >= w->m->user_expected_id) &&
                        (p->id < w->m->user_expected_id+BUFF_LEN))
                {
                    /* printf("[%d] - accepting new packet %d\n", w->id, p->id); */
                    target = malloc(sizeof(mpudp_packet_t));
                    w->m->rx_data[p->id % BUFF_LEN] = target;

                    *target = *p;
                    /* printf("target len: %d\n", target->len); */

                    /* target->payload = malloc(sizeof(p->len)); */
                    /* printf("target: %p\n", target->payload); */
                    /* printf("packet: %p\n", p->payload); */
                    target->payload = p->payload;

                    /* memcpy(target->payload, p->payload, p->len); */

                    worker_send_ack(w, p->id);
                    w->m->rx_num++;

                }
                else if(p->id < w->m->user_expected_id)
                {
                    // old packet
                    worker_send_ack(w, p->id);
                    printf("[%d] - confirming old packet %d\n", w->id, p->id);
                }
                else
                {
                    // droping packet
                    printf("[%d] - droping packet: %d\n", w->id, p->id);
                }

                pthread_cond_broadcast(&w->m->rx_has_data);
                pthread_mutex_unlock(&w->m->rx_mx);
            }
            else if(p->type == MPUDP_ACK)
            {
                /* timestamp(); */
                /* printf("[%d] - got ACK %d\n", w->id, p->id); */

                pthread_mutex_lock(&w->wait_ack_buff_mx);
                int i;
                for(i = 0; i < BUFF_LEN; i++)
                {
                    if(w->wait_ack_buff[i] != NULL && (w->wait_ack_buff[i]->id == p->id))
                    {
                        /* timestamp(); */
                        /* printf("[%d] - found matching ACK %d\n", w->id, p->id); */
                        free(w->wait_ack_buff[i]->payload);
                        w->wait_ack_buff[i] = NULL;
                        w->arq_count[i] = 0;

                        if(slide_window(w))
                        {
                            /* printf("[%d] - tx watcher notified\n", w->id); */
                            pthread_cond_broadcast(&w->m->tx_has_data);
                        }
                        break;
                    }
                }
                pthread_mutex_unlock(&w->wait_ack_buff_mx);
            }
        }
    }
}