Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
42 magnus 1
Description: Make autoscaling work.
2
 1) Add a StructureNotifyMask event handler to be notified of windows resizings,
3
    rather than checking for size changes twice every second in the Expose handler.
4
    Using the size of "form" seems to work best. Skip checking for pressed mouse
5
    buttons - those shouldn't matter in this situation, and the old code aborted
6
    if modifier keys were pressed or Caps Lock or Num Lock active.
7
 2) Avoid freaking out if the windows haven't been realized yet -
8
    instead use scale factor 1. This prevented setting -scale auto
9
    on the command line from working.
10
Bug: https://sourceforge.net/p/ssvnc/bugs/5/
11
Bug-Debian: https://bugs.debian.org/801804
12
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ssvnc/+bug/1312966
13
 
14
--- a/vnc_unixsrc/vncviewer/desktop.c
15
+++ b/vnc_unixsrc/vncviewer/desktop.c
16
@@ -55,6 +55,7 @@ static Cursor CreateDotCursor();
17
 static void CopyBGR233ToScreen(CARD8 *buf, int x, int y, int width,int height);
18
 static void HandleBasicDesktopEvent(Widget w, XtPointer ptr, XEvent *ev,
19
                                    Boolean *cont);
20
+static void HandleResizeEvent(Widget w, XtPointer ptr, XEvent *ev, Boolean *cont);
21
 
22
 static void CopyBGR565ToScreen(CARD16 *buf, int x, int y, int width,int height);
23
 
24
@@ -110,6 +111,8 @@ void get_scale_values(double *fx, double
25
                if (w > 32 && h > 32) {
26
                        frac_x = ((double) w) / ((double) xmax);
27
                        frac_y = ((double) h) / ((double) ymax);
28
+               } else {
29
+                   frac_x = frac_y = 1.0;
30
                }
31
        }
32
        if (frac_x < 0.0 && sscanf(s, "%lf", &f) == 1) {
33
@@ -456,7 +459,11 @@ void create_image() {
34
                                        scale_x = w;
35
                                        scale_y = h;
36
 
37
-                                       XtVaSetValues(toplevel, XtNmaxWidth, w, XtNmaxHeight, hyc, NULL);
38
+                                       if (!strcmp(appData.scale, "auto")) {
39
+                                               XtVaSetValues(toplevel, XtNmaxWidth, dpyWidth, XtNmaxHeight, dpyHeight, NULL);
40
+                                       } else {
41
+                                               XtVaSetValues(toplevel, XtNmaxWidth, w, XtNmaxHeight, hyc, NULL);
42
+                                       }
43
 
44
                                        h2 = scale_round(si.framebufferHeight, frac_y);
45
                                        XtVaSetValues(desktop,  XtNwidth, w, XtNheight, h2, NULL);
46
@@ -561,6 +568,8 @@ DesktopInitBeforeRealization()
47
 
48
        XtAddEventHandler(desktop, LeaveWindowMask|EnterWindowMask|ExposureMask,
49
            True, HandleBasicDesktopEvent, NULL);
50
+       XtAddEventHandler(form, StructureNotifyMask,
51
+           False, HandleResizeEvent, NULL);
52
 
53
        if (appData.yCrop) {
54
                int hm;
55
@@ -707,39 +716,6 @@ void check_things() {
56
        dpyWidth  = WidthOfScreen(DefaultScreenOfDisplay(dpy));
57
        dpyHeight = HeightOfScreen(DefaultScreenOfDisplay(dpy));
58
 
59
-       if (appData.scale != NULL) {
60
-               static Dimension last_w = 0, last_h = 0;
61
-               static double last_resize = 0.0;
62
-               Dimension w, h;
63
-               if (last_w == 0) {
64
-                       XtVaGetValues(toplevel, XtNwidth, &last_w, XtNheight, &last_h, NULL);
65
-                       last_resize = now;
66
-               }
67
-               if (now < last_resize + 0.5) {
68
-                       ;
69
-               } else if (appData.fullScreen) {
70
-                       ;
71
-               } else if (!strcmp(appData.scale, "auto")) {
72
-                       XtVaGetValues(toplevel, XtNwidth, &w, XtNheight, &h, NULL);
73
-                       if (w < 32 || h < 32)  {
74
-                               ;
75
-                       } else if (last_w != w || last_h != h) {
76
-                               Window rr, cr, r = DefaultRootWindow(dpy);
77
-                               int rx, ry, wx, wy;
78
-                               unsigned int mask;
79
-                               /* make sure mouse buttons not pressed */
80
-                               if (XQueryPointer(dpy, r, &rr, &cr, &rx, &ry, &wx, &wy, &mask)) {
81
-                                       if (mask == 0) {
82
-                                               rescale_image();
83
-                                               last_w = w;
84
-                                               last_h = h;
85
-                                               last_resize = dnow();
86
-                                       }
87
-                               }
88
-                       }
89
-               }
90
-       }
91
-
92
        last = dnow();
93
 }
94
 
95
@@ -1546,6 +1522,22 @@ void releaseAllPressedModifiers(void) {
96
 
97
 #define PR_EXPOSE fprintf(stderr, "Expose: %04dx%04d+%04d+%04d %04d/%04d/%04d now: %8.4f rescale: %8.4f fullscreen: %8.4f\n", width, height, x, y, si.framebufferWidth, appData.yCrop, si.framebufferHeight, now - start_time, now - last_rescale, now - last_fullscreen);
98
 
99
+static void
100
+HandleResizeEvent(Widget wdg, XtPointer ptr, XEvent *ev, Boolean *cont)
101
+{
102
+    static Dimension last_w = 0, last_h = 0;
103
+    Dimension w, h;
104
+    
105
+    if (ev->type == ConfigureNotify && !appData.fullScreen
106
+       && appData.scale != NULL && !strcasecmp(appData.scale, "auto")) {
107
+       XtVaGetValues(form, XtNwidth, &w, XtNheight, &h, NULL);
108
+       if (w != last_w || h != last_h) {
109
+           rescale_image();
110
+           last_w = w;
111
+           last_h = h;
112
+       }
113
+    }
114
+}
115
 /*
116
  * HandleBasicDesktopEvent - deal with expose and leave events.
117
  */