Skip to content

Commit c132693

Browse files
committed
Support set monitor info and scale
This is a shameless copy of neutrinolabs#172 for my own prototyping and editing purposes. We need to figure out how to get xf86SetDpi working.
1 parent a4ce59b commit c132693

File tree

3 files changed

+98
-38
lines changed

3 files changed

+98
-38
lines changed

module/rdpClientCon.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -1003,27 +1003,32 @@ rdpClientConProcessMsgClientInfo(rdpPtr dev, rdpClientCon *clientCon)
10031003
box.x2 = dev->minfo[0].right;
10041004
box.y2 = dev->minfo[0].bottom;
10051005
/* adjust monitor info so it's not negative */
1006-
for (index = 1; index < dev->monitorCount; index++)
1006+
for (index = 1; index < dev->monitorCount; ++index)
10071007
{
10081008
box.x1 = min(box.x1, dev->minfo[index].left);
10091009
box.y1 = min(box.y1, dev->minfo[index].top);
10101010
box.x2 = max(box.x2, dev->minfo[index].right);
10111011
box.y2 = max(box.y2, dev->minfo[index].bottom);
10121012
}
1013-
for (index = 0; index < dev->monitorCount; index++)
1013+
for (index = 0; index < dev->monitorCount; ++index)
10141014
{
10151015
dev->minfo[index].left -= box.x1;
10161016
dev->minfo[index].top -= box.y1;
10171017
dev->minfo[index].right -= box.x1;
10181018
dev->minfo[index].bottom -= box.y1;
1019-
LLOGLN(0, (" left %d top %d right %d bottom %d",
1019+
1020+
LLOGLN(0, (" left %d top %d right %d bottom %d pWidth %d pHeight %d "
1021+
"orientation %d",
10201022
dev->minfo[index].left,
10211023
dev->minfo[index].top,
10221024
dev->minfo[index].right,
1023-
dev->minfo[index].bottom));
1025+
dev->minfo[index].bottom,
1026+
dev->minfo[index].physical_width,
1027+
dev->minfo[index].physical_height,
1028+
dev->minfo[index].orientation));
10241029
}
10251030

1026-
rdpRRSetRdpOutputs(dev);
1031+
rdpRRSetRdpOutputs(dev, clientCon);
10271032
RRTellChanged(dev->pScreen);
10281033
}
10291034
else
@@ -1032,7 +1037,7 @@ rdpClientConProcessMsgClientInfo(rdpPtr dev, rdpClientCon *clientCon)
10321037
clientCon->doMultimon = 0;
10331038
dev->doMultimon = 0;
10341039
dev->monitorCount = 0;
1035-
rdpRRSetRdpOutputs(dev);
1040+
rdpRRSetRdpOutputs(dev, clientCon);
10361041
RRTellChanged(dev->pScreen);
10371042
}
10381043

module/rdpRandR.c

+86-31
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ RandR draw calls
4141
#include <fb.h>
4242
#include <micmap.h>
4343
#include <mi.h>
44+
#include <pixman.h>
45+
#include <xorg/rrtransform.h>
46+
#include <xorg/picturestr.h>
4447

4548
#include "rdp.h"
4649
#include "rdpDraw.h"
4750
#include "rdpReg.h"
4851
#include "rdpMisc.h"
4952
#include "rdpRandR.h"
53+
#include "rdpClientCon.h"
5054

5155
#if defined(XORGXRDP_GLAMOR)
5256
#include <glamor.h>
@@ -364,9 +368,42 @@ rdpRRSetPanning(ScreenPtr pScreen, RRCrtcPtr crtc, BoxPtr totalArea,
364368
return TRUE;
365369
}
366370

371+
/******************************************************************************/
372+
static void
373+
rdpRRSetOutputPhysicalSize(const char* func, RROutputPtr output,
374+
struct monitor_info *monitor)
375+
{
376+
if (monitor->physical_height == 0 || monitor->physical_width == 0)
377+
{
378+
return;
379+
}
380+
if (!RROutputSetPhysicalSize(output,
381+
monitor->physical_width, monitor->physical_height))
382+
{
383+
LLOGLN(0, ("%s: RROutputSetPhysicalSize failed", func));
384+
}
385+
}
386+
387+
/******************************************************************************/
388+
static Rotation
389+
rdpGetRotation(uint32_t orientation)
390+
{
391+
switch (orientation)
392+
{
393+
case 90:
394+
return RR_Rotate_90;
395+
case 180:
396+
return RR_Rotate_180;
397+
case 270:
398+
return RR_Rotate_270;
399+
default:
400+
return RR_Rotate_0;
401+
}
402+
}
403+
367404
/******************************************************************************/
368405
static RROutputPtr
369-
rdpRRAddOutput(rdpPtr dev, const char *aname, int x, int y, int width, int height)
406+
rdpRRAddOutput(rdpPtr dev, const char *aname, struct monitor_info *monitor)
370407
{
371408
RRModePtr mode;
372409
RRCrtcPtr crtc;
@@ -375,6 +412,10 @@ rdpRRAddOutput(rdpPtr dev, const char *aname, int x, int y, int width, int heigh
375412
char name[64];
376413
const int vfreq = 50;
377414
int i;
415+
int width = (monitor->right - monitor->left + 1);
416+
int height = (monitor->bottom - monitor->top + 1);
417+
int x = monitor->left;
418+
int y = monitor->top;
378419

379420
sprintf (name, "%dx%d", width, height);
380421
memset (&modeInfo, 0, sizeof(modeInfo));
@@ -416,6 +457,7 @@ rdpRRAddOutput(rdpPtr dev, const char *aname, int x, int y, int width, int heigh
416457
RRModeDestroy(mode);
417458
return 0;
418459
}
460+
rdpRRSetOutputPhysicalSize(__func__, output, monitor);
419461
if (!RROutputSetClones(output, NULL, 0))
420462
{
421463
LLOGLN(0, ("rdpRRAddOutput: RROutputSetClones failed"));
@@ -432,19 +474,24 @@ rdpRRAddOutput(rdpPtr dev, const char *aname, int x, int y, int width, int heigh
432474
{
433475
LLOGLN(0, ("rdpRRAddOutput: RROutputSetConnection failed"));
434476
}
435-
RRCrtcNotify(crtc, mode, x, y, RR_Rotate_0, NULL, 1, &output);
477+
RRCrtcNotify(crtc, mode, x, y, rdpGetRotation(monitor->orientation),
478+
NULL, 1, &output);
436479
return output;
437480
}
438481

439482
/******************************************************************************/
440483
static RROutputPtr
441484
rdpRRUpdateOutput(RROutputPtr output, RRCrtcPtr crtc,
442-
int x, int y, int width, int height)
485+
struct monitor_info *monitor)
443486
{
444487
RRModePtr mode;
445488
xRRModeInfo modeInfo;
446489
char name[64];
447490
const int vfreq = 50;
491+
int width = monitor->right - monitor->left + 1;
492+
int height = monitor->bottom - monitor->top + 1;
493+
int x = monitor->left;
494+
int y = monitor->top;
448495

449496
LLOGLN(0, ("rdpRRUpdateOutput:"));
450497
sprintf (name, "%dx%d", width, height);
@@ -465,7 +512,9 @@ rdpRRUpdateOutput(RROutputPtr output, RRCrtcPtr crtc,
465512
{
466513
LLOGLN(0, ("rdpRRUpdateOutput: RROutputSetModes failed"));
467514
}
468-
RRCrtcNotify(crtc, mode, x, y, RR_Rotate_0, NULL, 1, &output);
515+
rdpRRSetOutputPhysicalSize(__func__, output, monitor);
516+
RRCrtcNotify(crtc, mode, x, y, rdpGetRotation(monitor->orientation),
517+
NULL, 1, &output);
469518
RROutputChanged(output, 1);
470519
return output;
471520
}
@@ -516,14 +565,10 @@ rdpRRRemoveExtra(rrScrPrivPtr pRRScrPriv, int count)
516565

517566
/******************************************************************************/
518567
int
519-
rdpRRSetRdpOutputs(rdpPtr dev)
568+
rdpRRSetRdpOutputs(rdpPtr dev, rdpClientCon *clientCon)
520569
{
521570
rrScrPrivPtr pRRScrPriv;
522571
int index;
523-
int left;
524-
int top;
525-
int width;
526-
int height;
527572
char text[256];
528573
RROutputPtr output;
529574

@@ -532,29 +577,40 @@ rdpRRSetRdpOutputs(rdpPtr dev)
532577
pRRScrPriv->numCrtcs, pRRScrPriv->numOutputs, dev->monitorCount));
533578
if (dev->monitorCount <= 0)
534579
{
535-
left = 0;
536-
top = 0;
537-
width = dev->width;
538-
height = dev->height;
580+
struct monitor_info monitor;
581+
memset(&monitor, 0, sizeof(monitor));
582+
monitor.top = 0;
583+
monitor.left = 0;
584+
monitor.right = dev->width - 1;
585+
monitor.bottom = dev->height - 1;
586+
monitor.physical_width
587+
= clientCon->client_info.display_sizes.session_width;
588+
monitor.physical_height
589+
= clientCon->client_info.display_sizes.session_height;
590+
monitor.orientation = 0;
591+
monitor.desktop_scale_factor = 100;
592+
monitor.device_scale_factor = 100;
593+
539594
if (pRRScrPriv->numCrtcs > 0)
540595
{
541596
/* update */
542597
LLOGLN(0, ("rdpRRSetRdpOutputs: update output %d "
543-
"left %d top %d width %d height %d",
544-
0, left, top, width, height));
598+
"left %d top %d right %d bottom %d",
599+
0, monitor.left, monitor.top,
600+
monitor.right, monitor.bottom));
545601
output = rdpRRUpdateOutput(pRRScrPriv->outputs[0],
546602
pRRScrPriv->crtcs[0],
547-
left, top, width, height);
603+
&monitor);
548604
}
549605
else
550606
{
551607
/* add */
552608
LLOGLN(0, ("rdpRRSetRdpOutputs: add output %d "
553-
"left %d top %d width %d height %d",
554-
0, left, top, width, height));
609+
"left %d top %d right %d bottom %d",
610+
0, monitor.left, monitor.top,
611+
monitor.right, monitor.bottom));
555612
snprintf(text, 255, "rdp%d", 0);
556-
output = rdpRRAddOutput(dev, text,
557-
left, top, width, height);
613+
output = rdpRRAddOutput(dev, text, &monitor);
558614
}
559615
if (output == NULL)
560616
{
@@ -568,29 +624,28 @@ rdpRRSetRdpOutputs(rdpPtr dev)
568624
{
569625
for (index = 0; index < dev->monitorCount; index++)
570626
{
571-
left = dev->minfo[index].left;
572-
top = dev->minfo[index].top;
573-
width = dev->minfo[index].right - dev->minfo[index].left + 1;
574-
height = dev->minfo[index].bottom - dev->minfo[index].top + 1;
575627
if (index < pRRScrPriv->numCrtcs)
576628
{
577629
/* update */
578630
LLOGLN(0, ("rdpRRSetRdpOutputs: update output %d "
579-
"left %d top %d width %d height %d",
580-
index, left, top, width, height));
631+
"left %d top %d right %d bottom %d scale %d",
632+
index, dev->minfo[index].left, dev->minfo[index].top,
633+
dev->minfo[index].right, dev->minfo[index].bottom,
634+
dev->minfo[index].desktop_scale_factor));
581635
output = rdpRRUpdateOutput(pRRScrPriv->outputs[index],
582636
pRRScrPriv->crtcs[index],
583-
left, top, width, height);
637+
&dev->minfo[index]);
584638
}
585639
else
586640
{
587641
/* add */
588642
LLOGLN(0, ("rdpRRSetRdpOutputs: add output %d "
589-
"left %d top %d width %d height %d",
590-
index, left, top, width, height));
643+
"left %d top %d right %d bottom %d scale %d",
644+
index, dev->minfo[index].left, dev->minfo[index].top,
645+
dev->minfo[index].right, dev->minfo[index].bottom,
646+
dev->minfo[index].desktop_scale_factor));
591647
snprintf(text, 255, "rdp%d", index);
592-
output = rdpRRAddOutput(dev, text,
593-
left, top, width, height);
648+
output = rdpRRAddOutput(dev, text, &dev->minfo[index]);
594649
}
595650
if ((output != 0) && (dev->minfo[index].is_primary))
596651
{

module/rdpRandR.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ extern _X_EXPORT Bool
6161
rdpRRSetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea,
6262
BoxPtr trackingArea, INT16* border);
6363
extern _X_EXPORT int
64-
rdpRRSetRdpOutputs(rdpPtr dev);
64+
rdpRRSetRdpOutputs(rdpPtr dev, rdpClientCon *clientCon);
6565

6666
#endif

0 commit comments

Comments
 (0)