From 38e6cab1d81c343406483ca41487228c2d2690e3 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Tue, 19 Jun 2007 09:10:37 +0000 Subject: [PATCH] 2007-06-19 Matthew Allum * clutter/clutter-stage.c: * clutter/clutter-stage.h: * clutter/glx/clutter-stage-glx.c: * clutter/sdl/clutter-stage-sdl.c: Add window title setting/getting functionality. * clutter/clutter-event.c: (clutter_key_event_unicode): Remove uneeded convert case call. * clutter/cogl/gl/cogl.c: (cogl_rectangle) Use parameters correctly for underlying GL rect call. * tests/test-entry.c: Add a window title. --- ChangeLog | 17 ++++++++ clutter/clutter-event.c | 6 +-- clutter/clutter-stage.c | 73 +++++++++++++++++++++++++++++++++ clutter/clutter-stage.h | 6 +++ clutter/cogl/gl/cogl.c | 2 +- clutter/glx/clutter-stage-glx.c | 36 +++++++++++++++- clutter/sdl/clutter-stage-sdl.c | 8 ++++ tests/test-entry.c | 3 +- 8 files changed, 143 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77acca9e7..ac1e41da7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2007-06-19 Matthew Allum + + * clutter/clutter-stage.c: + * clutter/clutter-stage.h: + * clutter/glx/clutter-stage-glx.c: + * clutter/sdl/clutter-stage-sdl.c: + Add window title setting/getting functionality. + + * clutter/clutter-event.c: (clutter_key_event_unicode): + Remove uneeded convert case call. + + * clutter/cogl/gl/cogl.c: (cogl_rectangle) + Use parameters correctly for underlying GL rect call. + + * tests/test-entry.c: + Add a window title. + 2007-06-18 Matthew Allum * clutter/sdl/clutter-event-sdl.c: diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index aac9674fd..187574702 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -248,11 +248,7 @@ clutter_key_event_unicode (ClutterKeyEvent *keyev) { g_return_val_if_fail (keyev != NULL, 0); - if ((keyev->modifier_state & CLUTTER_SHIFT_MASK) || - (keyev->modifier_state & CLUTTER_LOCK_MASK)) - return g_unichar_toupper (clutter_keysym_to_unicode (keyev->keyval)); - else - return clutter_keysym_to_unicode (keyev->keyval); + return clutter_keysym_to_unicode (keyev->keyval); } /** diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 034c67631..18968ceee 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -61,6 +61,8 @@ struct _ClutterStagePrivate guint is_fullscreen : 1; guint is_offscreen : 1; guint is_cursor_visible : 1; + + gchar *title; }; enum @@ -72,6 +74,7 @@ enum PROP_OFFSCREEN, PROP_CURSOR_VISIBLE, PROP_PERSPECTIVE, + PROP_TITLE, }; enum @@ -147,6 +150,9 @@ clutter_stage_set_property (GObject *object, case PROP_PERSPECTIVE: clutter_stage_set_perspectivex (stage, g_value_get_boxed (value)); break; + case PROP_TITLE: + clutter_stage_set_title (stage, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -186,6 +192,9 @@ clutter_stage_get_property (GObject *object, clutter_stage_get_perspectivex (stage, &perspective); g_value_set_boxed (value, &perspective); break; + case PROP_TITLE: + g_value_set_string (value, priv->title); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -240,6 +249,22 @@ clutter_stage_class_init (ClutterStageClass *klass) "The color of the main stage", CLUTTER_TYPE_COLOR, CLUTTER_PARAM_READWRITE)); + + /** + * ClutterStage:title: + * + * The stages title - usually displayed in stage windows title decorations. + * + * Since: 0.4 + */ + g_object_class_install_property + (gobject_class, PROP_TITLE, + g_param_spec_string ("title", + "Title", + "Stage Title", + NULL, + CLUTTER_PARAM_READWRITE)); + /** * ClutterStage::event: * @stage: the actor which received the event @@ -855,6 +880,54 @@ clutter_stage_event (ClutterStage *stage, return res; } +/** + * clutter_stage_set_title + * @stage: A #ClutterStage + * @title: A utf8 string for the stage windows title. + * + * Sets the stage title. + * + * Since 0.4 + **/ +void +clutter_stage_set_title (ClutterStage *stage, + const gchar *title) +{ + ClutterStagePrivate *priv; + + g_return_if_fail (CLUTTER_IS_STAGE (stage)); + + priv = stage->priv; + + g_free (priv->title); + priv->title = g_strdup (title); + + if (CLUTTER_STAGE_GET_CLASS (stage)->set_title) + CLUTTER_STAGE_GET_CLASS (stage)->set_title (stage, priv->title); + + g_object_notify (G_OBJECT (stage), "title"); +} + +/** + * clutter_stage_get_title + * @stage: A #ClutterStage + * + * Gets the stage title. + * + * Return value: pointer to the title string for the stage. The + * returned string is owned by the actor and should not + * be modified or freed. + * + * Since: 0.4 + **/ +G_CONST_RETURN gchar * +clutter_stage_get_title (ClutterStage *stage) +{ + g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL); + + return stage->priv->title; +} + /*** Perspective boxed type ******/ /** diff --git a/clutter/clutter-stage.h b/clutter/clutter-stage.h index 08d2cc47f..c32dcedc6 100644 --- a/clutter/clutter-stage.h +++ b/clutter/clutter-stage.h @@ -90,6 +90,8 @@ struct _ClutterStageClass gint y, gint width, gint height); + void (* set_title) (ClutterStage *stage, + const gchar *title); /* signals */ void (* event) (ClutterStage *stage, @@ -169,6 +171,10 @@ GdkPixbuf * clutter_stage_snapshot (ClutterStage *stage, gboolean clutter_stage_event (ClutterStage *stage, ClutterEvent *event); +void clutter_stage_set_title (ClutterStage *stage, + const gchar *title); +G_CONST_RETURN gchar *clutter_stage_get_title (ClutterStage *stage); + G_END_DECLS #endif /* __CLUTTER_STAGE_H__ */ diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c index eaeaefa43..a71f9025d 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -415,7 +415,7 @@ cogl_texture_sub_image_2d (COGLenum target, void cogl_rectangle (gint x, gint y, guint width, guint height) { - GE( glRecti (x,y ,width, height) ); + GE( glRecti (x, y, x + width, y + height) ); } /* FIXME: Should use ClutterReal or Fixed */ diff --git a/clutter/glx/clutter-stage-glx.c b/clutter/glx/clutter-stage-glx.c index 2e8e3d2e6..43d445017 100644 --- a/clutter/glx/clutter-stage-glx.c +++ b/clutter/glx/clutter-stage-glx.c @@ -441,11 +441,44 @@ clutter_stage_glx_set_cursor_visible (ClutterStage *stage, } } +static void +clutter_stage_glx_set_title (ClutterStage *stage, + const gchar *title) +{ + ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (stage); + Atom atom_NET_WM_NAME, atom_UTF8_STRING; + + if (stage_glx->xwin == None) + return; + + /* FIXME: pre create these to avoid too many round trips */ + atom_NET_WM_NAME = XInternAtom (stage_glx->xdpy, "_NET_WM_NAME", False); + atom_UTF8_STRING = XInternAtom (stage_glx->xdpy, "UTF8_STRING", False); + + if (title == NULL) + { + XDeleteProperty (stage_glx->xdpy, + stage_glx->xwin, + atom_NET_WM_NAME); + } + else + { + XChangeProperty (stage_glx->xdpy, + stage_glx->xwin, + atom_NET_WM_NAME, + atom_UTF8_STRING, + 8, + PropModeReplace, + (unsigned char*)title, + (int)strlen(title)); + } +} + static void clutter_stage_glx_set_offscreen (ClutterStage *stage, gboolean offscreen) { - + /* Do nothing ? */ } static void @@ -548,6 +581,7 @@ clutter_stage_glx_class_init (ClutterStageGLXClass *klass) stage_class->set_cursor_visible = clutter_stage_glx_set_cursor_visible; stage_class->set_offscreen = clutter_stage_glx_set_offscreen; stage_class->draw_to_pixbuf = clutter_stage_glx_draw_to_pixbuf; + stage_class->set_title = clutter_stage_glx_set_title; } static void diff --git a/clutter/sdl/clutter-stage-sdl.c b/clutter/sdl/clutter-stage-sdl.c index 54c29799f..8d7a0ff8e 100644 --- a/clutter/sdl/clutter-stage-sdl.c +++ b/clutter/sdl/clutter-stage-sdl.c @@ -171,6 +171,13 @@ clutter_stage_sdl_draw_to_pixbuf (ClutterStage *stage, G_OBJECT_TYPE_NAME (stage)); } +static void +clutter_stage_sdl_set_title (ClutterStage *stage, + const gchar *title) +{ + SDL_WM_SetCaption (title, NULL); +} + static void clutter_stage_sdl_dispose (GObject *gobject) { @@ -201,6 +208,7 @@ clutter_stage_sdl_class_init (ClutterStageSDLClass *klass) stage_class->set_cursor_visible = clutter_stage_sdl_set_cursor_visible; stage_class->set_offscreen = clutter_stage_sdl_set_offscreen; stage_class->draw_to_pixbuf = clutter_stage_sdl_draw_to_pixbuf; + stage_class->set_title = clutter_stage_sdl_set_title; } static void diff --git a/tests/test-entry.c b/tests/test-entry.c index 3c232751d..e392ead08 100644 --- a/tests/test-entry.c +++ b/tests/test-entry.c @@ -40,7 +40,8 @@ main (int argc, char *argv[]) clutter_actor_set_size (stage, 800, 600); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - + clutter_stage_set_title (stage, "ClutterEntry Test"); + entry = clutter_entry_new_with_text ("Sans 14", "Type something, be sure to use the " "left/right arrow keys to move the "