Lines Matching refs:clone
88 struct clone *clone;
164 struct clone {
165 struct clone *next;
166 struct clone *active;
186 struct clone *clones;
187 struct clone *active;
522 ctx->clones = malloc(sizeof(struct clone));
612 static void clone_update_edid(struct clone *clone)
619 if (XRRGetOutputProperty(clone->dst.dpy, clone->dst.rr_output,
620 XInternAtom(clone->dst.dpy, "EDID", False),
623 XRRChangeOutputProperty(clone->src.dpy, clone->src.rr_output,
624 XInternAtom(clone->src.dpy, "EDID", False),
669 static int clone_update_modes__randr(struct clone *clone)
675 assert(clone->src.rr_output);
676 assert(clone->dst.rr_output);
677 assert(clone->dst.display->rr_event);
679 from_res = _XRRGetScreenResourcesCurrent(clone->dst.dpy, clone->dst.window);
683 from_info = XRRGetOutputInfo(clone->dst.dpy, from_res, clone->dst.rr_output);
688 DisplayString(clone->src.dpy), clone->src.name,
689 DisplayString(clone->dst.dpy), clone->dst.name,
690 from_info->timestamp, clone->timestamp));
692 to_res = _XRRGetScreenResourcesCurrent(clone->src.dpy, clone->src.window);
696 to_info = XRRGetOutputInfo(clone->src.dpy, to_res, clone->src.rr_output);
701 __func__, (long)clone->dst.rr_crtc, (long)from_info->crtc));
702 if (clone->dst.rr_crtc == from_info->crtc) {
711 DisplayString(clone->src.dpy), clone->src.name,
723 DisplayString(clone->src.dpy), clone->src.name,
730 DisplayString(clone->src.dpy), clone->src.name));
736 if (from_info->crtc != clone->dst.rr_crtc) {
738 DisplayString(clone->dst.dpy), clone->dst.name));
739 if (disable_crtc(clone->dst.dpy, from_res, from_info->crtc)) {
740 clone->dst.rr_crtc = 0;
741 clone->dst.mode.id = 0;
743 XRRCrtcInfo *c = XRRGetCrtcInfo(clone->dst.dpy, from_res, from_info->crtc);
745 clone->dst.x = c->x;
746 clone->dst.y = c->y;
747 clone->dst.rotation = c->rotation;
748 clone->dst.mode.id = c->mode;
755 XGrabServer(clone->src.dpy);
760 DisplayString(clone->src.dpy), clone->src.name));
761 disable_crtc(clone->src.dpy, to_res, to_info->crtc);
765 DisplayString(clone->src.dpy), clone->src.name, (long)to_info->modes[i]));
766 XRRDeleteOutputMode(clone->src.dpy, clone->src.rr_output, to_info->modes[i]);
769 clone->src.rr_crtc = 0;
794 DisplayString(clone->src.dpy), clone->src.name, id, mode->name));
805 "%s.%ld-%s", clone->src.name, (long)from_info->modes[i], mode->name);
808 id = XRRCreateMode(clone->src.dpy, clone->src.window, &m);
810 DisplayString(clone->src.dpy), clone->src.name, id, mode->name));
813 XRRAddOutputMode(clone->src.dpy, clone->src.rr_output, id);
815 clone_update_edid(clone);
816 XUngrabServer(clone->src.dpy);
819 clone->timestamp = from_info->timestamp;
834 static int clone_update_modes__fixed(struct clone *clone)
844 DisplayString(clone->dst.dpy), clone->dst.name,
845 clone->dst.width, clone->dst.height));
847 assert(clone->src.rr_output);
849 res = _XRRGetScreenResourcesCurrent(clone->src.dpy, clone->src.window);
853 info = XRRGetOutputInfo(clone->src.dpy, res, clone->src.rr_output);
857 XGrabServer(clone->src.dpy);
862 DisplayString(clone->src.dpy), clone->src.name));
863 disable_crtc(clone->src.dpy, res, info->crtc);
867 DisplayString(clone->src.dpy), clone->src.name, (long)info->modes[i]));
868 XRRDeleteOutputMode(clone->src.dpy, clone->src.rr_output, info->modes[i]);
871 clone->src.rr_crtc = 0;
875 mode.width = clone->dst.width;
876 mode.height = clone->dst.height;
888 id = XRRCreateMode(clone->src.dpy, clone->src.window, &mode);
890 XRRAddOutputMode(clone->src.dpy, clone->src.rr_output, id);
892 XUngrabServer(clone->src.dpy);
1016 static void init_image(struct clone *clone)
1018 XImage *image = &clone->image;
1021 image->width = clone->width;
1022 image->height = clone->height;
1029 image->data = clone->shm.shmaddr;
1030 image->bytes_per_line = stride_for_depth(clone->width, clone->depth);
1031 switch (clone->depth) {
1081 static void output_init_xfer(struct clone *clone, struct output *output)
1089 clone->shm.shmaddr, &output->shm,
1090 clone->width, clone->height, clone->depth);
1110 clone->width, clone->height, clone->depth);
1141 static int clone_init_xfer(struct clone *clone)
1145 if (clone->dst.mode.id == 0) {
1148 } else if (clone->dri3.xid) {
1149 width = clone->dst.width;
1150 height = clone->dst.height;
1152 width = mode_width(&clone->src.mode, clone->src.rotation);
1153 height = mode_height(&clone->src.mode, clone->src.rotation);
1157 DisplayString(clone->dst.dpy), clone->dst.name,
1158 width, height, clone->width, clone->height));
1160 if (width == clone->width && height == clone->height)
1163 if (clone->shm.shmaddr) {
1164 if (clone->src.use_shm)
1165 XShmDetach(clone->src.dpy, &clone->src.shm);
1166 if (clone->dst.use_shm)
1167 XShmDetach(clone->dst.dpy, &clone->dst.shm);
1169 shmdt(clone->shm.shmaddr);
1170 clone->shm.shmaddr = NULL;
1173 if (clone->src.pixmap) {
1174 XFreePixmap(clone->src.dpy, clone->src.pixmap);
1175 clone->src.pixmap = 0;
1178 if (clone->dst.pixmap) {
1179 XFreePixmap(clone->dst.dpy, clone->dst.pixmap);
1180 clone->dst.pixmap = 0;
1184 clone->damaged.x2 = clone->damaged.y2 = INT_MIN;
1185 clone->damaged.x1 = clone->damaged.y1 = INT_MAX;
1189 if (clone->dri3.xid) {
1196 DisplayString(clone->dst.dpy), clone->dst.name));
1198 fd = dri3_create_fd(clone->dst.dpy, clone->dst.window, &stride);
1203 DisplayString(clone->dst.dpy), clone->dst.name,
1206 src = dri3_create_pixmap(clone->src.dpy, clone->src.window,
1207 width, height, clone->depth,
1208 fd, bpp_for_depth(clone->depth),
1211 XSync(clone->src.dpy, False);
1213 clone->src.pixmap = src;
1214 clone->width = width;
1215 clone->height = height;
1217 XFreePixmap(clone->src.dpy, src);
1220 dri3_fence_free(clone->src.dpy, &clone->dri3);
1221 clone->dri3.xid = 0;
1224 DisplayString(clone->dst.dpy), clone->dst.name));
1228 width = mode_width(&clone->src.mode, clone->src.rotation);
1229 height = mode_height(&clone->src.mode, clone->src.rotation);
1231 if (!clone->dri3.xid) {
1233 DisplayString(clone->dst.dpy), clone->dst.name));
1235 clone->shm.shmid = shmget(IPC_PRIVATE,
1236 height * stride_for_depth(width, clone->depth),
1238 if (clone->shm.shmid == -1)
1241 clone->shm.shmaddr = shmat(clone->shm.shmid, 0, 0);
1242 if (clone->shm.shmaddr == (char *) -1) {
1243 shmctl(clone->shm.shmid, IPC_RMID, NULL);
1247 if (clone->src.use_shm) {
1248 clone->src.shm = clone->shm;
1249 clone->src.shm.readOnly = False;
1250 XShmAttach(clone->src.dpy, &clone->src.shm);
1251 XSync(clone->src.dpy, False);
1253 if (clone->dst.use_shm) {
1254 clone->dst.shm = clone->shm;
1255 clone->dst.shm.readOnly = !clone->dst.use_shm_pixmap;
1256 XShmAttach(clone->dst.dpy, &clone->dst.shm);
1257 XSync(clone->dst.dpy, False);
1260 shmctl(clone->shm.shmid, IPC_RMID, NULL);
1262 clone->width = width;
1263 clone->height = height;
1265 init_image(clone);
1268 output_init_xfer(clone, &clone->src);
1269 output_init_xfer(clone, &clone->dst);
1271 clone->damaged.x1 = clone->src.x;
1272 clone->damaged.x2 = clone->src.x + width;
1273 clone->damaged.y1 = clone->src.y;
1274 clone->damaged.y2 = clone->src.y + height;
1276 display_mark_flush(clone->dst.display);
1280 static void clone_update(struct clone *clone)
1282 if (!clone->rr_update)
1286 DisplayString(clone->dst.dpy), clone->dst.name));
1288 clone_update_modes__randr(clone);
1289 clone->rr_update = 0;
1439 struct clone *clone;
1443 for (clone = display->clone; clone; clone = clone->next) {
1444 struct output *output = &clone->src;
1446 clone->dst.mode.id = -1;
1447 clone->dst.rr_crtc = -1;
1449 clone->dst.mode.id = 0;
1450 clone->dst.rr_crtc = 0;
1459 for (clone = display->clone; clone; clone = clone->next) {
1460 struct output *output = &clone->src;
1463 assert(clone->dst.display == display);
1469 DisplayString(clone->dst.dpy), output->name,
1497 for (clone = display->clone; clone; clone = clone->next) {
1498 struct output *dst = &clone->dst;
1505 assert(clone->dst.display == display);
1523 for (clone = display->clone; clone; clone = clone->next) {
1524 struct output *dst = &clone->dst;
1531 assert(clone->dst.display == display);
1544 for (clone = display->clone; clone; clone = clone->next) {
1545 struct output *src = &clone->src;
1546 struct output *dst = &clone->dst;
1549 struct clone *set;
1563 assert(clone->dst.display == display);
1617 for (set = display->clone; set != clone; set = set->next) {
1631 for (set = display->clone; set != clone; set = set->next) {
1638 if (set == clone) {
1707 struct clone *clone = &ctx->clones[n];
1709 clone_init_xfer(clone);
1711 if (clone->dst.rr_crtc == 0)
1715 DisplayString(clone->dst.display->dpy), clone->dst.name));
1717 if (clone->dst.display->active++ == 0)
1718 screensaver_disable(clone->dst.display);
1720 clone->active = ctx->active;
1721 ctx->active = clone;
1851 static void clone_move_cursor(struct clone *c, int x, int y)
1870 static int clone_output_init(struct clone *clone, struct output *output,
1897 if (depth < clone->depth)
1898 clone->depth = depth;
1910 static void get_src(struct clone *c, const XRectangle *clip)
1965 static void put_dst(struct clone *c, const XRectangle *clip)
2030 static int clone_paint(struct clone *c)
2037 DBG(DRAW, ("%s-%s paint clone, damaged (%d, %d), (%d, %d) [(%d, %d), (%d, %d)]\n",
2127 static void clone_damage(struct clone *c, const XRectangle *rec)
2178 struct clone *clone;
2180 for (clone = ctx->active; clone; clone = clone->active)
2181 clone_move_cursor(clone,
2402 static int clone_init_depth(struct clone *clone)
2407 DisplayString(clone->dst.dpy), clone->dst.name, clone->depth));
2410 for (depth = clone->depth; depth <= 24; depth += 8) {
2411 ret = display_init_render(clone->src.display, depth, &clone->src.use_render);
2415 ret = display_init_render(clone->dst.display, depth, &clone->dst.use_render);
2424 clone->depth = depth;
2427 DisplayString(clone->dst.dpy), clone->dst.name,
2428 clone->depth,
2429 clone->src.use_render != NULL,
2430 clone->dst.use_render != NULL));
2432 if (!clone->dst.use_render &&
2433 clone->src.display->dri3_active &&
2434 clone->dst.display->dri3_active)
2435 dri3_create_fence(clone->src.dpy, clone->src.window, &clone->dri3);
2468 struct clone *clone = &ctx->clones[n];
2469 clone->src.display = new_display + (clone->src.display - ctx->display);
2470 clone->dst.display = new_display + (clone->dst.display - ctx->display);
2656 static void rebuild_clones(struct context *ctx, struct clone *new_clones)
2663 d->clone = NULL;
2665 struct clone *c = &new_clones[m];
2670 c->next = d->clone;
2671 d->clone = c;
2678 static struct clone *add_clone(struct context *ctx)
2681 struct clone *new_clones;
2683 new_clones = realloc(ctx->clones, 2*ctx->nclone*sizeof(struct clone));
2691 return memset(&ctx->clones[ctx->nclone++], 0, sizeof(struct clone));
2701 struct clone *list = NULL;
2703 while (display->clone) {
2704 struct clone *clone = display->clone;
2705 display->clone = clone->next;
2706 clone->next = list;
2707 list = clone;
2710 display->clone = list;
2732 struct clone *clone = add_clone(ctx);
2735 if (clone == NULL)
2738 clone->depth = 24;
2739 clone->next = display->clone;
2740 display->clone = clone;
2749 ret = clone_output_init(clone, &clone->src, ctx->display, buf, id);
2756 ret = clone_output_init(clone, &clone->dst, display, o->name, res->outputs[i]);
2763 ret = clone_init_depth(clone);
2770 clone->dst.x = 0;
2771 clone->dst.y = 0;
2772 clone->dst.width = display->width;
2773 clone->dst.height = display->height;
2775 ret = clone_update_modes__randr(clone);
2777 fprintf(stderr, "Failed to clone output \"%s\" from display \"%s\"\n",
2810 struct clone *clone = add_clone(ctx);
2813 if (clone == NULL)
2819 clone->depth = 24;
2820 clone->next = display->clone;
2821 display->clone = clone;
2828 ret = clone_output_init(clone, &clone->src, ctx->display, buf, id);
2836 ret = clone_output_init(clone, &clone->dst, display, buf, 0);
2843 ret = clone_init_depth(clone);
2851 clone->dst.width = xi[n].width;
2852 clone->dst.height = xi[n].height;
2853 clone->dst.x = xi[n].x_org;
2854 clone->dst.y = xi[n].y_org;
2855 clone->dst.rr_crtc = -1;
2856 ret = clone_update_modes__fixed(clone);
2858 fprintf(stderr, "Failed to clone Xinerama screen %d from display \"%s\"\n",
2863 clone->active = ctx->active;
2864 ctx->active = clone;
2879 struct clone *clone;
2889 clone = add_clone(ctx);
2890 if (clone == NULL)
2893 clone->depth = 24;
2894 clone->next = display->clone;
2895 display->clone = clone;
2902 ret = clone_output_init(clone, &clone->src, ctx->display, buf, id);
2910 ret = clone_output_init(clone, &clone->dst, display, buf, 0);
2917 ret = clone_init_depth(clone);
2926 clone->dst.width = scr->width;
2927 clone->dst.height = scr->height;
2928 clone->dst.x = 0;
2929 clone->dst.y = 0;
2930 clone->dst.rr_crtc = -1;
2931 ret = clone_update_modes__fixed(clone);
2933 fprintf(stderr, "Failed to clone display \"%s\"\n",
2938 clone->active = ctx->active;
2939 ctx->active = clone;
3313 struct clone *clone = &ctx->clones[i];
3316 assert(clone->src.display == ctx->display);
3318 output = XRRGetOutputInfo(dpy, res, clone->src.rr_output);
3324 XRRDeleteOutputMode(dpy, clone->src.rr_output, output->modes[j]);
3630 struct clone *clone;
3636 for (clone = ctx.active; clone; clone = clone->active)
3637 clone_damage(clone, &de->area);
3686 struct clone *clone;
3693 for (clone = ctx.active; clone; clone = clone->active) {
3696 if (clone->dst.display != &ctx.display[i])
3699 r.x = clone->src.x + xe->x;
3700 r.y = clone->src.y + xe->y;
3703 clone_damage(clone, &r);
3715 struct clone *clone;
3718 for (clone = ctx.display[i].clone; clone; clone = clone->next) {
3719 if (clone->dst.rr_output == ro->output)
3720 rr_update = clone->rr_update = 1;
3739 struct clone *clone;
3750 for (clone = ctx.active; clone; clone = clone->active)
3751 ret |= clone_paint(clone);