mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-12 07:13:23 +00:00
x11/skia: Add Display::setIcons() impl
This commit is contained in:
parent
c5f6299df4
commit
6dd025ae7b
@ -139,7 +139,9 @@ void SkiaDisplay::setTitleBar(const std::string& title)
|
||||
|
||||
void SkiaDisplay::setIcons(const SurfaceList& icons)
|
||||
{
|
||||
// TODO copy the Allegro impl
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
m_window.setIcons(icons);
|
||||
#endif
|
||||
}
|
||||
|
||||
NativeCursor SkiaDisplay::nativeMouseCursor()
|
||||
|
@ -201,6 +201,46 @@ void X11Window::setTitle(const std::string& title)
|
||||
XSetWMName(m_display, m_window, &prop);
|
||||
}
|
||||
|
||||
void X11Window::setIcons(const SurfaceList& icons)
|
||||
{
|
||||
if (!m_display || !m_window)
|
||||
return;
|
||||
|
||||
bool first = true;
|
||||
for (Surface* icon : icons) {
|
||||
const int w = icon->width();
|
||||
const int h = icon->height();
|
||||
|
||||
SurfaceFormatData format;
|
||||
icon->getFormat(&format);
|
||||
|
||||
std::vector<unsigned long> data(w*h+2);
|
||||
int i = 0;
|
||||
data[i++] = w;
|
||||
data[i++] = h;
|
||||
for (int y=0; y<h; ++y) {
|
||||
const uint32_t* p = (const uint32_t*)icon->getData(0, y);
|
||||
for (int x=0; x<w; ++x, ++p) {
|
||||
uint32_t c = *p;
|
||||
data[i++] =
|
||||
(((c & format.blueMask ) >> format.blueShift ) ) |
|
||||
(((c & format.greenMask) >> format.greenShift) << 8) |
|
||||
(((c & format.redMask ) >> format.redShift ) << 16) |
|
||||
(((c & format.alphaMask) >> format.alphaShift) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
Atom _NET_WM_ICON = XInternAtom(m_display, "_NET_WM_ICON", False);
|
||||
XChangeProperty(
|
||||
m_display, m_window, _NET_WM_ICON, XA_CARDINAL, 32,
|
||||
first ? PropModeReplace:
|
||||
PropModeAppend,
|
||||
(const unsigned char*)&data[0], data.size());
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Size X11Window::clientSize() const
|
||||
{
|
||||
Window root;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "gfx/fwd.h"
|
||||
#include "gfx/size.h"
|
||||
#include "she/native_cursor.h"
|
||||
#include "she/surface_list.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
@ -34,6 +35,7 @@ public:
|
||||
void setScale(const int scale);
|
||||
|
||||
void setTitle(const std::string& title);
|
||||
void setIcons(const SurfaceList& icons);
|
||||
|
||||
gfx::Size clientSize() const;
|
||||
gfx::Size restoredSize() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user