Commit Graph

24 Commits

Author SHA1 Message Date
Emmanuel Gil Peyrot 44fc1be913 xwm: Fix icon surface ownership
The cairo surface used for the icon must be completely given to the
frame as soon as said frame has been created.  To prevent both the
window and the frame from sharing ownership of the icon, we set
window->icon_surface back to NULL right after creating or changing the
frame, only keeping it there when no frame has been created yet.

Fixes https://lists.freedesktop.org/archives/wayland-devel/2018-January/036655.html
Reported-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2018-02-09 17:01:09 +00:00
Emmanuel Gil Peyrot 6b58ea8c43 xwm: Add icon support to the frame
This fetches the _NET_WM_ICON property of the X11 window, and use the
first image found as the frame icon.

This has been tested with various X11 programs, and improves usability
and user-friendliness a bit.

Changes since v1:
- Changed frame_button_create() to use
  frame_button_create_from_surface() internally.
- Removed a check that should never have been commited.

Changes since v2:
- Request UINT32_MAX items instead of 2048, to avoid cutting valid
  icons.
- Strengthen checks against malformed input.
- Handle XCB_PROPERTY_DELETE to remove the icon.
- Schedule a repaint if the icon changed.

Changes since v3:
- Keep the previous Cairo surface until the new one has been
  successfully loaded.
- Use uint32_t for cardinals.  Unsigned is the same type except on
  16-bit machines, but uint32_t is clearer.
- Declare length as uint32_t too, like in xcb_get_property_reply_t.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2018-01-18 12:24:19 +00:00
Louis-Francis Ratté-Boulianne 864e39bf96 xwm: Deal with title in a smarter way when there isn't enough space
The title in X11 windows and Wayland application using Weston toy
toolkit were placing the title in a very naive fashion. It was
only try to center the string in the title bar. This patch:

 * Makes sure the title isn't renderer underneath buttons;
 * Move the title to the left if the titlebar isn't large enough;
 * Clip the end of the title if needed.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-05 14:09:24 +00:00
Quentin Glidic d8b17bc452
share/cairo-util: Use wl_pointer_button_state enum directly
This silences two warnings:

clients/window.c:2450:20: warning: implicit conversion from enumeration
type 'enum wl_pointer_button_state' to different enumeration type 'enum
frame_button_state' [-Wenum-conversion]
                                              button, state);
                                                      ^~~~~

clients/window.c:2453:15: warning: implicit conversion from enumeration
type 'enum wl_pointer_button_state' to different enumeration type 'enum
frame_button_state' [-Wenum-conversion]
                                                button, state);
                                                        ^~~~~

Warning produced by Clang 3.8.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
2016-09-24 11:52:56 +02:00
Derek Foreman 9690641bfc cairo-util: return theme location from frame_touch_down
I'll be using this in a follow up patch that adds touch input to weston's
wayland backend.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
2015-12-08 13:04:34 -06:00
Bryce Harrington 6c6164c5ba shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
Murray Calavera 883ac02d22 Whitespace corrections
Signed-off-by: Murray Calavera <murray.calavera@gmail.com>
2015-06-06 12:39:51 -07:00
Marek Chalupa 0d7fe8d925 toytoolkit: rename tile_mask to render_shadow
This function is used and clearly designed only for drawing the shadows.
Rename it so that it has name after what it does and also move some
common code into the function.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-19 15:39:36 +02:00
Xiong Zhang 382de46a2f clients: Maximize window when double touch on title bar
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
2014-09-22 10:19:44 +03:00
Xiong Zhang bfb4ade1a0 clients: Maximize window when double click on title bar
Signed-off-by: Xiong Zhang <panda0626@gmail.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-04 17:11:22 +03:00
Boyan Ding 850a514137 cairo-util: Draw solid titlebar for frames with only buttons
Previously geometry was changed to leave space for titlebar if a frame
has only buttons but no title. This patch fixes theme_render_frame to
avoid transparent titlebar.

Signed-off-by: Boyan Ding <stu_dby@126.com>
2014-08-19 16:45:15 +03:00
Jasper St. Pierre 7407345446 xdg-shell: Add set_margin request
This is used to figure out the size of "invisible" decorations, which we'll
use to better know the visible extents of the surface, which we can use for
constraining, titlebars, and more.
2014-02-06 13:05:03 -08:00
Jason Ekstrand 0bdd58f6c0 cairo-util: Rework frame button handling
This makes button handling more correct concerning drags.  Also,
frame_pointer_button returns the original button location in the case of a
release.  This makes filtering of button events much easier for users of
the cair-util frame code.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-07 16:35:06 -08:00
Kristian Høgsberg 89f4bc4fc4 window.c: Don't put titlebars on menu windows 2013-10-23 22:12:13 -07:00
Kristian Høgsberg c680e90489 window.c: Use frame code for drawing menus
This gives us a nice frame and drop shadows for the menus.
2013-10-23 21:49:30 -07:00
Jason Ekstrand 3f66cf92ed Use cairo-util frame in tinytoolkit
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-14 12:27:55 -07:00
Jason Ekstrand 01c9ec3477 Add decoration frame support to cairo-util
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 22:12:16 -07:00
Kristian Høgsberg c0bf8173dd shared: Add out-of-memory handling to theme_create() 2013-07-25 15:54:20 -07:00
Kristian Høgsberg 3c2360ff9d Add new shared/image-loader.h to separate include dependencies
Before, cairo-util.h would combine pixman and cairo includes.  X11 and
Wayland compositors uses this to load an image as a pixman_image_t but are
forced to include cairo headers.  Clients use load_cairo_surface to
load images as cairo_surface_t's, but are forced to include pixman.h.

We move the load_image pixman prototype to its own header, so compositors
can get at the pixman prototype without including cairo.h and clients
can include the cairo based function without including pixman.h.
2013-01-28 16:02:04 -05:00
Pekka Paalanen 4fbb65372e Fix build warnings from image_loader
Fix the following build warnings, and the build failures due to the
warning fixes:

  CC     libshared_cairo_la-image-loader.lo
image-loader.c:369:1: warning: no previous prototype for 'load_image'

  CC     x11_backend_la-compositor-x11.lo
compositor-x11.c: In function 'x11_output_set_icon':
compositor-x11.c:396:2: warning: implicit declaration of function 'load_image'
compositor-x11.c:396:8: warning: assignment makes pointer from integer without a cast

  CC     wayland_backend_la-compositor-wayland.lo
compositor-wayland.c: In function 'create_border':
compositor-wayland.c:97:2: warning: implicit declaration of function 'load_image'
compositor-wayland.c:97:8: warning: assignment makes pointer from integer without a cast

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-30 14:24:00 -05:00
Kristian Høgsberg 6006ecb497 configure.ac: Don't link weston to cairo or image libraries
We were pulling in cairo and the image loading libraries through libshared.
Split out libshared into a core libshared and a libshared-cairo that
pulls in the extra libraries.
2012-11-29 13:32:11 -05:00
Scott Moreau c6a7e4b277 toytoolkit: Don't draw shadows for maximized windows.
Add THEME_FRAME_MAXIMIZED flag so the theming system can know not to draw
shadows for maximized windows. This allows maximized surfaces' content to be
sized and placed in a more expectable fashion.
2012-10-10 11:23:41 -04:00
Kristian Høgsberg f96e6c00d9 Share code to to classify pointer location in frame 2012-05-22 16:38:53 -04:00
Kristian Høgsberg 5a315bc72d Move cairo-util to shared/ 2012-05-15 22:33:43 -04:00