Re: [gtk-vnc-devel] Scaling down
- From: Jonh Wendell <jwendell gnome org>
- To: "Daniel P. Berrange" <berrange redhat com>
- Cc: gtk-vnc-devel List <gtk-vnc-devel lists sourceforge net>
- Subject: Re: [gtk-vnc-devel] Scaling down
- Date: Fri, 27 Jun 2008 11:57:16 -0300
Em Qui, 2008-06-05 às 16:27 +0100, Daniel P. Berrange escreveu:
> On Thu, Jun 05, 2008 at 10:08:32AM -0500, Anthony Liguori wrote:
> > Daniel P. Berrange wrote:
> > >
> > >Yes, but even when scaling is enabled, when first connecting to the
> > >server it will be in 1:1 mode, which GTK-VNC optimizes to use GDK and
> > >thus calls set_size_request(). Once that's called, even though you can
> > >now scale the display you can't scale it smaller due to this initial
> > >call.
> > >
> > >We probably need to conditionalize set_size_request() based on whether
> > >the scaling flag is enabled or not, instead of whether we're drawing
> > >when GL vs GDK.
> > >
> >
> > The scaling flag can be enabled very early if that's desired. Note that
> > enabling scaling doesn't automatically mean you scale. If the ratio is
> > 1:1, it still uses GDK, it just doesn't do set_size_request().
> >
> > So we already have this behavior.
>
> I don't believe we do.
>
> in the do_resize() method
>
> if (priv->gl_enabled)
> setup_gl_image(obj, width, height);
> else
> setup_gdk_image(obj, width, height);
>
> And the last line in setup_gdk_image() is
>
> gtk_widget_set_size_request(GTK_WIDGET(obj), width, height);
>
> So, if scaling is enabled and it is 1:1, then AFAICT, we will always
> set the size request explicitly.
>
> > If a user conditionally enables scaling, they should set_size_request(1,
> > 1) IFF they haven't set window_set_resizable(False). I've always
> > wondered if there was an unset_size_request() type operation that puts
> > you back in the mode before any size request has been made. That would
> > really be ideal. I've never been able to figure that out though.
>
> I guess that's just a case of checking to see what the default size
> values are in GTK before being set. I imagine they're either 1,1 or
> -1, -1.
>
> Regards,
> Daniel.
Attached is a patch to add this feature to gtk-vnc. It:
- Adds a new symbol: vnc_display_set_always_scaling which accepts a
boolean value and tell us whether to do the size_scale().
- Changes the on_resize() event so that it works nice when we are using
scaling
I have tested it with vinagre and it's working as expected.
Comments?
--
Jonh Wendell
www.bani.com.br
diff -r 6a869ca98aeb src/libgtk-vnc_sym.version
--- a/src/libgtk-vnc_sym.version Thu Jun 05 14:11:20 2008 -0300
+++ b/src/libgtk-vnc_sym.version Fri Jun 27 11:54:34 2008 -0300
@@ -50,6 +50,9 @@
vnc_display_get_option_group;
+ vnc_display_set_always_scaling;
+ vnc_display_get_always_scaling;
+
local:
*;
};
diff -r 6a869ca98aeb src/vncdisplay.c
--- a/src/vncdisplay.c Thu Jun 05 14:11:20 2008 -0300
+++ b/src/vncdisplay.c Fri Jun 27 11:54:34 2008 -0300
@@ -82,6 +82,7 @@ struct _VncDisplayPrivate
gboolean allow_lossy;
gboolean allow_scaling;
gboolean shared_flag;
+ gboolean always_scaling;
GSList *preferable_auths;
};
@@ -123,7 +124,8 @@ enum
PROP_NAME,
PROP_LOSSY_ENCODING,
PROP_SCALING,
- PROP_SHARED_FLAG
+ PROP_SHARED_FLAG,
+ PROP_ALWAYS_SCALING
};
/* Signals */
@@ -203,6 +205,9 @@ vnc_display_get_property (GObject *ob
case PROP_SHARED_FLAG:
g_value_set_boolean (value, vnc->priv->shared_flag);
break;
+ case PROP_ALWAYS_SCALING:
+ g_value_set_boolean (value, vnc->priv->always_scaling);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -239,6 +244,9 @@ vnc_display_set_property (GObject *
break;
case PROP_SHARED_FLAG:
vnc_display_set_shared_flag (vnc, g_value_get_boolean (value));
+ break;
+ case PROP_ALWAYS_SCALING:
+ vnc_display_set_always_scaling (vnc, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -892,7 +900,10 @@ static void setup_gdk_image(VncDisplay *
priv->fb.data = (uint8_t *)priv->image->mem;
priv->fb.byte_order = priv->image->byte_order == GDK_LSB_FIRST ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
- gtk_widget_set_size_request(GTK_WIDGET(obj), width, height);
+#if WITH_GTKGLEXT
+ if (!priv->always_scaling || !priv->allow_scaling)
+#endif
+ gtk_widget_set_size_request(GTK_WIDGET(obj), width, height);
}
#if WITH_GTKGLEXT
@@ -1058,11 +1069,6 @@ static gboolean do_resize(void *opaque,
return TRUE;
}
-static gboolean on_resize(void *opaque, int width, int height)
-{
- return do_resize(opaque, width, height, FALSE);
-}
-
static gboolean on_pixel_format(void *opaque,
struct gvnc_pixel_format *fmt G_GNUC_UNUSED)
{
@@ -1208,7 +1214,8 @@ static void rescale_display(VncDisplay *
if (priv->allow_scaling &&
(priv->fb.width != width ||
- priv->fb.height != height))
+ priv->fb.height != height ||
+ priv->always_scaling))
scale_display(obj, width, height);
else if (priv->gl_enabled) {
void *data;
@@ -1243,6 +1250,26 @@ static gboolean configure_event(GtkWidge
return FALSE;
}
#endif
+
+static gboolean on_resize(void *opaque, int width, int height)
+{
+#if WITH_GTKGLEXT
+ VncDisplay *obj = VNC_DISPLAY(opaque);
+ GtkWidget *widget = GTK_WIDGET(opaque);
+
+ if (obj->priv->always_scaling && obj->priv->allow_scaling) {
+ gint w, h;
+
+ do_resize(obj, width, height, FALSE);
+ gdk_drawable_get_size(widget->window, &w, &h);
+ rescale_display(obj, w, h);
+ gtk_widget_queue_draw_area(widget, 0, 0, w, h);
+ return TRUE;
+ }
+ else
+#endif
+ return do_resize(opaque, width, height, FALSE);
+}
static gboolean on_pointer_type_change(void *opaque, int absolute)
{
@@ -1926,6 +1953,17 @@ static void vnc_display_class_init(VncDi
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class,
+ PROP_ALWAYS_SCALING,
+ g_param_spec_boolean ( "always-scaling",
+ "Always Scaling",
+ "Whether we always use scaling, so, we do not define the widget size",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
signalCredParam = g_param_spec_enum("credential",
"credential",
@@ -2142,6 +2180,7 @@ static void vnc_display_init(VncDisplay
priv->grab_keyboard = FALSE;
priv->local_pointer = FALSE;
priv->shared_flag = FALSE;
+ priv->always_scaling = FALSE;
priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (GVNC_AUTH_VENCRYPT));
priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (GVNC_AUTH_TLS));
@@ -2399,6 +2438,19 @@ gboolean vnc_display_set_scaling(VncDisp
}
#endif
+void vnc_display_set_always_scaling(VncDisplay *obj, gboolean enabled)
+{
+ g_return_if_fail (VNC_IS_DISPLAY (obj));
+ obj->priv->always_scaling = enabled;
+}
+
+gboolean vnc_display_get_always_scaling(VncDisplay *obj)
+{
+ g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+
+ return obj->priv->always_scaling;
+}
+
gboolean vnc_display_get_scaling(VncDisplay *obj)
{
g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
diff -r 6a869ca98aeb src/vncdisplay.h
--- a/src/vncdisplay.h Thu Jun 05 14:11:20 2008 -0300
+++ b/src/vncdisplay.h Fri Jun 27 11:54:34 2008 -0300
@@ -116,6 +116,9 @@ gboolean vnc_display_set_scaling(VncDisp
gboolean vnc_display_set_scaling(VncDisplay *obj, gboolean enable);
gboolean vnc_display_get_scaling(VncDisplay *obj);
+void vnc_display_set_always_scaling(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_always_scaling(VncDisplay *obj);
+
void vnc_display_set_shared_flag(VncDisplay *obj, gboolean shared);
gboolean vnc_display_get_shared_flag(VncDisplay *obj);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]