Compare commits

..

18 Commits

Author SHA1 Message Date
Matthias Clasen eea6087f49 gridview: Reorganize size_allocate a bit more
Treat headers more like multirow tiles, and
footers more like regular items. Also, explicitly
set the height of all tiles to 0 at the outset,
so we have a certain way to know which tiles have
already had their size set to row_height.
2023-05-27 22:43:01 -04:00
Matthias Clasen 2e6e952c2e gridview: Don't consider headers for height
When determining the height of unknown items,
don't throw headers into the mix. They are
different.
2023-05-27 22:43:01 -04:00
Matthias Clasen 284f087429 testsuite: Make checks match
The gridview tests were not using the same
assertions as the code in GtkGridView. Make
them match, so the tests pass.
2023-05-27 22:43:01 -04:00
Matthias Clasen 9ee508e768 gridview: Make rubberband selection section-aware
Compute the right items to include in a rectangular
selection even if it stretches across section boundaries.

This code currently does the simplest thing that can
work. If it turns out to be a problem for big selections,
we can try to make it smarter.
2023-05-27 22:43:01 -04:00
Matthias Clasen 1a320a9aa3 gridview: Make focus movement section-aware
Make up-down focus movements preserve the column
across section boundaries.

This code does the simplest thing that can work.
If this turns out to be a problem, it can be
made smarter.

Note that the code currently prefers to jump over
short sections to preserve the column. If there
are many short sections, this not be desired,
and we may want to make it tweakable.
2023-05-27 22:43:01 -04:00
Matthias Clasen e4133ff1de gridview: Fix measure with sections
We must not include the header width when
determining the column width, but we do
want to take it into account when finding
the overall gridview width.
2023-05-27 22:43:01 -04:00
Matthias Clasen 98e99a075c gridview: Make helpers section-aware
Make get_column_for_position and is_multirow_tile
take sections into account.
2023-05-27 22:43:01 -04:00
Matthias Clasen 0891a0dee7 gridview: Add a section helper 2023-05-27 22:43:01 -04:00
Matthias Clasen 12af6ad1d4 gridview: Always set header and footer size
Update tile allocation for headers and foots in cases
where we go from having headers to not having headers.

Before this commit, turning sections off in testsections
would leave the global header and footer with some empty
space allocated.
2023-05-27 22:43:01 -04:00
Matthias Clasen f5ba7d0da7 gridview: Allocate headers
Allocate the right amount of space to headers and footers
to make sections break the grid in the expected way.
2023-05-27 22:43:01 -04:00
Matthias Clasen a02a765703 gridview: Copy section plumbing
Add a header factory, and implement prepare_section and
create_header_widget.

Allocating header and footer tiles properly will be
left to future commits.
2023-05-27 22:43:01 -04:00
Matthias Clasen ac03248334 gridview: Rewrite size_allocate
Rewrite size_allocate to use the new split_tiles
function and the multirow helper, and move the handling
of the footer tile at the end into the regular allocation
loop.

This is preparing the code to work with sections.
For now, nothing has changed.
2023-05-27 22:23:37 -04:00
Matthias Clasen 2dcda12369 gridview: Add tests for tile split
These tests are reusing the section model plumbing
of the listitemmanager tests, and just check that
splitting tiles according to a certain number of
columns works and produces multi-row tiles starting
and ending on the first or last column.
2023-05-27 22:23:37 -04:00
Matthias Clasen 7eb2de05a0 gridview: Export some functions privately
This will let us write tests for the tile splitting code.
2023-05-27 22:23:37 -04:00
Matthias Clasen dda24956a1 gridview: Add a function to split tiles
Break this part of size_allocate out as a separate function.
Future commits will rewrite size_allocate to make use of it.

Making this a standalone function taking just a listitemmanager
and n_columns as arguments will make it easy to write tests for it.
2023-05-27 22:23:37 -04:00
Matthias Clasen 243914ff6a gridview: Add a multi-row helper
This is another trivial helper function
that will become more interesting when sections
enter the picture.
2023-05-27 22:23:37 -04:00
Matthias Clasen 7fd42c4a05 gridview: Rewrite get_position_from_allocation
Use the new column helper, and write this function
in a way that will keep working with sections.

The most important point here is that we determine the
column that the anchor item will fall into *after*
other adjustments for position.

This means that the column will be accurate, unless n_columns
or has_sections changes between get_position_for_allocation
and size_allocate.
2023-05-27 22:23:37 -04:00
Matthias Clasen b6d0a04199 gridview: Add a column helper
This is currently a trivial function, but it
will become more interesting when we introduce
sections.
2023-05-27 22:23:37 -04:00
59 changed files with 1574 additions and 2126 deletions
-8
View File
@@ -8,9 +8,6 @@ Overview of Changes in 4.11.3, xx-xx-xxxx
* GtkListView:
- Don't leak the factories
* GtkColumnView:
- Support displaying sections
* GtkNotebook:
- Make the pages model implement GtkSelectionModel
@@ -23,10 +20,6 @@ Overview of Changes in 4.11.3, xx-xx-xxxx
* Css:
- Add new binding-friendly css provider apis
* GDK:
- Support grayscale texture and alpha texture formats
for loading and saving to png and tiff, and in GL
* Theme:
- Show focus in the shortcuts window
@@ -56,7 +49,6 @@ Overview of Changes in 4.11.3, xx-xx-xxxx
Basque
Catalan
Russian
Turkish
Overview of Changes in 4.11.2, 09-05-2023
-24
View File
@@ -30,8 +30,6 @@
#include <glib.h>
#include <gdk/version/gdkversionmacros.h>
G_BEGIN_DECLS
/**
@@ -308,20 +306,6 @@ typedef enum
* the alpha value. Since: 4.6
* @GDK_MEMORY_R32G32B32A32_FLOAT: 4 float values; for red, green, blue and
* alpha. Since: 4.6
* @GDK_MEMORY_G8A8_PREMULTIPLIED: 2 bytes; for grayscale, alpha. The color
* values are premultiplied with the alpha value. Since: 4.12
* @GDK_MEMORY_G8A8: 2 bytes; for grayscale, alpha. Since: 4.12
* @GDK_MEMORY_G8: One byte; for grayscale. The data is opaque.
* Since: 4.12
* @GDK_MEMORY_G16A16_PREMULTIPLIED: 2 guint16 values; for grayscale, alpha.
* The color values are premultiplied with the alpha value. Since: 4.12
* @GDK_MEMORY_G16A16: 2 guint16 values; for grayscale, alpha. Since: 4.12
* @GDK_MEMORY_G16: One guint16 value; for grayscale. The data is opaque.
* Since: 4.12
* @GDK_MEMORY_A8: One byte; for alpha.
* Since: 4.12
* @GDK_MEMORY_A16: One guint16 value; for alpha.
* Since: 4.12
* @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as
* more formats get added, so do not rely on its concrete integer.
*
@@ -356,14 +340,6 @@ typedef enum {
GDK_MEMORY_R32G32B32_FLOAT,
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
GDK_MEMORY_R32G32B32A32_FLOAT,
GDK_MEMORY_G8A8_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G8A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G16A16_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G16A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_N_FORMATS
} GdkMemoryFormat;
+15 -139
View File
@@ -138,7 +138,6 @@ static gboolean
gdk_gl_texture_find_format (gboolean use_es,
guint gl_major,
guint gl_minor,
GdkMemoryAlpha alpha,
GLint gl_format,
GLint gl_type,
GdkMemoryFormat *out_format)
@@ -148,12 +147,8 @@ gdk_gl_texture_find_format (gboolean use_es,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLenum q_internal_format, q_format, q_type;
GLint q_swizzle[4];
if (gdk_memory_format_alpha (format) != alpha)
continue;
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type, &q_swizzle))
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type))
continue;
if (q_format != gl_format || q_type != gl_type)
@@ -172,57 +167,23 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gpointer download_)
{
GdkTexture *texture = GDK_TEXTURE (self);
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLenum gl_internal_format, gl_format, gl_type;
GLint gl_swizzle[4];
int major, minor;
format = gdk_texture_get_format (texture),
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
gdk_gl_context_get_version (context, &major, &minor);
if (!gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (format,
FALSE,
major, minor,
&gl_internal_format,
&gl_format, &gl_type, &gl_swizzle))
if (download->stride == expected_stride &&
!gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (download->format, TRUE, major, minor, &gl_internal_format, &gl_format, &gl_type))
{
if (download->stride == expected_stride &&
download->format == format)
{
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
download->data);
}
else
{
gsize stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
guchar *pixels = g_malloc_n (stride, texture->height);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
pixels);
gdk_memory_convert (download->data,
download->stride,
download->format,
pixels,
stride,
format,
texture->width,
texture->height);
g_free (pixels);
}
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
download->data);
}
else
{
@@ -235,26 +196,17 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
{
gdk_gl_context_get_version (context, &major, &minor);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
if (!gdk_gl_texture_find_format (TRUE, major, minor, gdk_memory_format_alpha (format), gl_read_format, gl_read_type, &actual_format))
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
else
actual_format = GDK_MEMORY_R8G8B8A8;
}
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), major, minor, gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
}
else
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
else
actual_format = GDK_MEMORY_R8G8B8A8;
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
}
if (download->format == actual_format &&
@@ -269,95 +221,19 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
else
{
gsize actual_bpp = gdk_memory_format_bytes_per_pixel (actual_format);
gsize stride = actual_bpp * texture->width;
guchar *pixels = g_malloc_n (stride, texture->height);
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glReadPixels (0, 0,
texture->width, texture->height,
gl_read_format,
gl_read_type,
pixels);
/* Fix up gles inadequacies */
if (gl_read_format == GL_RGBA &&
gl_read_type == GL_UNSIGNED_BYTE &&
(format == GDK_MEMORY_G8A8 ||
format == GDK_MEMORY_G8A8_PREMULTIPLIED ||
format == GDK_MEMORY_G8 ||
format == GDK_MEMORY_A8))
{
for (unsigned int y = 0; y < texture->height; y++)
{
for (unsigned int x = 0; x < texture->width; x++)
{
guchar *data = &pixels[y * stride + x * actual_bpp];
if (format == GDK_MEMORY_G8A8 ||
format == GDK_MEMORY_G8A8_PREMULTIPLIED)
{
data[3] = data[1];
data[1] = data[0];
data[2] = data[0];
}
else if (format == GDK_MEMORY_G8)
{
data[1] = data[0];
data[2] = data[0];
data[3] = 0xff;
}
else if (format == GDK_MEMORY_A8)
{
data[3] = data[0];
data[0] = 0;
data[1] = 0;
data[2] = 0;
}
}
}
}
if (gl_read_format == GL_RGBA &&
gl_read_type == GL_UNSIGNED_SHORT &&
(format == GDK_MEMORY_G16A16 ||
format == GDK_MEMORY_G16A16_PREMULTIPLIED ||
format == GDK_MEMORY_G16 ||
format == GDK_MEMORY_A16))
{
for (unsigned int y = 0; y < texture->height; y++)
{
for (unsigned int x = 0; x < texture->width; x++)
{
guint16 *data = (guint16 *) &pixels[y * stride + x * actual_bpp];
if (format == GDK_MEMORY_G16A16 ||
format == GDK_MEMORY_G16A16_PREMULTIPLIED)
{
data[3] = data[1];
data[1] = data[0];
data[2] = data[0];
}
else if (format == GDK_MEMORY_G16)
{
data[1] = data[0];
data[2] = data[0];
data[3] = 0xffff;
}
else if (format == GDK_MEMORY_A16)
{
data[3] = data[0];
data[0] = 0;
data[1] = 0;
data[2] = 0;
}
}
}
}
gdk_memory_convert (download->data,
download->stride,
download->format,
pixels,
stride,
texture->width * actual_bpp,
actual_format,
texture->width,
texture->height);
-8
View File
@@ -644,18 +644,10 @@ gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self)
* The format is the preferred format the texture data should be downloaded to. The
* format must be supported by the GL version of [property@Gdk.GLTextureBuilder:context].
*
* GDK's texture download code assumes that the format corresponds to the storage
* parameters of the GL texture in an obvious way. For example, a format of
* `GDK_MEMORY_R16G16B16A16_PREMULTIPLIED` is expected to be stored as `GL_RGBA16`
* texture, and `GDK_MEMORY_G8A8` is expected to be stored as `GL_RG8` texture.
*
* Setting the right format is particularly useful when using high bit depth textures
* to preserve the bit depth, to set the correct value for unpremultiplied textures
* and to make sure opaque textures are treated as such.
*
* Non-RGBA textures need to have swizzling parameters set up properly to be usable
* in GSK's shaders.
*
* Since: 4.12
*/
void
+22 -141
View File
@@ -60,36 +60,6 @@ name ## _from_float (guchar *dest_data, \
} \
}
#define TYPED_GRAY_FUNCS(name, T, G, A, bpp, scale) \
static void \
name ## _to_float (float *dest, \
const guchar *src_data, \
gsize n) \
{ \
for (gsize i = 0; i < n; i++) \
{ \
T *src = (T *) (src_data + i * bpp); \
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = 1.0; \
dest[1] = dest[2] = dest[0]; \
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
dest += 4; \
} \
} \
\
static void \
name ## _from_float (guchar *dest_data, \
const float *src, \
gsize n) \
{ \
for (gsize i = 0; i < n; i++) \
{ \
T *dest = (T *) (dest_data + i * bpp); \
if (G >= 0) dest[G] = CLAMP ((src[0] + src[1] + src[2]) * scale / 3.f + 0.5, 0, scale); \
if (A >= 0) dest[A] = CLAMP (src[3] * scale + 0.5, 0, scale); \
src += 4; \
} \
}
TYPED_FUNCS (b8g8r8a8_premultiplied, guchar, 2, 1, 0, 3, 4, 255)
TYPED_FUNCS (a8r8g8b8_premultiplied, guchar, 1, 2, 3, 0, 4, 255)
TYPED_FUNCS (r8g8b8a8_premultiplied, guchar, 0, 1, 2, 3, 4, 255)
@@ -102,15 +72,6 @@ TYPED_FUNCS (b8g8r8, guchar, 2, 1, 0, -1, 3, 255)
TYPED_FUNCS (r16g16b16, guint16, 0, 1, 2, -1, 6, 65535)
TYPED_FUNCS (r16g16b16a16, guint16, 0, 1, 2, 3, 8, 65535)
TYPED_GRAY_FUNCS (g8a8_premultiplied, guchar, 0, 1, 2, 255)
TYPED_GRAY_FUNCS (g8a8, guchar, 0, 1, 2, 255)
TYPED_GRAY_FUNCS (g8, guchar, 0, -1, 1, 255)
TYPED_GRAY_FUNCS (a8, guchar, -1, 0, 1, 255)
TYPED_GRAY_FUNCS (g16a16_premultiplied, guint16, 0, 1, 4, 65535)
TYPED_GRAY_FUNCS (g16a16, guint16, 0, 1, 4, 65535)
TYPED_GRAY_FUNCS (g16, guint16, 0, -1, 2, 65535)
TYPED_GRAY_FUNCS (a16, guint16, -1, 0, 2, 65535)
static void
r16g16b16_float_to_float (float *dest,
const guchar *src_data,
@@ -269,7 +230,6 @@ struct _GdkMemoryFormatDescription
guint internal_format;
guint format;
guint type;
GLint swizzle[4];
} gl;
/* no premultiplication going on here */
void (* to_float) (float *, const guchar*, gsize);
@@ -291,7 +251,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
b8g8r8a8_premultiplied_to_float,
b8g8r8a8_premultiplied_from_float,
},
@@ -301,7 +261,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8r8g8b8_premultiplied_to_float,
a8r8g8b8_premultiplied_from_float,
},
@@ -311,7 +271,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 0, 0 },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
r8g8b8a8_premultiplied_to_float,
r8g8b8a8_premultiplied_from_float,
},
@@ -321,7 +281,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
b8g8r8a8_to_float,
b8g8r8a8_from_float,
},
@@ -331,7 +291,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8r8g8b8_to_float,
a8r8g8b8_from_float,
},
@@ -341,7 +301,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 0, 0 },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
r8g8b8a8_to_float,
r8g8b8a8_from_float,
},
@@ -351,7 +311,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8b8g8r8_to_float,
a8b8g8r8_from_float,
},
@@ -361,7 +321,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 0, 0 },
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
r8g8b8_to_float,
r8g8b8_from_float,
},
@@ -371,7 +331,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
b8g8r8_to_float,
b8g8r8_from_float,
},
@@ -381,7 +341,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
r16g16b16_to_float,
r16g16b16_from_float,
},
@@ -391,7 +351,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
r16g16b16a16_to_float,
r16g16b16a16_from_float,
},
@@ -401,7 +361,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
r16g16b16a16_to_float,
r16g16b16a16_from_float,
},
@@ -411,7 +371,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
r16g16b16_float_to_float,
r16g16b16_float_from_float,
},
@@ -421,7 +381,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
r16g16b16a16_float_to_float,
r16g16b16a16_float_from_float,
},
@@ -431,7 +391,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
r16g16b16a16_float_to_float,
r16g16b16a16_float_from_float,
},
@@ -441,7 +401,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (float),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB32F, GL_RGB, GL_FLOAT },
r32g32b32_float_to_float,
r32g32b32_float_from_float,
},
@@ -451,7 +411,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (float),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
r32g32b32a32_float_to_float,
r32g32b32a32_float_from_float,
},
@@ -461,89 +421,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (float),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
r32g32b32a32_float_to_float,
r32g32b32a32_float_from_float,
},
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
GDK_MEMORY_ALPHA_PREMULTIPLIED,
2,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g8a8_premultiplied_to_float,
g8a8_premultiplied_from_float,
},
[GDK_MEMORY_G8A8] = {
GDK_MEMORY_ALPHA_STRAIGHT,
2,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g8a8_to_float,
g8a8_from_float,
},
[GDK_MEMORY_G8] = {
GDK_MEMORY_ALPHA_OPAQUE,
1,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_ONE } },
g8_to_float,
g8_from_float,
},
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
GDK_MEMORY_ALPHA_PREMULTIPLIED,
4,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g16a16_premultiplied_to_float,
g16a16_premultiplied_from_float,
},
[GDK_MEMORY_G16A16] = {
GDK_MEMORY_ALPHA_STRAIGHT,
4,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g16a16_to_float,
g16a16_from_float,
},
[GDK_MEMORY_G16] = {
GDK_MEMORY_ALPHA_OPAQUE,
2,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_ONE } },
g16_to_float,
g16_from_float,
},
[GDK_MEMORY_A8] = {
GDK_MEMORY_ALPHA_STRAIGHT,
1,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
a8_to_float,
a8_from_float,
},
[GDK_MEMORY_A16] = {
GDK_MEMORY_ALPHA_STRAIGHT,
2,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
a16_to_float,
a16_from_float,
}
};
@@ -592,13 +472,14 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
guint gl_minor,
guint *out_internal_format,
guint *out_format,
guint *out_type,
GLint (*out_swizzle)[4])
guint *out_type)
{
*out_internal_format = memory_formats[format].gl.internal_format;
*out_format = memory_formats[format].gl.format;
*out_type = memory_formats[format].gl.type;
memcpy (out_swizzle, &memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
return FALSE;
if (gles)
{
+1 -4
View File
@@ -21,8 +21,6 @@
#include "gdkenums.h"
#include <epoxy/gl.h>
G_BEGIN_DECLS
typedef enum {
@@ -41,8 +39,7 @@ gboolean gdk_memory_format_gl_format (GdkMemoryFormat
guint gl_minor,
guint *out_internal_format,
guint *out_format,
guint *out_type,
GLint (*out_gizzle)[4]);
guint *out_type);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
+6 -49
View File
@@ -183,7 +183,8 @@ gdk_load_png (GBytes *bytes,
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb (png);
if (color_type == PNG_COLOR_TYPE_GRAY)
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_expand_gray_1_2_4_to_8 (png);
if (png_get_valid (png, info, PNG_INFO_tRNS))
@@ -192,6 +193,10 @@ gdk_load_png (GBytes *bytes,
if (depth < 8)
png_set_packing (png);
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb (png);
if (interlace != PNG_INTERLACE_NONE)
png_set_interlace_handling (png);
@@ -234,26 +239,6 @@ gdk_load_png (GBytes *bytes,
format = GDK_MEMORY_R16G16B16;
}
break;
case PNG_COLOR_TYPE_GRAY:
if (depth == 8)
{
format = GDK_MEMORY_G8;
}
else if (depth == 16)
{
format = GDK_MEMORY_G16;
}
break;
case PNG_COLOR_TYPE_GRAY_ALPHA:
if (depth == 8)
{
format = GDK_MEMORY_G8A8;
}
else if (depth == 16)
{
format = GDK_MEMORY_G16A16;
}
break;
default:
png_destroy_read_struct (&png, &info, NULL);
g_set_error (error,
@@ -364,34 +349,6 @@ gdk_save_png (GdkTexture *texture)
depth = 16;
break;
case GDK_MEMORY_G8:
format = GDK_MEMORY_G8;
png_format = PNG_COLOR_TYPE_GRAY;
depth = 8;
break;
case GDK_MEMORY_G8A8_PREMULTIPLIED:
case GDK_MEMORY_G8A8:
case GDK_MEMORY_A8:
format = GDK_MEMORY_G8A8;
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
depth = 8;
break;
case GDK_MEMORY_G16:
format = GDK_MEMORY_G16;
png_format = PNG_COLOR_TYPE_GRAY;
depth = 16;
break;
case GDK_MEMORY_G16A16_PREMULTIPLIED:
case GDK_MEMORY_G16A16:
case GDK_MEMORY_A16:
format = GDK_MEMORY_G16A16;
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
depth = 16;
break;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
+22 -32
View File
@@ -229,36 +229,27 @@ struct _FormatData {
guint16 samples_per_pixel;
guint16 sample_format;
guint16 alpha_samples;
guint16 photometric;
};
static const FormatData format_data[] = {
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_G8A8_PREMULTIPLIED] = { GDK_MEMORY_G8A8_PREMULTIPLIED, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G8A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G8] = { GDK_MEMORY_G8, 8, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G16A16_PREMULTIPLIED] = { GDK_MEMORY_G16A16_PREMULTIPLIED, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G16A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G16] = { GDK_MEMORY_G16, 16, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0 },
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0 },
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
};
/* if this fails, somebody forgot to add formats above */
@@ -298,7 +289,7 @@ gdk_save_tiff (GdkTexture *texture)
if (fdata->alpha_samples)
TIFFSetField (tif, TIFFTAG_EXTRASAMPLES, 1, &fdata->alpha_samples);
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, fdata->photometric);
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
gdk_texture_downloader_init (&downloader, texture);
@@ -406,7 +397,7 @@ gdk_load_tiff (GBytes *input_bytes,
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGELENGTH, &height);
if (samples_per_pixel == 2 || samples_per_pixel == 4)
if (samples_per_pixel == 4)
{
guint16 extra;
guint16 *extra_types;
@@ -435,15 +426,14 @@ gdk_load_tiff (GBytes *input_bytes,
if (format_data[format].sample_format == sample_format &&
format_data[format].bits_per_sample == bits_per_sample &&
format_data[format].samples_per_pixel == samples_per_pixel &&
format_data[format].alpha_samples == alpha_samples &&
format_data[format].photometric == photometric)
format_data[format].alpha_samples == alpha_samples)
{
break;
}
}
if (format == G_N_ELEMENTS(format_data) ||
(photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_MINISBLACK) ||
photometric != PHOTOMETRIC_RGB ||
planarconfig != PLANARCONFIG_CONTIG ||
TIFFIsTiled (tif) ||
orientation != ORIENTATION_TOPLEFT)
+3 -3
View File
@@ -344,14 +344,14 @@ create_pixel_format (GdkGLVersion *version,
if (gdk_gl_version_get_major (version) >= 4)
{
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL4_Core;
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
if (CGLChoosePixelFormat (attrs, &format, &n_format))
return g_steal_pointer (&format);
}
if (gdk_gl_version_greater_equal (version, &GDK_GL_MIN_GL_VERSION))
{
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL3_Core;
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
if (CGLChoosePixelFormat (attrs, &format, &n_format))
return g_steal_pointer (&format);
}
@@ -396,7 +396,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
gdk_gl_context_get_matching_version (context,
GDK_GL_API_GL,
FALSE,
&min_version);
&version);
display = gdk_gl_context_get_display (context);
shared = gdk_display_get_gl_context (display);
+3 -3
View File
@@ -1436,7 +1436,7 @@ register_clipboard_notification ()
wclass.lpszClassName = "GdkClipboardNotification";
wclass.lpfnWndProc = _clipboard_window_procedure;
wclass.hInstance = this_module ();
wclass.hInstance = _gdk_dll_hinstance;
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
klass = RegisterClass (&wclass);
@@ -1446,7 +1446,7 @@ register_clipboard_notification ()
clipboard_thread_data->clipboard_window = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
this_module (), NULL);
_gdk_dll_hinstance, NULL);
if (clipboard_thread_data->clipboard_window == NULL)
goto failed;
@@ -1471,7 +1471,7 @@ register_clipboard_notification ()
failed:
g_critical ("Failed to install clipboard viewer");
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_dll_hinstance);
return FALSE;
}
+30 -7
View File
@@ -417,12 +417,13 @@ hcursor_from_x_cursor (int i,
#undef SET_BIT
#undef RESET_BIT
rv = CreateCursor (NULL, cursors[i].hotx, cursors[i].hoty,
rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
w, h, and_plane, xor_plane);
}
else
{
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
w, h, and_plane, xor_plane);
}
if (rv == NULL)
@@ -465,7 +466,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
result = gdk_win32_hcursor_new (display,
LoadImageA (GetModuleHandle (NULL),
LoadImageA (_gdk_app_hmodule,
(const char *) cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
@@ -475,7 +476,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
result = gdk_win32_hcursor_new (display,
LoadImageA (this_module (),
LoadImageA (_gdk_dll_hinstance,
(const char *) cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
@@ -857,7 +858,9 @@ create_blank_win32hcursor (GdkWin32Display *display)
xor_plane = g_malloc ((w/8) * h);
memset (xor_plane, 0, (w/8) * h);
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
w, h, and_plane, xor_plane);
if (rv == NULL)
WIN32_API_FAILED ("CreateCursor");
@@ -868,7 +871,6 @@ static GdkWin32HCursor *
gdk_win32hcursor_create_for_name (GdkWin32Display *display,
const char *name)
{
const HINSTANCE hinstance = GetModuleHandle (NULL);
GdkWin32HCursor *win32hcursor = NULL;
/* Blank cursor case */
@@ -883,7 +885,7 @@ gdk_win32hcursor_create_for_name (GdkWin32Display *display,
/* Allow to load named cursor resources linked into the executable.
* Cursors obtained with LoadCursor() cannot be destroyed.
*/
return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
return gdk_win32_hcursor_new (display, LoadCursor (_gdk_app_hmodule, name), FALSE);
}
static HICON
@@ -1450,6 +1452,27 @@ pixbuf_to_hicon (GdkPixbuf *pixbuf,
return icon;
}
HICON
_gdk_win32_texture_to_hicon (GdkTexture *texture)
{
cairo_surface_t *surface;
GdkPixbuf *pixbuf;
int width, height;
HICON icon;
surface = gdk_texture_download_surface (texture);
width = cairo_image_surface_get_width (surface);
height = cairo_image_surface_get_height (surface);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
icon = pixbuf_to_hicon (pixbuf, TRUE, 0, 0);
g_object_unref (pixbuf);
return icon;
}
/**
* gdk_win32_display_get_win32hcursor:
* @display: (type GdkWin32Display): a `GdkDisplay`
+3 -4
View File
@@ -292,7 +292,6 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display)
if (!w32_ex_monitor->remove)
continue;
w32_ex_monitor->hmonitor = NULL;
g_list_store_remove (G_LIST_STORE (win32_display->monitors), i);
gdk_monitor_invalidate (ex_monitor);
}
@@ -481,7 +480,7 @@ register_display_change_notification (GdkDisplay *display)
wclass.lpszClassName = "GdkDisplayChange";
wclass.lpfnWndProc = display_change_window_procedure;
wclass.hInstance = this_module ();
wclass.hInstance = _gdk_app_hmodule;
wclass.style = CS_OWNDC;
klass = RegisterClass (&wclass);
@@ -490,10 +489,10 @@ register_display_change_notification (GdkDisplay *display)
display_win32->hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
this_module (), NULL);
_gdk_app_hmodule, NULL);
if (!display_win32->hwnd)
{
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
}
}
}
+2 -1
View File
@@ -413,7 +413,8 @@ set_up_low_level_keyboard_hook (void)
hook_handle = SetWindowsHookEx (WH_KEYBOARD_LL,
(HOOKPROC) low_level_keyboard_proc,
this_module (), 0);
_gdk_dll_hinstance,
0);
if (hook_handle != NULL)
keyboard_hook = hook_handle;
+3 -3
View File
@@ -261,7 +261,7 @@ create_dummy_gl_window (void)
wclass.lpszClassName = "GdkGLDummyWindow";
wclass.lpfnWndProc = DefWindowProc;
wclass.hInstance = this_module ();
wclass.hInstance = _gdk_app_hmodule;
wclass.style = CS_OWNDC;
klass = RegisterClass (&wclass);
@@ -270,10 +270,10 @@ create_dummy_gl_window (void)
hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
this_module (), NULL);
_gdk_app_hmodule, NULL);
if (!hwnd)
{
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
}
}
+4
View File
@@ -30,6 +30,10 @@
GdkDisplay *_gdk_display = NULL;
GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
HDC _gdk_display_hdc;
HINSTANCE _gdk_dll_hinstance;
HINSTANCE _gdk_app_hmodule;
int _gdk_input_ignore_core;
HKL _gdk_input_locale;
+2 -2
View File
@@ -1003,7 +1003,7 @@ winpointer_notif_window_create (void)
wndclassex.cbSize = sizeof (wndclassex);
wndclassex.lpszClassName = L"GdkWin32WinpointerNotificationsWindowClass";
wndclassex.lpfnWndProc = winpointer_notifications_window_procedure;
wndclassex.hInstance = this_module ();
wndclassex.hInstance = _gdk_dll_hinstance;
if ((notifications_window_class = RegisterClassExW (&wndclassex)) == 0)
{
@@ -1018,7 +1018,7 @@ winpointer_notif_window_create (void)
0, 0, 0, 0,
HWND_MESSAGE,
NULL,
this_module (),
_gdk_dll_hinstance,
NULL)))
{
WIN32_API_FAILED ("CreateWindowExW");
+13
View File
@@ -576,6 +576,19 @@ gdk_mod_mask_to_mod_bits (GdkModifierType mod_mask)
return result;
}
/* keypad decimal mark depends on active keyboard layout
* return current decimal mark as unicode character
*/
guint32
_gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap)
{
guint32 c = MapVirtualKeyW (VK_DECIMAL, MAPVK_VK_TO_CHAR);
if (!c)
c = (guint32) '.';
return c;
}
static void
update_keymap (GdkWin32Keymap *keymap)
{
+190 -56
View File
@@ -45,6 +45,9 @@
#include <wintab.h>
#include <imm.h>
/* for CFSTR_SHELLIDLIST */
#include <shlobj.h>
static gboolean gdk_synchronize = FALSE;
/* Whether GDK initialized COM */
@@ -63,6 +66,8 @@ _gdk_win32_surfaceing_init (void)
if (gdk_synchronize)
GdiSetBatchLimit (1);
_gdk_app_hmodule = GetModuleHandle (NULL);
_gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
_gdk_input_locale = GetKeyboardLayout (0);
_gdk_win32_keymap_set_active_layout (win32_keymap, _gdk_input_locale);
@@ -182,6 +187,135 @@ static_printf (const char *format,
return retval;
}
void
_gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
const int nentries)
{
char buf[20];
int i;
for (i = 0; i < nentries; i++)
g_print (" %3d %02x: %02x %02x %02x%s\n",
i, i,
pep[i].peRed, pep[i].peGreen, pep[i].peBlue,
(pep[i].peFlags == 0 ? "" :
(pep[i].peFlags == PC_EXPLICIT ? " PC_EXPLICIT" :
(pep[i].peFlags == PC_NOCOLLAPSE ? " PC_NOCOLLAPSE" :
(pep[i].peFlags == PC_RESERVED ? " PC_RESERVED" :
(g_sprintf (buf, " %d", pep[i].peFlags), buf))))));
}
void
_gdk_win32_print_system_palette (void)
{
PALETTEENTRY *pe;
int k;
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, 0, NULL);
pe = g_new (PALETTEENTRY, k);
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, k, pe);
if (!k)
g_print ("GetSystemPaletteEntries failed: %s\n",
g_win32_error_message (GetLastError ()));
else
{
g_print ("System palette: %d entries\n", k);
_gdk_win32_print_paletteentries (pe, k);
}
g_free (pe);
}
static int
palette_size (HPALETTE hpal)
{
WORD npal = 0;
if (!GetObject (hpal, sizeof (npal), &npal))
WIN32_GDI_FAILED ("GetObject (HPALETTE)");
return npal;
}
void
_gdk_win32_print_hpalette (HPALETTE hpal)
{
PALETTEENTRY *pe;
int n, npal;
npal = palette_size (hpal);
pe = g_new (PALETTEENTRY, npal);
n = GetPaletteEntries (hpal, 0, npal, pe);
if (!n)
g_print ("HPALETTE %p: GetPaletteEntries failed: %s\n",
hpal, g_win32_error_message (GetLastError ()));
else
{
g_print ("HPALETTE %p: %d (%d) entries\n", hpal, n, npal);
_gdk_win32_print_paletteentries (pe, n);
}
g_free (pe);
}
void
_gdk_win32_print_dc (HDC hdc)
{
HGDIOBJ obj;
LOGBRUSH logbrush;
EXTLOGPEN extlogpen;
HRGN hrgn;
RECT rect;
int flag;
g_print ("%p:\n", hdc);
obj = GetCurrentObject (hdc, OBJ_BRUSH);
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
g_print ("brush: %s color=%06lx hatch=%p\n",
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
logbrush.lbColor, (gpointer) logbrush.lbHatch);
obj = GetCurrentObject (hdc, OBJ_PEN);
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
g_print ("pen: %s %s %s %s w=%d %s\n",
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
(int) extlogpen.elpWidth,
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
g_print ("rop2: %s textcolor=%06lx\n",
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
GetTextColor (hdc));
hrgn = CreateRectRgn (0, 0, 0, 0);
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
WIN32_API_FAILED ("GetClipRgn");
else if (flag == 0)
g_print ("no clip region\n");
else if (flag == 1)
{
GetRgnBox (hrgn, &rect);
g_print ("clip region: %p bbox: %s\n",
hrgn, _gdk_win32_rect_to_string (&rect));
}
DeleteObject (hrgn);
}
char *
_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
{
switch (protocol)
{
#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
CASE (NONE);
CASE (WIN32_DROPFILES);
CASE (OLE2);
#undef CASE
default: return static_printf ("illegal_%d", protocol);
}
/* NOTREACHED */
return NULL;
}
char *
_gdk_win32_surface_state_to_string (GdkToplevelState state)
{
@@ -344,7 +478,7 @@ _gdk_win32_drag_action_to_string (GdkDragAction actions)
return static_printf ("%s", buf);
}
static char *
char *
_gdk_win32_rop2_to_string (int rop2)
{
switch (rop2)
@@ -373,7 +507,7 @@ _gdk_win32_rop2_to_string (int rop2)
return NULL;
}
static char *
char *
_gdk_win32_lbstyle_to_string (UINT brush_style)
{
switch (brush_style)
@@ -392,7 +526,7 @@ _gdk_win32_lbstyle_to_string (UINT brush_style)
return NULL;
}
static char *
char *
_gdk_win32_pstype_to_string (DWORD pen_style)
{
switch (pen_style & PS_TYPE_MASK)
@@ -405,7 +539,7 @@ _gdk_win32_pstype_to_string (DWORD pen_style)
return NULL;
}
static char *
char *
_gdk_win32_psstyle_to_string (DWORD pen_style)
{
switch (pen_style & PS_STYLE_MASK)
@@ -427,7 +561,7 @@ _gdk_win32_psstyle_to_string (DWORD pen_style)
return NULL;
}
static char *
char *
_gdk_win32_psendcap_to_string (DWORD pen_style)
{
switch (pen_style & PS_ENDCAP_MASK)
@@ -443,7 +577,7 @@ _gdk_win32_psendcap_to_string (DWORD pen_style)
return NULL;
}
static char *
char *
_gdk_win32_psjoin_to_string (DWORD pen_style)
{
switch (pen_style & PS_JOIN_MASK)
@@ -459,56 +593,6 @@ _gdk_win32_psjoin_to_string (DWORD pen_style)
return NULL;
}
void
_gdk_win32_print_dc (HDC hdc)
{
HGDIOBJ obj;
LOGBRUSH logbrush;
EXTLOGPEN extlogpen;
HRGN hrgn;
RECT rect;
int flag;
g_print ("%p:\n", hdc);
obj = GetCurrentObject (hdc, OBJ_BRUSH);
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
g_print ("brush: %s color=%06lx hatch=%p\n",
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
logbrush.lbColor, (gpointer) logbrush.lbHatch);
obj = GetCurrentObject (hdc, OBJ_PEN);
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
g_print ("pen: %s %s %s %s w=%d %s\n",
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
(int) extlogpen.elpWidth,
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
g_print ("rop2: %s textcolor=%06lx\n",
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
GetTextColor (hdc));
hrgn = CreateRectRgn (0, 0, 0, 0);
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
WIN32_API_FAILED ("GetClipRgn");
else if (flag == 0)
g_print ("no clip region\n");
else if (flag == 1)
{
GetRgnBox (hrgn, &rect);
g_print ("clip region: %p bbox: %s\n",
hrgn, _gdk_win32_rect_to_string (&rect));
}
DeleteObject (hrgn);
}
char *
_gdk_win32_message_to_string (UINT msg)
{
@@ -809,6 +893,26 @@ _gdk_win32_cf_to_string (UINT format)
}
}
char *
_gdk_win32_data_to_string (const guchar *data,
int nbytes)
{
GString *s = g_string_new ("");
int i;
char *retval;
for (i = 0; i < nbytes; i++)
if (data[i] >=' ' && data[i] <= '~')
g_string_append_printf (s, "%c ", data[i]);
else
g_string_append_printf (s, "%02X ", data[i]);
retval = static_printf ("%s", s->str);
g_string_free (s, TRUE);
return retval;
}
char *
_gdk_win32_rect_to_string (const RECT *rect)
{
@@ -817,4 +921,34 @@ _gdk_win32_rect_to_string (const RECT *rect)
rect->left, rect->top);
}
char *
_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect)
{
return static_printf ("%dx%d@%+d%+d",
rect->width, rect->height,
rect->x, rect->y);
}
char *
_gdk_win32_cairo_region_to_string (const cairo_region_t *rgn)
{
cairo_rectangle_int_t extents;
cairo_region_get_extents (rgn, &extents);
return static_printf ("%dx%d@%+d%+d",
extents.width, extents.height,
extents.x, extents.y);
}
char *
_gdk_win32_surface_description (GdkSurface *d)
{
g_return_val_if_fail (GDK_IS_SURFACE (d), NULL);
return static_printf ("%s:%p:%dx%d",
G_OBJECT_TYPE_NAME (d),
GDK_SURFACE_HWND (d),
gdk_surface_get_width (GDK_SURFACE (d)),
gdk_surface_get_height (GDK_SURFACE (d)));
}
#endif /* G_ENABLE_DEBUG */
+3 -8
View File
@@ -443,6 +443,9 @@ populate_monitor_devices_from_display_config (GPtrArray *monitors)
char *path, *path_lower;
DISPLAYCONFIG_RATIONAL *refresh;
if ((dispconf_paths[path_index].flags & DISPLAYCONFIG_PATH_ACTIVE) == 0)
continue;
tdn.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
tdn.header.size = sizeof (tdn);
tdn.header.adapterId = dispconf_paths[path_index].targetInfo.adapterId;
@@ -478,12 +481,6 @@ populate_monitor_devices_from_display_config (GPtrArray *monitors)
if (w32mon == NULL)
continue;
if ((dispconf_paths[path_index].flags & DISPLAYCONFIG_PATH_ACTIVE) == 0)
{
w32mon->remove = TRUE;
continue;
}
mon = GDK_MONITOR (w32mon);
if (!tdn.flags.friendlyNameForced)
@@ -601,8 +598,6 @@ enum_monitor (HMONITOR hmonitor,
if (w32mon == NULL)
continue;
w32mon->hmonitor = hmonitor;
}
else
{
-3
View File
@@ -35,9 +35,6 @@ struct _GdkWin32Monitor
/* Device instance path (used to match GdkWin32Monitor to monitor device) */
char *instance_path;
/* MOnitor handle (used to fullscreen windows on monitors) */
HMONITOR hmonitor;
/* TRUE if monitor is made up by us
* (this happens when system has logical monitors, but no physical ones).
*/
+157 -10
View File
@@ -15,9 +15,14 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#pragma once
#include <gdk/gdkcursorprivate.h>
#include <gdk/gdkdebugprivate.h>
@@ -27,6 +32,10 @@
#include <gdk/win32/gdkwin32keys.h>
#include <gdk/win32/gdkdevicemanager-win32.h>
#include <gdk/win32/gdkclipdrop-win32.h>
//#include <gdk/win32/gdkselection-win32.h>
#include "config.h"
/* Old debug macros */
@@ -45,6 +54,62 @@
#endif
/* Make up for some minor w32api or MSVC6 header lossage */
#ifndef PS_JOIN_MASK
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
#endif
#ifndef FS_VIETNAMESE
#define FS_VIETNAMESE 0x100
#endif
#ifndef WM_GETOBJECT
#define WM_GETOBJECT 0x3D
#endif
#ifndef WM_NCXBUTTONDOWN
#define WM_NCXBUTTONDOWN 0xAB
#endif
#ifndef WM_NCXBUTTONUP
#define WM_NCXBUTTONUP 0xAC
#endif
#ifndef WM_NCXBUTTONDBLCLK
#define WM_NCXBUTTONDBLCLK 0xAD
#endif
#ifndef WM_CHANGEUISTATE
#define WM_CHANGEUISTATE 0x127
#endif
#ifndef WM_UPDATEUISTATE
#define WM_UPDATEUISTATE 0x128
#endif
#ifndef WM_QUERYUISTATE
#define WM_QUERYUISTATE 0x129
#endif
#ifndef WM_XBUTTONDOWN
#define WM_XBUTTONDOWN 0x20B
#endif
#ifndef WM_XBUTTONUP
#define WM_XBUTTONUP 0x20C
#endif
#ifndef WM_XBUTTONDBLCLK
#define WM_XBUTTONDBLCLK 0x20D
#endif
#ifndef WM_NCMOUSEHOVER
#define WM_NCMOUSEHOVER 0x2A0
#endif
#ifndef WM_NCMOUSELEAVE
#define WM_NCMOUSELEAVE 0x2A2
#endif
#ifndef WM_APPCOMMAND
#define WM_APPCOMMAND 0x319
#endif
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x20E
#endif
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
/* According to
* http://blog.airesoft.co.uk/2009/11/wm_messages/
* this is the actual internal name MS uses for this undocumented message.
@@ -57,6 +122,11 @@
#define WM_SYSMENU 0x313
#endif
#ifndef CF_DIBV5
#define CF_DIBV5 17
#endif
/* Define some combinations of GdkDebugFlags */
#define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
#define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
@@ -70,6 +140,22 @@ GdkWin32Screen *GDK_SURFACE_SCREEN(GObject *win);
*/
#define SWP_NOZORDER_SPECIFIED HWND_TOP
typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
struct _GdkWin32SingleFont
{
HFONT hfont;
UINT charset;
UINT codepage;
FONTSIGNATURE fs;
};
typedef enum {
GDK_WIN32_PE_STATIC,
GDK_WIN32_PE_AVAILABLE,
GDK_WIN32_PE_INUSE
} GdkWin32PalEntryState;
typedef enum
{
GDK_DRAG_PROTO_NONE = 0,
@@ -77,23 +163,51 @@ typedef enum
GDK_DRAG_PROTO_OLE2,
} GdkDragProtocol;
GType _gdk_gc_win32_get_type (void);
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
BOOL _gdk_win32_get_cursor_pos (LPPOINT lpPoint);
void _gdk_surface_init_position (GdkSurface *window);
void _gdk_surface_move_resize_child (GdkSurface *window,
int x,
int y,
int width,
int height);
gboolean _gdk_win32_surface_enable_transparency (GdkSurface *window);
/* GdkSurfaceImpl methods */
void _gdk_win32_surface_scroll (GdkSurface *window,
int dx,
int dy);
void _gdk_win32_surface_move_region (GdkSurface *window,
const cairo_region_t *region,
int dx,
int dy);
void _gdk_win32_selection_init (void);
void _gdk_win32_dnd_exit (void);
void gdk_win32_handle_table_insert (HANDLE *handle,
gpointer data);
void gdk_win32_handle_table_remove (HANDLE handle);
HRGN _gdk_win32_cairo_region_to_hrgn (const cairo_region_t *region,
int x_origin,
int y_origin);
cairo_region_t *_gdk_win32_hrgn_to_region (HRGN hrgn,
guint scale);
void _gdk_win32_adjust_client_rect (GdkSurface *window,
RECT *RECT);
void _gdk_selection_property_delete (GdkSurface *);
void _gdk_push_modal_window (GdkSurface *window);
void _gdk_remove_modal_window (GdkSurface *window);
GdkSurface *_gdk_modal_current (void);
@@ -103,22 +217,41 @@ gboolean gdk_win32_ensure_com (void);
gboolean gdk_win32_ensure_ole (void);
#ifdef G_ENABLE_DEBUG
void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
const int nentries);
void _gdk_win32_print_system_palette (void);
void _gdk_win32_print_hpalette (HPALETTE hpal);
void _gdk_win32_print_dc (HDC hdc);
char *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
char *_gdk_win32_surface_style_to_string (LONG style);
char *_gdk_win32_surface_exstyle_to_string (LONG style);
char *_gdk_win32_surface_pos_bits_to_string (UINT flags);
char *_gdk_win32_drag_action_to_string (GdkDragAction actions);
char *_gdk_win32_surface_description (GdkSurface *d);
char *_gdk_win32_rop2_to_string (int rop2);
char *_gdk_win32_lbstyle_to_string (UINT brush_style);
char *_gdk_win32_pstype_to_string (DWORD pen_style);
char *_gdk_win32_psstyle_to_string (DWORD pen_style);
char *_gdk_win32_psendcap_to_string (DWORD pen_style);
char *_gdk_win32_psjoin_to_string (DWORD pen_style);
char *_gdk_win32_message_to_string (UINT msg);
char *_gdk_win32_key_to_string (LONG lParam);
char *_gdk_win32_cf_to_string (UINT format);
char *_gdk_win32_data_to_string (const guchar*data,
int nbytes);
char *_gdk_win32_rect_to_string (const RECT *rect);
char *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
char *_gdk_win32_cairo_region_to_string (const cairo_region_t *box);
void _gdk_win32_print_event (GdkEvent *event);
#endif
char *_gdk_win32_last_error_string (void);
void _gdk_win32_api_failed (const char *where,
const char *api);
void _gdk_other_api_failed (const char *where,
@@ -151,6 +284,10 @@ extern GdkDisplay *_gdk_display;
extern GdkDeviceManagerWin32 *_gdk_device_manager;
extern HDC _gdk_display_hdc;
extern HINSTANCE _gdk_dll_hinstance;
extern HINSTANCE _gdk_app_hmodule;
extern int _gdk_input_ignore_core;
/* These are thread specific, but GDK/win32 works OK only when invoked
@@ -167,6 +304,8 @@ extern GdkWin32Clipdrop *_win32_clipdrop;
/* Used to identify the main thread */
extern GThread *_win32_main_thread;
void _gdk_win32_dnd_do_dragdrop (void);
typedef enum {
GDK_WIN32_MODAL_OP_NONE = 0x0,
GDK_WIN32_MODAL_OP_SIZE = 0x1 << 0,
@@ -185,9 +324,16 @@ extern HWND _modal_move_resize_window;
void _gdk_win32_begin_modal_call (GdkWin32ModalOpKind kind);
void _gdk_win32_end_modal_call (GdkWin32ModalOpKind kind);
/* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
* Windows XP, thresholds alpha otherwise.
*/
HICON _gdk_win32_texture_to_hicon (GdkTexture *texture);
void _gdk_win32_display_init_cursors (GdkWin32Display *display);
void _gdk_win32_display_finalize_cursors (GdkWin32Display *display);
void _gdk_win32_display_update_cursors (GdkWin32Display *display);
GdkCursor *_gdk_win32_display_get_cursor_for_name (GdkDisplay *display, const char * cursor_name);
GdkCursor *gdk_win32_display_cursor_from_hcursor (GdkDisplay *display, HCURSOR hcursor);
typedef struct _Win32CursorTheme Win32CursorTheme;
@@ -221,6 +367,9 @@ Win32Cursor * win32_cursor_theme_get_cursor (Win32CursorTheme *theme,
void win32_cursor_theme_destroy (Win32CursorTheme *theme);
Win32CursorTheme *_gdk_win32_display_get_cursor_theme (GdkWin32Display *win32_display);
/* GdkDisplay member functions */
GList *_gdk_win32_display_list_devices (GdkDisplay *dpy);
gboolean _gdk_win32_display_has_pending (GdkDisplay *display);
void _gdk_win32_display_queue_events (GdkDisplay *display);
@@ -246,11 +395,16 @@ GdkDrag *_gdk_win32_surface_drag_begin (GdkSurface *window,
/* Stray GdkWin32Screen members */
gboolean _gdk_win32_get_setting (const char *name, GValue *value);
void _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen);
GdkSurface *gdk_win32_screen_get_root_window (GdkWin32Screen *screen);
GdkSurface *gdk_win32_display_get_root_window (GdkDisplay *display);
/* Distributed display manager implementation */
GdkDisplay *_gdk_win32_display_open (const char *display_name);
void _gdk_win32_append_event (GdkEvent *event);
guint32 _gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap);
void _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
GdkWin32AeroSnapCombo combo);
@@ -295,15 +449,8 @@ gboolean _gdk_win32_check_processor (GdkWin32ProcessorCheckType check_type);
GdkPixbuf *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
double *x_hot,
double *y_hot);
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
gpointer gdk_win32_handle_table_lookup_ (HWND handle);
extern IMAGE_DOS_HEADER __ImageBase;
static inline HMODULE
this_module (void)
{
return (HMODULE) &__ImageBase;
}
+1 -9
View File
@@ -113,15 +113,7 @@ _gdk_win32_get_setting (const char *name,
}
else if (strcmp ("gtk-font-name", name) == 0)
{
char *font_name = NULL;
HDC hdc = NULL;
if ((hdc = GetDC (HWND_DESKTOP)) != NULL)
{
font_name = _get_system_font_name (hdc);
ReleaseDC (HWND_DESKTOP, hdc);
hdc = NULL;
}
char *font_name = _get_system_font_name (_gdk_display_hdc);
if (font_name)
{
+17 -28
View File
@@ -50,7 +50,6 @@
#include "gdkdisplay-win32.h"
#include "gdkdevice-win32.h"
#include "gdkcairocontext-win32.h"
#include "gdkmonitor-win32.h"
#include <cairo-win32.h>
#include <dwmapi.h>
@@ -339,7 +338,7 @@ RegisterGdkClass (GType wtype)
wcl.lpfnWndProc = _gdk_win32_surface_procedure;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = this_module ();
wcl.hInstance = _gdk_dll_hinstance;
wcl.hIcon = 0;
wcl.hIconSm = 0;
@@ -356,7 +355,7 @@ RegisterGdkClass (GType wtype)
if (0 == hAppIcon && 0 == hAppIconSm)
{
// fallback : load icon from GTK DLL
if (0 != GetModuleFileName (this_module (), sLoc, MAX_PATH))
if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
{
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
}
@@ -493,7 +492,7 @@ gdk_win32_surface_constructed (GObject *object)
CW_USEDEFAULT, CW_USEDEFAULT,
owner,
NULL,
this_module (),
_gdk_dll_hinstance,
surface);
if (impl->handle == NULL)
{
@@ -626,8 +625,7 @@ get_outer_rect (GdkSurface *window,
}
static void
gdk_win32_surface_fullscreen (GdkSurface *window,
GdkMonitor *monitor);
gdk_win32_surface_fullscreen (GdkSurface *window);
static void
show_window_internal (GdkSurface *window,
@@ -791,7 +789,11 @@ show_window_internal (GdkSurface *window,
}
if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
{
gdk_win32_surface_fullscreen (window);
}
else if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
{
GtkShowWindow (window, SW_MAXIMIZE);
}
@@ -2404,7 +2406,7 @@ RegisterGdkDumbClass ()
wcl.lpfnWndProc = DefWindowProcW;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = this_module ();
wcl.hInstance = _gdk_dll_hinstance;
wcl.hIcon = 0;
wcl.hIconSm = 0;
wcl.lpszMenuName = NULL;
@@ -2445,7 +2447,7 @@ ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context)
0, 0,
NULL,
NULL,
this_module (),
_gdk_dll_hinstance,
NULL);
context->shape_indicator = handle;
@@ -4006,12 +4008,11 @@ gdk_win32_surface_unmaximize (GdkSurface *surface)
}
static void
gdk_win32_surface_fullscreen (GdkSurface *window,
GdkMonitor *monitor)
gdk_win32_surface_fullscreen (GdkSurface *window)
{
int x, y, width, height;
FullscreenInfo *fi;
HMONITOR hmonitor = NULL;
HMONITOR monitor;
MONITORINFO mi;
g_return_if_fail (GDK_IS_SURFACE (window));
@@ -4024,14 +4025,9 @@ gdk_win32_surface_fullscreen (GdkSurface *window,
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
if (monitor && GDK_IS_WIN32_MONITOR (monitor))
hmonitor = GDK_WIN32_MONITOR (monitor)->hmonitor;
if (!hmonitor)
hmonitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof (mi);
if (hmonitor && GetMonitorInfo (hmonitor, &mi))
if (monitor && GetMonitorInfo (monitor, &mi))
{
x = mi.rcMonitor.left;
y = mi.rcMonitor.top;
@@ -4873,16 +4869,9 @@ gdk_win32_toplevel_present (GdkToplevel *toplevel,
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
{
if (fullscreen)
{
GdkMonitor *monitor;
monitor = gdk_toplevel_layout_get_fullscreen_monitor (layout);
gdk_win32_surface_fullscreen (surface, monitor);
}
gdk_win32_surface_fullscreen (surface);
else
{
gdk_win32_surface_unfullscreen (surface);
}
gdk_win32_surface_unfullscreen (surface);
}
gdk_win32_surface_show (surface, FALSE);
+3 -1
View File
@@ -30,6 +30,8 @@
#include "gdkprivate-win32.h"
#include "gdkwin32misc.h"
extern HINSTANCE _gdk_dll_hinstance;
G_DEFINE_TYPE (GdkWin32VulkanContext, gdk_win32_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
static VkResult
@@ -45,7 +47,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
info.pNext = NULL;
info.flags = 0;
info.hinstance = this_module ();
info.hinstance = _gdk_dll_hinstance;
info.hwnd = GDK_SURFACE_HWND (window);
/* This is necessary so that Vulkan sees the Window.
+204 -1
View File
@@ -134,6 +134,35 @@ struct _GdkX11DragClass
GdkDragClass parent_class;
};
typedef struct {
int keysym;
int modifiers;
} GrabKey;
static GrabKey grab_keys[] = {
{ XK_Escape, 0 },
{ XK_space, 0 },
{ XK_KP_Space, 0 },
{ XK_Return, 0 },
{ XK_KP_Enter, 0 },
{ XK_Up, 0 },
{ XK_Up, Mod1Mask },
{ XK_Down, 0 },
{ XK_Down, Mod1Mask },
{ XK_Left, 0 },
{ XK_Left, Mod1Mask },
{ XK_Right, 0 },
{ XK_Right, Mod1Mask },
{ XK_KP_Up, 0 },
{ XK_KP_Up, Mod1Mask },
{ XK_KP_Down, 0 },
{ XK_KP_Down, Mod1Mask },
{ XK_KP_Left, 0 },
{ XK_KP_Left, Mod1Mask },
{ XK_KP_Right, 0 },
{ XK_KP_Right, Mod1Mask }
};
/* Forward declarations */
static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache);
@@ -1832,15 +1861,20 @@ drag_grab (GdkDrag *drag)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkSeatCapabilities capabilities;
GdkDisplay *display;
Window root;
GdkSeat *seat;
int keycode, i;
GdkCursor *cursor;
if (!x11_drag->ipc_surface)
return FALSE;
display = gdk_drag_get_display (drag);
root = GDK_DISPLAY_XROOTWIN (display);
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD;
cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
g_set_object (&x11_drag->cursor, cursor);
@@ -1852,6 +1886,46 @@ drag_grab (GdkDrag *drag)
g_set_object (&x11_drag->grab_seat, seat);
gdk_x11_display_error_trap_push (display);
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
{
int deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat));
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
XIGrabModifiers mods;
XIEventMask evmask;
int num_mods;
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
grab_keys[i].keysym);
if (keycode == NoSymbol)
continue;
memset (mask, 0, sizeof (mask));
XISetMask (mask, XI_KeyPress);
XISetMask (mask, XI_KeyRelease);
evmask.deviceid = deviceid;
evmask.mask_len = sizeof (mask);
evmask.mask = mask;
num_mods = 1;
mods.modifiers = grab_keys[i].modifiers;
XIGrabKeycode (GDK_DISPLAY_XDISPLAY (display),
deviceid,
keycode,
root,
GrabModeAsync,
GrabModeAsync,
False,
&evmask,
num_mods,
&mods);
}
gdk_x11_display_error_trap_pop_ignored (display);
return TRUE;
}
@@ -1859,13 +1933,41 @@ static void
drag_ungrab (GdkDrag *drag)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkDisplay *display;
GdkDevice *keyboard;
Window root;
int keycode, i;
if (!x11_drag->grab_seat)
return;
gdk_seat_ungrab (x11_drag->grab_seat);
display = gdk_drag_get_display (drag);
keyboard = gdk_seat_get_keyboard (x11_drag->grab_seat);
root = GDK_DISPLAY_XROOTWIN (display);
g_clear_object (&x11_drag->grab_seat);
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
{
XIGrabModifiers mods;
int num_mods;
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
grab_keys[i].keysym);
if (keycode == NoSymbol)
continue;
num_mods = 1;
mods.modifiers = grab_keys[i].modifiers;
XIUngrabKeycode (GDK_DISPLAY_XDISPLAY (display),
gdk_x11_device_get_id (keyboard),
keycode,
root,
num_mods,
&mods);
}
}
GdkDrag *
@@ -2089,6 +2191,103 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
return TRUE;
}
static gboolean
gdk_dnd_handle_key_event (GdkDrag *drag,
GdkEvent *event)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkModifierType state;
GdkDevice *pointer;
GdkSeat *seat;
int dx, dy;
dx = dy = 0;
state = gdk_event_get_modifier_state (event);
seat = gdk_event_get_seat (event);
pointer = gdk_seat_get_pointer (seat);
if (event->event_type == GDK_KEY_PRESS)
{
guint keyval = gdk_key_event_get_keyval (event);
switch (keyval)
{
case GDK_KEY_Escape:
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
return TRUE;
case GDK_KEY_space:
case GDK_KEY_Return:
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_KP_Space:
if ((gdk_drag_get_selected_action (drag) != 0) &&
(x11_drag->proxy_xid != None))
{
g_signal_emit_by_name (drag, "drop-performed");
}
else
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
return TRUE;
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
dy = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
dy = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
case GDK_KEY_Left:
case GDK_KEY_KP_Left:
dx = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
dx = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
default:
break;
}
}
/* The state is not yet updated in the event, so we need
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
gdk_x11_device_xi2_query_state (pointer, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
GdkDisplay *display;
Display *xdisplay;
GdkX11Screen *screen;
Window dest;
x11_drag->last_x += dx;
x11_drag->last_y += dy;
display = gdk_event_get_display ((GdkEvent *)event);
xdisplay = GDK_DISPLAY_XDISPLAY (display);
screen = GDK_X11_DISPLAY (display)->screen;
dest = GDK_SCREEN_XROOTWIN (screen);
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
round (x11_drag->last_x * screen->surface_scale),
round (x11_drag->last_y * screen->surface_scale));
}
gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state,
gdk_event_get_time (event));
return TRUE;
}
static gboolean
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
GdkEvent *event)
@@ -2155,6 +2354,10 @@ gdk_x11_drag_handle_event (GdkDrag *drag,
case GDK_BUTTON_RELEASE:
return gdk_dnd_handle_button_event (drag, event);
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
return gdk_dnd_handle_key_event (drag, event);
case GDK_GRAB_BROKEN:
return gdk_dnd_handle_grab_broken_event (drag, event);
+15 -12
View File
@@ -543,14 +543,14 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
if (share != NULL)
share_glx = GDK_X11_GL_CONTEXT_GLX (share);
gdk_x11_display_error_trap_push (display);
supported_versions = gdk_gl_versions_get_for_api (api);
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
{
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
context_attribs [minor_idx] = gdk_gl_version_get_minor (&supported_versions[j]);
gdk_x11_display_error_trap_push (display);
/* If we don't have access to GLX_ARB_create_context_profile, then
* we have to fall back to the old GLX 1.3 API.
*/
@@ -568,19 +568,22 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
True,
context_attribs);
if (ctx == NULL)
{
gdk_x11_display_error_trap_pop_ignored (display);
}
else if (gdk_x11_display_error_trap_pop (display))
{
glXDestroyContext (dpy, ctx);
ctx = NULL;
}
else
if (ctx)
break;
}
if (ctx == NULL)
{
gdk_x11_display_error_trap_pop_ignored (display);
return 0;
}
if (gdk_x11_display_error_trap_pop (display))
{
glXDestroyContext (dpy, ctx);
return 0;
}
GDK_DISPLAY_DEBUG (display, OPENGL,
"Realized GLX context[%p], %s, version: %d.%d",
context_glx->glx_context,
+3 -19
View File
@@ -685,13 +685,8 @@ init_randr13 (GdkX11Screen *x11_screen)
for (i = 0; i < resources->noutput; ++i)
{
RROutput output = resources->outputs[i];
XRROutputInfo *output_info;
gdk_x11_display_error_trap_push (display);
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
if (gdk_x11_display_error_trap_pop (display))
continue;
XRROutputInfo *output_info =
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
if (output_info->connection == RR_Disconnected)
{
@@ -702,22 +697,13 @@ init_randr13 (GdkX11Screen *x11_screen)
if (output_info->crtc)
{
GdkX11Monitor *monitor;
XRRCrtcInfo *crtc;
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
char *name;
GdkRectangle geometry;
GdkRectangle newgeo;
int j;
int refresh_rate = 0;
gdk_x11_display_error_trap_push (display);
crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
if (gdk_x11_display_error_trap_pop (display))
{
XRRFreeOutputInfo (output_info);
continue;
}
for (j = 0; j < resources->nmode; j++)
{
XRRModeInfo *xmode = &resources->modes[j];
@@ -789,10 +775,8 @@ init_randr13 (GdkX11Screen *x11_screen)
}
x11_display->primary_monitor = 0;
gdk_x11_display_error_trap_push (display);
primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
x11_screen->xroot_window);
gdk_x11_display_error_trap_pop_ignored (display);
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
{
+12 -12
View File
@@ -89,7 +89,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
if (size == 0)
{
/* EOF marker, put it back */
g_async_queue_push_front_unlocked (priv->chunks, g_steal_pointer (&bytes));
g_async_queue_push_front_unlocked (priv->chunks, bytes);
break;
}
else if (size > count)
@@ -107,7 +107,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
memcpy (buffer, g_bytes_get_data (bytes, NULL), size);
}
g_bytes_unref (g_steal_pointer (&bytes));
g_bytes_unref (bytes);
result += size;
if (buffer)
buffer += size;
@@ -165,7 +165,9 @@ gdk_x11_selection_input_stream_complete (GdkX11SelectionInputStream *stream)
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
g_signal_handlers_disconnect_by_func (priv->display,
gdk_x11_selection_input_stream_xevent,
g_steal_pointer (&stream));
stream);
g_object_unref (stream);
}
static gssize
@@ -414,7 +416,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
"%s:%s: got PropertyNotify erroring out of INCR",
priv->selection, priv->target);
/* error, should we signal one? */
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else if (g_bytes_get_size (bytes) == 0 || type == None)
{
@@ -422,7 +424,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
"%s:%s: got PropertyNotify ending INCR",
priv->selection, priv->target);
g_bytes_unref (bytes);
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else
{
@@ -465,7 +467,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
_("Format %s not supported"), priv->target);
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else
{
@@ -476,7 +478,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
if (bytes == NULL)
{
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else
{
@@ -498,7 +500,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
g_bytes_get_size (bytes));
g_async_queue_push (priv->chunks, bytes);
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
}
@@ -539,10 +541,7 @@ gdk_x11_selection_input_stream_new_async (GdkDisplay *display,
priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream);
priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property);
g_signal_connect_data (display, "xevent",
G_CALLBACK (gdk_x11_selection_input_stream_xevent),
g_steal_pointer (&stream),
(GClosureNotify) g_object_unref, 0);
g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_selection_input_stream_xevent), stream);
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
priv->xselection,
@@ -578,6 +577,7 @@ gdk_x11_selection_input_stream_new_finish (GAsyncResult *result,
*type = priv->type;
if (format)
*format = priv->format;
g_object_ref (stream);
}
return G_INPUT_STREAM (stream);
+12 -34
View File
@@ -1447,7 +1447,6 @@ gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self)
return fbo_id;
}
static GdkMemoryFormat
memory_format_gl_format (GdkMemoryFormat data_format,
gboolean use_es,
@@ -1455,8 +1454,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
guint minor,
guint *gl_internalformat,
guint *gl_format,
guint *gl_type,
GLint (*gl_swizzle)[4])
guint *gl_type)
{
if (gdk_memory_format_gl_format (data_format,
use_es,
@@ -1464,9 +1462,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
minor,
gl_internalformat,
gl_format,
gl_type,
gl_swizzle) &&
gdk_memory_format_alpha (data_format) != GDK_MEMORY_ALPHA_STRAIGHT)
gl_type))
return data_format;
if (gdk_memory_format_prefers_high_depth (data_format))
@@ -1478,8 +1474,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
minor,
gl_internalformat,
gl_format,
gl_type,
gl_swizzle))
gl_type))
return data_format;
}
@@ -1490,8 +1485,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
minor,
gl_internalformat,
gl_format,
gl_type,
gl_swizzle))
gl_type))
{
g_assert_not_reached ();
}
@@ -1514,7 +1508,6 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
GLenum gl_internalformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
gsize bpp;
gboolean use_es;
int major, minor;
@@ -1531,8 +1524,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
minor,
&gl_internalformat,
&gl_format,
&gl_type,
&gl_swizzle);
&gl_type);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, data_format);
@@ -1567,18 +1559,6 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
/* Only apply swizzle if really needed, might not even be
* supported if default values are set
*/
if (gl_swizzle[0] != GL_RED || gl_swizzle[1] != GL_GREEN || gl_swizzle[2] != GL_BLUE)
{
/* Set each channel independently since GLES 3.0 doesn't support the iv method */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, gl_swizzle[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, gl_swizzle[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_swizzle[2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, gl_swizzle[3]);
}
g_bytes_unref (bytes);
}
@@ -1593,7 +1573,6 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
GLenum gl_internalformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
gboolean use_es;
int texture_id;
int major, minor;
@@ -1632,14 +1611,13 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
use_es = gdk_gl_context_get_use_es (self->context);
gdk_gl_context_get_version (self->context, &major, &minor);
data_format = gdk_texture_get_format (chunks[0].texture);
data_format = memory_format_gl_format (data_format,
use_es,
major,
minor,
&gl_internalformat,
&gl_format,
&gl_type,
&gl_swizzle);
memory_format_gl_format (data_format,
use_es,
major,
minor,
&gl_internalformat,
&gl_format,
&gl_type);
glTexImage2D (GL_TEXTURE_2D, 0, gl_internalformat, width, height, 0, gl_format, gl_type, NULL);
+1 -2
View File
@@ -761,8 +761,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
GdkGLContext *texture_context = gdk_gl_texture_get_context (gl_texture);
if (gdk_gl_context_is_shared (context, texture_context) &&
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)) &&
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_STRAIGHT)
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)))
{
/* A GL texture from the same GL context is a simple task... */
return gdk_gl_texture_get_id (gl_texture);
-8
View File
@@ -2892,14 +2892,6 @@ append_texture_param (Printer *p,
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16:
case GDK_MEMORY_G8A8_PREMULTIPLIED:
case GDK_MEMORY_G8A8:
case GDK_MEMORY_G8:
case GDK_MEMORY_G16A16_PREMULTIPLIED:
case GDK_MEMORY_G16A16:
case GDK_MEMORY_G16:
case GDK_MEMORY_A8:
case GDK_MEMORY_A16:
bytes = gdk_texture_save_to_png_bytes (texture);
g_string_append (p->str, "url(\"data:image/png;base64,");
break;
+1 -1
View File
@@ -32,4 +32,4 @@ VS_VERSION_INFO VERSIONINFO
END
END
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST libgtk.manifest
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST libgtk4.manifest
+1 -4
View File
@@ -325,9 +325,6 @@ gtk_action_muxer_get_group (GtkActionMuxer *muxer,
{
Group *group;
if (!muxer->groups)
return NULL;
group = g_hash_table_lookup (muxer->groups, group_name);
if (group)
return group->group;
@@ -455,7 +452,7 @@ notify_observers_added (GtkActionMuxer *muxer,
gtk_action_observable_register_observer (GTK_ACTION_OBSERVABLE (parent), action_name, GTK_ACTION_OBSERVER (muxer));
if (!action_muxer_query_action (muxer, action_name,
if (!action_muxer_query_action (parent, action_name,
&enabled, &parameter_type,
NULL, NULL, &state,
TRUE))
+1 -6
View File
@@ -323,7 +323,6 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
int largest_min_above = -1, largest_min_below = -1;
int largest_nat_above = -1, largest_nat_below = -1;
gboolean have_baseline = FALSE;
gboolean align_baseline = FALSE;
for (child = gtk_widget_get_first_child (widget);
child != NULL;
@@ -351,10 +350,6 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
if (child_min_baseline > -1)
{
have_baseline = TRUE;
if (gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE_FILL ||
gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE_CENTER)
align_baseline = TRUE;
largest_min_above = MAX (largest_min_above, child_min_baseline);
largest_min_below = MAX (largest_min_below, child_min - child_min_baseline);
largest_nat_above = MAX (largest_nat_above, child_nat_baseline);
@@ -363,7 +358,7 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
}
}
if (self->orientation == GTK_ORIENTATION_HORIZONTAL && align_baseline)
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
largest_min = MAX (largest_min, largest_min_above + largest_min_below);
largest_nat = MAX (largest_nat, largest_nat_above + largest_nat_below);
+3 -4
View File
@@ -1422,7 +1422,7 @@ typedef enum {
GTK_ACCESSIBLE_ROLE_TREE_ITEM,
GTK_ACCESSIBLE_ROLE_WIDGET,
GTK_ACCESSIBLE_ROLE_WINDOW,
GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON GDK_AVAILABLE_ENUMERATOR_IN_4_10
GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON
} GtkAccessibleRole;
/**
@@ -1449,8 +1449,7 @@ typedef enum {
* @GTK_ACCESSIBLE_STATE_SELECTED: A selected state; set when a widget
* is selected. Value type: boolean or undefined
* @GTK_ACCESSIBLE_STATE_VISITED: Indicates that a widget with the
* GTK_ACCESSIBLE_ROLE_LINK has been visited. Value type: boolean.
* Since: 4.12
* GTK_ACCESSIBLE_ROLE_LINK has been visited. Value type: boolean. Since: 4.12
*
* The possible accessible states of a [iface@Accessible].
*/
@@ -1463,7 +1462,7 @@ typedef enum {
GTK_ACCESSIBLE_STATE_INVALID,
GTK_ACCESSIBLE_STATE_PRESSED,
GTK_ACCESSIBLE_STATE_SELECTED,
GTK_ACCESSIBLE_STATE_VISITED GDK_AVAILABLE_ENUMERATOR_IN_4_12
GTK_ACCESSIBLE_STATE_VISITED
} GtkAccessibleState;
/**
+1 -277
View File
@@ -23,7 +23,6 @@
#include "gtkbitset.h"
#include "gtkprivate.h"
#include "gtkselectionmodel.h"
#include "gtksectionmodelprivate.h"
/**
@@ -40,12 +39,8 @@
* [method@Gtk.FilterListModel.set_incremental] for details.
*
* `GtkFilterListModel` passes through sections from the underlying model.
*
* Since 4.12, `GtkFilterListModel` also implements `GtkSelectionModel`
* and passes through selections from the underlying model. Any changes
* to the selection that are done through the filter model will cause
* filtered-out items to be unselected.
*/
enum {
PROP_0,
PROP_FILTER,
@@ -143,240 +138,6 @@ gtk_filter_list_model_model_init (GListModelInterface *iface)
iface->get_item = gtk_filter_list_model_get_item;
}
static gboolean
gtk_filter_list_model_is_selected (GtkSelectionModel *model,
guint position)
{
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (model);
guint unfiltered;
if (!GTK_IS_SELECTION_MODEL (self->model))
return FALSE;
switch (self->strictness)
{
case GTK_FILTER_MATCH_NONE:
return FALSE;
case GTK_FILTER_MATCH_ALL:
unfiltered = position;
break;
case GTK_FILTER_MATCH_SOME:
unfiltered = gtk_bitset_get_nth (self->matches, position);
if (unfiltered == 0 && position >= gtk_bitset_get_size (self->matches))
return FALSE;
break;
default:
g_assert_not_reached ();
}
return gtk_selection_model_is_selected (GTK_SELECTION_MODEL (self->model), unfiltered);
}
static GtkBitset *
gtk_filter_list_model_get_selection_in_range (GtkSelectionModel *model,
guint pos,
guint n_items)
{
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (model);
if (!GTK_IS_SELECTION_MODEL (self->model))
return gtk_bitset_new_empty ();
switch (self->strictness)
{
case GTK_FILTER_MATCH_NONE:
return gtk_bitset_new_empty ();
case GTK_FILTER_MATCH_ALL:
return gtk_selection_model_get_selection_in_range (GTK_SELECTION_MODEL (self->model),
pos,
n_items);
case GTK_FILTER_MATCH_SOME:
{
GtkBitset *result;
GtkBitset *selected;
unsigned int last;
unsigned int start, end;
if (pos >= gtk_bitset_get_size (self->matches))
return gtk_bitset_new_empty ();
last = MIN (pos + n_items, gtk_bitset_get_size (self->matches));
start = gtk_bitset_get_nth (self->matches, pos);
end = gtk_bitset_get_nth (self->matches, last - 1);
selected = gtk_selection_model_get_selection_in_range (GTK_SELECTION_MODEL (self->model),
start, end - start + 1);
result = gtk_bitset_new_empty ();
for (unsigned int i = pos; i < last; i++)
{
if (gtk_bitset_contains (selected, gtk_bitset_get_nth (self->matches, i)))
gtk_bitset_add (result, i);
}
gtk_bitset_unref (selected);
return result;
}
default:
g_assert_not_reached ();
}
}
static gboolean
gtk_filter_list_model_select_item (GtkSelectionModel *model,
guint position,
gboolean unselect_rest)
{
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (model);
unsigned int unfiltered;
if (!GTK_IS_SELECTION_MODEL (self->model))
return TRUE;
switch (self->strictness)
{
case GTK_FILTER_MATCH_NONE:
return TRUE;
case GTK_FILTER_MATCH_ALL:
unfiltered = position;
break;
case GTK_FILTER_MATCH_SOME:
unfiltered = gtk_bitset_get_nth (self->matches, position);
if (unfiltered == 0 && position >= gtk_bitset_get_size (self->matches))
return TRUE;
break;
default:
g_assert_not_reached ();
}
return gtk_selection_model_select_item (GTK_SELECTION_MODEL (self->model),
unfiltered,
unselect_rest);
}
static gboolean
gtk_filter_list_model_unselect_item (GtkSelectionModel *model,
guint position)
{
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (model);
unsigned int unfiltered;
if (!GTK_IS_SELECTION_MODEL (self->model))
return TRUE;
switch (self->strictness)
{
case GTK_FILTER_MATCH_NONE:
return TRUE;
case GTK_FILTER_MATCH_ALL:
unfiltered = position;
break;
case GTK_FILTER_MATCH_SOME:
unfiltered = gtk_bitset_get_nth (self->matches, position);
if (unfiltered == 0 && position >= gtk_bitset_get_size (self->matches))
return TRUE;
break;
default:
g_assert_not_reached ();
}
return gtk_selection_model_unselect_item (GTK_SELECTION_MODEL (self->model),
unfiltered);
}
static gboolean
gtk_filter_list_model_set_selection (GtkSelectionModel *model,
GtkBitset *selected,
GtkBitset *mask)
{
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (model);
if (!GTK_IS_SELECTION_MODEL (self->model))
return TRUE;
switch (self->strictness)
{
case GTK_FILTER_MATCH_NONE:
return TRUE;
case GTK_FILTER_MATCH_ALL:
return gtk_selection_model_set_selection (GTK_SELECTION_MODEL (self->model),
selected,
mask);
case GTK_FILTER_MATCH_SOME:
{
GtkBitset *selected2;
GtkBitset *mask2;
GtkBitset *unmatched;
GtkBitsetIter iter;
unsigned int unfiltered;
gboolean ret;
selected2 = gtk_bitset_new_empty ();
mask2 = gtk_bitset_new_empty ();
if (gtk_bitset_iter_init_first (&iter, self->matches, &unfiltered))
{
unsigned int i = 0;
do
{
if (gtk_bitset_contains (selected, i))
gtk_bitset_add (selected2, unfiltered);
if (gtk_bitset_contains (mask, i))
gtk_bitset_add (mask2, unfiltered);
i++;
}
while (gtk_bitset_iter_next (&iter, &unfiltered));
}
unmatched = gtk_bitset_new_range (0, g_list_model_get_n_items (self->model));
gtk_bitset_subtract (unmatched, self->matches);
gtk_bitset_union (mask2, unmatched);
ret = gtk_selection_model_set_selection (GTK_SELECTION_MODEL (self->model),
selected2,
mask2);
gtk_bitset_unref (unmatched);
gtk_bitset_unref (selected2);
gtk_bitset_unref (mask2);
return ret;
}
default:
g_assert_not_reached ();
}
}
static void
gtk_filter_list_model_selection_model_init (GtkSelectionModelInterface *iface)
{
iface->is_selected = gtk_filter_list_model_is_selected;
iface->select_item = gtk_filter_list_model_select_item;
iface->unselect_item = gtk_filter_list_model_unselect_item;
iface->get_selection_in_range = gtk_filter_list_model_get_selection_in_range;
iface->set_selection = gtk_filter_list_model_set_selection;
}
static void
gtk_filter_list_model_get_section (GtkSectionModel *model,
guint position,
@@ -429,39 +190,6 @@ gtk_filter_list_model_get_section (GtkSectionModel *model,
*out_end = *out_start + gtk_bitset_get_size_in_range (self->matches, start, end - 1);
}
static void
gtk_filter_list_model_selection_changed_cb (GtkSelectionModel *model,
unsigned int position,
unsigned int n_items,
gpointer user_data)
{
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (user_data);
unsigned int start, end;
switch (self->strictness)
{
case GTK_FILTER_MATCH_NONE:
return;
case GTK_FILTER_MATCH_ALL:
gtk_selection_model_selection_changed (GTK_SELECTION_MODEL (self), position, n_items);
break;
case GTK_FILTER_MATCH_SOME:
if (position > 0)
start = gtk_bitset_get_size_in_range (self->matches, 0, position - 1);
else
start = 0;
end = gtk_bitset_get_size_in_range (self->matches, 0, position + n_items - 1);
if (end - start > 0)
gtk_selection_model_selection_changed (GTK_SELECTION_MODEL (self), start, end - start);
break;
default:
g_assert_not_reached ();
}
}
static void
gtk_filter_list_model_sections_changed_cb (GtkSectionModel *model,
unsigned int position,
@@ -503,7 +231,6 @@ gtk_filter_list_model_section_model_init (GtkSectionModelInterface *iface)
G_DEFINE_TYPE_WITH_CODE (GtkFilterListModel, gtk_filter_list_model, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_filter_list_model_model_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SELECTION_MODEL, gtk_filter_list_model_selection_model_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SECTION_MODEL, gtk_filter_list_model_section_model_init))
static gboolean
@@ -771,7 +498,6 @@ gtk_filter_list_model_clear_model (GtkFilterListModel *self)
gtk_filter_list_model_stop_filtering (self);
g_signal_handlers_disconnect_by_func (self->model, gtk_filter_list_model_items_changed_cb, self);
g_signal_handlers_disconnect_by_func (self->model, gtk_filter_list_model_selection_changed_cb, self);
g_signal_handlers_disconnect_by_func (self->model, gtk_filter_list_model_sections_changed_cb, self);
g_clear_object (&self->model);
if (self->matches)
@@ -1137,8 +863,6 @@ gtk_filter_list_model_set_model (GtkFilterListModel *self,
{
self->model = g_object_ref (model);
g_signal_connect (model, "items-changed", G_CALLBACK (gtk_filter_list_model_items_changed_cb), self);
if (GTK_IS_SELECTION_MODEL (model))
g_signal_connect (model, "selection-changed", G_CALLBACK (gtk_filter_list_model_selection_changed_cb), self);
if (GTK_IS_SECTION_MODEL (model))
g_signal_connect (model, "sections-changed", G_CALLBACK (gtk_filter_list_model_sections_changed_cb), self);
if (removed == 0)
+1 -1
View File
@@ -1162,7 +1162,7 @@ update_fontlist (GtkFontChooserWidget *self)
model = G_LIST_MODEL (gtk_slice_list_model_new (model, 0, 20));
gtk_widget_add_tick_callback (GTK_WIDGET (self), add_to_fontlist, g_object_ref (model), g_object_unref);
gtk_single_selection_set_model (self->selection, model);
gtk_filter_list_model_set_model (self->filter_model, model);
g_object_unref (model);
}
+481 -98
View File
@@ -19,16 +19,18 @@
#include "config.h"
#include "gtkgridview.h"
#include "gtkgridviewprivate.h"
#include "gtkbitset.h"
#include "gtklistbaseprivate.h"
#include "gtklistheaderwidgetprivate.h"
#include "gtklistitemfactory.h"
#include "gtklistitemmanagerprivate.h"
#include "gtklistitemwidgetprivate.h"
#include "gtkmultiselection.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtksectionmodel.h"
/* Maximum number of list items created by the gridview.
* For debugging, you can set this to G_MAXUINT to ensure
@@ -87,6 +89,7 @@ struct _GtkGridView
GtkListItemManager *item_manager;
GtkListItemFactory *factory;
GtkListItemFactory *header_factory;
guint min_columns;
guint max_columns;
gboolean single_click_activate;
@@ -105,6 +108,7 @@ enum
PROP_0,
PROP_ENABLE_RUBBERBAND,
PROP_FACTORY,
PROP_HEADER_FACTORY,
PROP_MAX_COLUMNS,
PROP_MIN_COLUMNS,
PROP_MODEL,
@@ -257,6 +261,13 @@ gtk_grid_view_split (GtkListBase *base,
return split;
}
static void
gtk_grid_view_prepare_section (GtkListBase *base,
GtkListTile *tile,
guint position)
{
}
/* We define the listview as **inert** when the factory isn't used. */
static gboolean
gtk_grid_view_is_inert (GtkGridView *self)
@@ -269,7 +280,8 @@ gtk_grid_view_is_inert (GtkGridView *self)
static void
gtk_grid_view_update_factories_with (GtkGridView *self,
GtkListItemFactory *factory)
GtkListItemFactory *factory,
GtkListItemFactory *header_factory)
{
GtkListTile *tile;
@@ -277,8 +289,26 @@ gtk_grid_view_update_factories_with (GtkGridView *self,
tile != NULL;
tile = gtk_rb_tree_node_get_next (tile))
{
if (tile->widget)
gtk_list_factory_widget_set_factory (GTK_LIST_FACTORY_WIDGET (tile->widget), factory);
switch (tile->type)
{
case GTK_LIST_TILE_ITEM:
if (tile->widget)
gtk_list_factory_widget_set_factory (GTK_LIST_FACTORY_WIDGET (tile->widget), factory);
break;
case GTK_LIST_TILE_HEADER:
if (tile->widget)
gtk_list_header_widget_set_factory (GTK_LIST_HEADER_WIDGET (tile->widget), header_factory);
break;
case GTK_LIST_TILE_UNMATCHED_HEADER:
case GTK_LIST_TILE_FOOTER:
case GTK_LIST_TILE_UNMATCHED_FOOTER:
case GTK_LIST_TILE_REMOVED:
g_assert (tile->widget == NULL);
break;
default:
g_assert_not_reached();
break;
}
}
}
@@ -286,13 +316,14 @@ static void
gtk_grid_view_update_factories (GtkGridView *self)
{
gtk_grid_view_update_factories_with (self,
gtk_grid_view_is_inert (self) ? NULL : self->factory);
gtk_grid_view_is_inert (self) ? NULL : self->factory,
gtk_grid_view_is_inert (self) ? NULL : self->header_factory);
}
static void
gtk_grid_view_clear_factories (GtkGridView *self)
{
gtk_grid_view_update_factories_with (self, NULL);
gtk_grid_view_update_factories_with (self, NULL, NULL);
}
static GtkListItemBase *
@@ -316,6 +347,20 @@ gtk_grid_view_create_list_widget (GtkListBase *base)
return GTK_LIST_ITEM_BASE (result);
}
static GtkListHeaderBase *
gtk_grid_view_create_header_widget (GtkListBase *base)
{
GtkGridView *self = GTK_GRID_VIEW (base);
GtkListItemFactory *factory;
if (gtk_grid_view_is_inert (self))
factory = NULL;
else
factory = self->header_factory;
return GTK_LIST_HEADER_BASE (gtk_list_header_widget_new (factory));
}
static gboolean
gtk_grid_view_get_allocation (GtkListBase *base,
guint pos,
@@ -384,6 +429,78 @@ gtk_grid_view_get_allocation (GtkListBase *base,
return TRUE;
}
/* Returns the section that position falls into
*/
void
gtk_grid_view_get_section_for_position (GtkListItemManager *items,
unsigned int position,
unsigned int *section_start,
unsigned int *section_end)
{
GListModel *model;
unsigned int start, end;
model = G_LIST_MODEL (gtk_list_item_manager_get_model (items));
if (!gtk_list_item_manager_get_has_sections (items))
{
start = 0;
end = g_list_model_get_n_items (model);
}
else
{
gtk_section_model_get_section (GTK_SECTION_MODEL (model), position, &start, &end);
}
if (section_start)
*section_start = start;
if (section_end)
*section_end = end;
}
/* Returns the column that the given item will fall in, taking
* sections into account. Note that this depends on whether
* we are currently showing sections, and on the number of
* columns that the grid is allocating.
*/
unsigned int
gtk_grid_view_get_column_for_position (GtkListItemManager *items,
unsigned int n_columns,
unsigned int position)
{
unsigned int start;
gtk_grid_view_get_section_for_position (items, position, &start, NULL);
return (position - start) % n_columns;
}
/* Determine whether a tile is contained in a single row,
* or spans multiple rows.
*/
gboolean
gtk_grid_view_is_multirow_tile (GtkListItemManager *items,
unsigned int n_columns,
GtkListTile *tile)
{
unsigned int position;
unsigned int start, end;
unsigned int col;
if (tile->n_items <= 1)
return FALSE;
position = gtk_list_tile_get_position (items, tile);
gtk_grid_view_get_section_for_position (items, position, &start, &end);
if (end < position + tile->n_items)
return TRUE;
col = (position - start) % n_columns;
return col + tile->n_items > n_columns;
}
static gboolean
gtk_grid_view_get_position_from_allocation (GtkListBase *base,
int x,
@@ -394,6 +511,7 @@ gtk_grid_view_get_position_from_allocation (GtkListBase *base,
GtkGridView *self = GTK_GRID_VIEW (base);
GtkListTile *tile;
guint pos;
guint col;
tile = gtk_list_item_manager_get_nearest_tile (self->item_manager, x, y);
if (tile == NULL)
@@ -411,44 +529,43 @@ gtk_grid_view_get_position_from_allocation (GtkListBase *base,
}
pos = gtk_list_tile_get_position (self->item_manager, tile);
col = gtk_grid_view_get_column_for_position (self->item_manager, self->n_columns, pos);
if (tile->n_items > 1)
{
int xspacing, yspacing;
unsigned int row_height;
unsigned int row_index;
gtk_list_base_get_border_spacing (base, &xspacing, &yspacing);
/* offset in x direction */
pos += column_index (self, xspacing, MAX (tile->area.width - 1, x - tile->area.x));
if (area)
{
guint col = MIN (column_index (self, xspacing, x), self->n_columns - 1);
area->x = column_start (self, xspacing, col);
area->width = column_end (self, xspacing, col) - area->x;
}
/* offset in y direction */
if (tile->n_items > self->n_columns)
{
guint rows_in_tile = tile->n_items / self->n_columns;
guint row_height = (tile->area.height + yspacing) / rows_in_tile - yspacing;
guint row_index = MIN (tile->area.height - 1, y - tile->area.y) / (row_height + yspacing);
pos += self->n_columns * row_index;
if (area)
{
area->y = tile->area.y + row_index * (row_height + yspacing);
area->height = row_height;
}
row_height = (tile->area.height + yspacing) / rows_in_tile - yspacing;
row_index = MIN (tile->area.height - 1, y - tile->area.y) / (row_height + yspacing);
pos += self->n_columns * row_index;
}
else
{
if (area)
{
area->y = tile->area.y;
area->height = tile->area.height;
}
row_height = tile->area.height;
row_index = 0;
}
col = gtk_grid_view_get_column_for_position (self->item_manager, self->n_columns, pos);
if (area)
{
area->x = column_start (self, xspacing, col);
area->y = tile->area.y + row_index * (row_height + yspacing);
area->width = column_end (self, xspacing, col) - area->x;
area->height = row_height;
}
}
else
{
@@ -490,38 +607,104 @@ gtk_grid_view_get_items_in_rect (GtkListBase *base,
if (area.y >= rect->y + rect->height)
last_row -= self->n_columns;
if (first_column <= last_column && first_row <= last_row)
if (gtk_list_item_manager_get_has_sections (self->item_manager))
{
gtk_bitset_add_rectangle (result,
first_row + first_column,
last_column - first_column + 1,
(last_row - first_row) / self->n_columns + 1,
self->n_columns);
for (unsigned int pos = first_row; pos < last_row + self->n_columns; pos++)
{
unsigned int col;
col = gtk_grid_view_get_column_for_position (self->item_manager,
self->n_columns,
pos);
if (col >= first_column && col <= last_column)
gtk_bitset_add (result, pos);
}
}
else
{
if (first_column <= last_column && first_row <= last_row)
{
gtk_bitset_add_rectangle (result,
first_row + first_column,
last_column - first_column + 1,
(last_row - first_row) / self->n_columns + 1,
self->n_columns);
}
}
return result;
}
static unsigned int
find_previous_item_in_column (GtkGridView *self,
unsigned int position)
{
unsigned int col, pos;
if (position == 0)
return position;
col = gtk_grid_view_get_column_for_position (self->item_manager,
self->n_columns,
position);
pos = position;
do
{
pos--;
if (col == gtk_grid_view_get_column_for_position (self->item_manager,
self->n_columns,
pos))
return pos;
} while (pos > 0);
return position;
}
static unsigned int
find_next_item_in_column (GtkGridView *self,
unsigned int position)
{
unsigned int col;
unsigned int n_items;
n_items = g_list_model_get_n_items (G_LIST_MODEL (gtk_list_item_manager_get_model (self->item_manager)));
col = gtk_grid_view_get_column_for_position (self->item_manager,
self->n_columns,
position);
for (unsigned int p = position + 1; p < n_items; p++)
{
if (col == gtk_grid_view_get_column_for_position (self->item_manager,
self->n_columns,
p))
return p;
}
return position;
}
static guint
gtk_grid_view_move_focus_along (GtkListBase *base,
guint pos,
int steps)
{
GtkGridView *self = GTK_GRID_VIEW (base);
unsigned int prev_pos = pos;
steps *= self->n_columns;
for (unsigned int i = 0; i < abs (steps); i++)
{
if (steps < 0)
pos = find_previous_item_in_column (self, pos);
else
pos = find_next_item_in_column (self, pos);
}
if (steps < 0)
{
if (pos >= self->n_columns)
pos -= MIN (pos, -steps);
}
else
{
guint n_items = gtk_list_base_get_n_items (base);
if (n_items / self->n_columns > pos / self->n_columns)
pos += MIN (n_items - pos - 1, steps);
}
if (prev_pos == pos)
gtk_widget_keynav_failed (GTK_WIDGET (self), steps < 0 ? GTK_DIR_UP : GTK_DIR_DOWN);
return pos;
}
@@ -531,14 +714,19 @@ gtk_grid_view_move_focus_across (GtkListBase *base,
guint pos,
int steps)
{
unsigned int prev_pos = pos;
if (steps < 0)
return pos - MIN (pos, -steps);
pos = pos - MIN (pos, -steps);
else
{
guint n_items = gtk_list_base_get_n_items (base);
pos += MIN (n_items - pos - 1, steps);
}
if (prev_pos == pos)
gtk_widget_keynav_failed (GTK_WIDGET (base), steps < 0 ? GTK_DIR_LEFT : GTK_DIR_RIGHT);
return pos;
}
@@ -564,32 +752,49 @@ gtk_grid_view_get_unknown_row_size (GtkGridView *self,
static void
gtk_grid_view_measure_column_size (GtkGridView *self,
int *minimum,
int *natural)
int *natural,
int *header_minimum,
int *header_natural)
{
GtkOrientation opposite;
GtkListTile *tile;
int min, nat, child_min, child_nat;
int min, nat, header_min, header_nat;
min = 0;
nat = 0;
header_min = 0;
header_nat = 0;
opposite = gtk_list_base_get_opposite_orientation (GTK_LIST_BASE (self));
for (tile = gtk_list_item_manager_get_first (self->item_manager);
tile != NULL;
tile = gtk_rb_tree_node_get_next (tile))
{
int child_min, child_nat;
if (tile->widget == NULL)
continue;
gtk_widget_measure (tile->widget,
opposite, -1,
&child_min, &child_nat, NULL, NULL);
min = MAX (min, child_min);
nat = MAX (nat, child_nat);
if (tile->type == GTK_LIST_TILE_ITEM)
{
min = MAX (min, child_min);
nat = MAX (nat, child_nat);
}
else
{
header_min = MAX (header_min, child_min);
header_nat = MAX (header_nat, child_nat);
}
}
*minimum = min;
*natural = nat;
*header_minimum = header_min;
*header_natural = header_nat;
}
static void
@@ -600,13 +805,14 @@ gtk_grid_view_measure_across (GtkWidget *widget,
{
GtkGridView *self = GTK_GRID_VIEW (widget);
int xspacing;
int col_min, col_nat, header_min, header_nat;
gtk_list_base_get_border_spacing (GTK_LIST_BASE (widget), &xspacing, NULL);
gtk_grid_view_measure_column_size (self, minimum, natural);
gtk_grid_view_measure_column_size (self, &col_min, &col_nat, &header_min, &header_nat);
*minimum = (*minimum + xspacing) * self->min_columns - xspacing;
*natural = (*natural + xspacing) * self->max_columns - xspacing;
*minimum = MAX ((col_min + xspacing) * self->min_columns - xspacing, header_min);
*natural = MAX ((col_nat + xspacing) * self->max_columns - xspacing, header_nat);
}
static guint
@@ -642,7 +848,7 @@ gtk_grid_view_measure_list (GtkWidget *widget,
GtkScrollablePolicy scroll_policy;
GtkListTile *tile;
int height, row_height, child_min, child_nat, column_size, col_min, col_nat;
int xspacing, yspacing;
int xspacing, yspacing, header_min, header_nat;
gboolean measured;
GArray *heights;
guint n_unknown, n_columns;
@@ -654,7 +860,7 @@ gtk_grid_view_measure_list (GtkWidget *widget,
n_unknown = 0;
height = 0;
gtk_grid_view_measure_column_size (self, &col_min, &col_nat);
gtk_grid_view_measure_column_size (self, &col_min, &col_nat, &header_min, &header_nat);
for_size = MAX (for_size, col_min * (int) self->min_columns);
n_columns = gtk_grid_view_compute_n_columns (self, for_size, xspacing, col_min, col_nat);
column_size = (for_size + xspacing) / n_columns - xspacing;
@@ -670,7 +876,7 @@ gtk_grid_view_measure_list (GtkWidget *widget,
{
gtk_widget_measure (tile->widget,
gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
column_size,
gtk_list_tile_is_header (tile) ? for_size : column_size,
&child_min, &child_nat, NULL, NULL);
if (scroll_policy == GTK_SCROLL_MINIMUM)
row_height = MAX (row_height, child_min);
@@ -679,7 +885,10 @@ gtk_grid_view_measure_list (GtkWidget *widget,
measured = TRUE;
}
i += tile->n_items;
if (gtk_list_tile_is_header (tile) || gtk_list_tile_is_footer (tile))
i = n_columns;
else
i += tile->n_items;
if (i >= n_columns)
{
@@ -736,6 +945,48 @@ gtk_grid_view_measure (GtkWidget *widget,
gtk_grid_view_measure_across (widget, for_size, minimum, natural);
}
void
gtk_grid_view_split_tiles_by_columns (GtkListItemManager *items,
guint n_columns)
{
GtkListTile *tile;
for (tile = gtk_list_item_manager_get_first (items);
tile != NULL;
tile = gtk_rb_tree_node_get_next (tile))
{
if (tile->n_items > 1)
{
guint pos, col;
guint remaining;
pos = gtk_list_tile_get_position (items, tile);
col = gtk_grid_view_get_column_for_position (items, n_columns, pos);
if (col > 0)
{
/* Determine if the first row needs to be split off */
remaining = n_columns - col;
if (remaining > 0 && tile->n_items > remaining)
gtk_list_tile_split (items, tile, remaining);
continue;
}
pos += tile->n_items - 1;
col = gtk_grid_view_get_column_for_position (items, n_columns, pos);
if (col < n_columns - 1)
{
/* Determine if the last row needs to be split off */
remaining = n_columns - (col - 1);
if (remaining > 0 && col + 1 < tile->n_items)
tile = gtk_list_tile_split (items, tile, tile->n_items - (col + 1));
}
}
}
}
static void
gtk_grid_view_size_allocate (GtkWidget *widget,
int width,
@@ -746,6 +997,7 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
GtkListTile *tile, *start;
GArray *heights;
int min_row_height, unknown_row_height, row_height, col_min, col_nat;
int header_min, header_nat;
GtkOrientation orientation;
GtkScrollablePolicy scroll_policy;
int y, xspacing, yspacing;
@@ -767,7 +1019,7 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
}
/* step 1: determine width of the list */
gtk_grid_view_measure_column_size (self, &col_min, &col_nat);
gtk_grid_view_measure_column_size (self, &col_min, &col_nat, &header_min, &header_nat);
self->n_columns = gtk_grid_view_compute_n_columns (self,
orientation == GTK_ORIENTATION_VERTICAL ? width : height,
xspacing,
@@ -775,28 +1027,32 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
self->column_width = ((orientation == GTK_ORIENTATION_VERTICAL ? width : height) + xspacing) / self->n_columns - xspacing;
self->column_width = MAX (self->column_width, col_min);
/* step 2: determine height of known rows */
/* step 2: split tiles as required */
gtk_grid_view_split_tiles_by_columns (self->item_manager, self->n_columns);
/* step 3: determine height of known rows */
heights = g_array_new (FALSE, FALSE, sizeof (int));
tile = gtk_list_item_manager_get_first (self->item_manager);
while (tile != NULL)
{
/* if it's a multirow tile, handle it here */
if (tile->n_items > 1 && tile->n_items >= self->n_columns)
if (gtk_grid_view_is_multirow_tile (self->item_manager, self->n_columns, tile) ||
gtk_list_tile_is_header (tile))
{
if (tile->n_items % self->n_columns)
gtk_list_tile_split (self->item_manager, tile, tile->n_items / self->n_columns * self->n_columns);
gtk_list_tile_set_area_size (self->item_manager, tile, 0, 0);
tile = gtk_rb_tree_node_get_next (tile);
continue;
}
/* Not a multirow tile */
i = 0;
row_height = 0;
for (i = 0, start = tile;
i < self->n_columns && tile != NULL;
tile = gtk_rb_tree_node_get_next (tile))
{
g_assert (!gtk_list_tile_is_header (start));
gtk_list_tile_set_area_size (self->item_manager, tile, 0, 0);
if (tile->widget)
{
int min, nat, size;
@@ -809,35 +1065,49 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
else
size = nat;
size = MAX (size, min_row_height);
g_array_append_val (heights, size);
if (tile->type == GTK_LIST_TILE_ITEM)
g_array_append_val (heights, size);
row_height = MAX (row_height, size);
}
if (tile->n_items > self->n_columns - i)
gtk_list_tile_split (self->item_manager, tile, self->n_columns - i);
i += tile->n_items;
if (gtk_list_tile_is_footer (tile))
i = self->n_columns;
else
i += tile->n_items;
}
if (row_height > 0)
{
for (i = 0;
start != tile;
start = gtk_rb_tree_node_get_next (start))
{
unsigned int n_columns;
g_assert (!gtk_list_tile_is_header (start));
if (gtk_list_tile_is_footer (start))
n_columns = self->n_columns - i;
else
n_columns = start->n_items;
gtk_list_tile_set_area_size (self->item_manager,
start,
column_end (self, xspacing, i + start->n_items - 1)
column_end (self, xspacing, i + n_columns - 1)
- column_start (self, xspacing, i),
row_height);
i += start->n_items;
i = (i + n_columns) % self->n_columns;
}
g_assert (i <= self->n_columns);
}
}
/* step 3: determine height of rows with only unknown items */
/* step 4: determine height of rows with only unknown items */
unknown_row_height = gtk_grid_view_get_unknown_row_size (self, heights);
g_array_free (heights, TRUE);
/* step 4: determine height for remaining rows and set each row's position */
g_assert (unknown_row_height > 0);
/* step 5: determine height for remaining rows and set each row's position */
y = 0;
i = 0;
for (tile = gtk_list_item_manager_get_first (self->item_manager);
@@ -848,10 +1118,10 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
tile,
column_start (self, xspacing, i),
y);
if (tile->n_items >= self->n_columns && tile->widget == NULL)
if (gtk_grid_view_is_multirow_tile (self->item_manager, self->n_columns, tile))
{
g_assert (i == 0);
g_assert (tile->n_items % self->n_columns == 0);
gtk_list_tile_set_area_size (self->item_manager,
tile,
column_end (self, xspacing, self->n_columns - 1)
@@ -859,18 +1129,59 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
(unknown_row_height + yspacing) * (tile->n_items / self->n_columns) - yspacing);
y += tile->area.height + yspacing;
}
else if (gtk_list_tile_is_header (tile))
{
int size;
g_assert (i == 0);
if (tile->widget)
{
int min, nat;
gtk_widget_measure (tile->widget,
gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
(self->column_width + xspacing) * self->n_columns,
&min, &nat, NULL, NULL);
if (scroll_policy == GTK_SCROLL_MINIMUM)
size = min;
else
size = nat;
size = MAX (size, min_row_height);
}
else if (gtk_list_item_manager_get_has_sections (self->item_manager))
size = unknown_row_height;
else
size = 0;
gtk_list_tile_set_area_size (self->item_manager,
tile,
column_end (self, xspacing, self->n_columns - 1)
- column_start (self, xspacing, 0),
size);
y += tile->area.height + yspacing;
}
else
{
if (tile->area.height == 0)
unsigned int n_items = tile->n_items;
if (gtk_list_tile_is_footer (tile))
{
/* this case is for the last row - it may not be a full row so it won't
* be a multirow tile but it may have no widgets either */
gtk_list_tile_set_area_size (self->item_manager,
tile,
column_end (self, xspacing, i + tile->n_items - 1) - tile->area.x,
unknown_row_height);
if (i == 0)
n_items = 0;
else
n_items = self->n_columns - i;
}
i += tile->n_items;
if (tile->area.height == 0)
gtk_list_tile_set_area_size (self->item_manager,
tile,
column_end (self, xspacing, i + n_items - 1) - tile->area.x,
unknown_row_height);
i += n_items;
}
if (i >= self->n_columns)
@@ -880,23 +1191,8 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
i = 0;
}
}
/* Add a filler tile for empty space in the bottom right */
if (i > 0)
{
GtkListTile *footer = gtk_list_item_manager_get_last (self->item_manager);
g_assert (gtk_list_tile_is_footer (footer));
tile = gtk_rb_tree_node_get_previous (footer);
gtk_list_tile_set_area_position (self->item_manager,
footer,
column_start (self, xspacing, i),
y);
gtk_list_tile_set_area_size (self->item_manager,
footer,
column_end (self, xspacing, self->n_columns - 1) - footer->area.x,
tile->area.height);
}
/* step 4: allocate the rest */
/* step 6: allocate the rest */
gtk_list_base_allocate (GTK_LIST_BASE (self));
}
@@ -952,6 +1248,7 @@ gtk_grid_view_dispose (GObject *object)
self->item_manager = NULL;
g_clear_object (&self->factory);
g_clear_object (&self->header_factory);
G_OBJECT_CLASS (gtk_grid_view_parent_class)->dispose (object);
}
@@ -974,6 +1271,10 @@ gtk_grid_view_get_property (GObject *object,
g_value_set_object (value, self->factory);
break;
case PROP_HEADER_FACTORY:
g_value_set_object (value, self->header_factory);
break;
case PROP_MAX_COLUMNS:
g_value_set_uint (value, self->max_columns);
break;
@@ -1018,6 +1319,10 @@ gtk_grid_view_set_property (GObject *object,
gtk_grid_view_set_factory (self, g_value_get_object (value));
break;
case PROP_HEADER_FACTORY:
gtk_grid_view_set_header_factory (self, g_value_get_object (value));
break;
case PROP_MAX_COLUMNS:
gtk_grid_view_set_max_columns (self, g_value_get_uint (value));
break;
@@ -1071,6 +1376,8 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
list_base_class->split = gtk_grid_view_split;
list_base_class->create_list_widget = gtk_grid_view_create_list_widget;
list_base_class->prepare_section = gtk_grid_view_prepare_section;
list_base_class->create_header_widget = gtk_grid_view_create_header_widget;
list_base_class->get_allocation = gtk_grid_view_get_allocation;
list_base_class->get_items_in_rect = gtk_grid_view_get_items_in_rect;
list_base_class->get_position_from_allocation = gtk_grid_view_get_position_from_allocation;
@@ -1109,6 +1416,19 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkGridView:header-factory: (attributes org.gtk.Property.get=gtk_grid_view_get_header_factory org.gtk.Property.set=gtk_grid_view_set_header_factory)
*
* Factory for creating header widgets.
*
* Since: 4.12
*/
properties[PROP_HEADER_FACTORY] =
g_param_spec_object ("header-factory", NULL, NULL,
GTK_TYPE_LIST_ITEM_FACTORY,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkGridView:max-columns: (attributes org.gtk.Property.get=gtk_grid_view_get_max_columns org.gtk.Property.set=gtk_grid_view_set_max_columns)
*
@@ -1342,6 +1662,69 @@ gtk_grid_view_set_factory (GtkGridView *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);
}
/**
* gtk_grid_view_get_header_factory: (attributes org.gtk.Method.get_property=header-factory)
* @self: a `GtkGridView`
*
* Gets the factory that's currently used to populate section headers.
*
* Returns: (nullable) (transfer none): The factory in use
*
* Since: 4.12
*/
GtkListItemFactory *
gtk_grid_view_get_header_factory (GtkGridView *self)
{
g_return_val_if_fail (GTK_IS_GRID_VIEW (self), NULL);
return self->header_factory;
}
/**
* gtk_grid_view_set_header_factory: (attributes org.gtk.Method.set_property=header-factory)
* @self: a `GtkGridView`
* @factory: (nullable) (transfer none): the factory to use
*
* Sets the `GtkListItemFactory` to use for populating the
* [class@Gtk.ListHeader] objects used in section headers.
*
* If this factory is set to %NULL, the list will not show section headers.
*
* Since: 4.12
*/
void
gtk_grid_view_set_header_factory (GtkGridView *self,
GtkListItemFactory *factory)
{
gboolean had_sections;
g_return_if_fail (GTK_IS_GRID_VIEW (self));
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
had_sections = gtk_list_item_manager_get_has_sections (self->item_manager);
if (!g_set_object (&self->header_factory, factory))
return;
gtk_list_item_manager_set_has_sections (self->item_manager, factory != NULL);
if (!gtk_grid_view_is_inert (self) &&
had_sections && gtk_list_item_manager_get_has_sections (self->item_manager))
{
GtkListTile *tile;
for (tile = gtk_list_item_manager_get_first (self->item_manager);
tile != NULL;
tile = gtk_rb_tree_node_get_next (tile))
{
if (tile->widget && tile->type == GTK_LIST_TILE_HEADER)
gtk_list_header_widget_set_factory (GTK_LIST_HEADER_WIDGET (tile->widget), factory);
}
}
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADER_FACTORY]);
}
/**
* gtk_grid_view_get_max_columns: (attributes org.gtk.Method.get_property=max-columns)
* @self: a `GtkGridView`
+8
View File
@@ -56,6 +56,14 @@ void gtk_grid_view_set_factory (GtkGridView
GDK_AVAILABLE_IN_ALL
GtkListItemFactory *
gtk_grid_view_get_factory (GtkGridView *self);
GDK_AVAILABLE_IN_4_12
void gtk_grid_view_set_header_factory (GtkGridView *self,
GtkListItemFactory *factory);
GDK_AVAILABLE_IN_4_12
GtkListItemFactory *
gtk_grid_view_get_header_factory (GtkGridView *self);
GDK_AVAILABLE_IN_ALL
guint gtk_grid_view_get_min_columns (GtkGridView *self);
GDK_AVAILABLE_IN_ALL
+45
View File
@@ -0,0 +1,45 @@
/*
* Copyright © 2023 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "gtk/gtktypes.h"
#include "gtk/gtkenums.h"
#include "gtk/gtkgridview.h"
#include "gtk/gtklistitemmanagerprivate.h"
G_BEGIN_DECLS
void gtk_grid_view_get_section_for_position (GtkListItemManager *items,
unsigned int position,
unsigned int *start,
unsigned int *end);
unsigned int gtk_grid_view_get_column_for_position (GtkListItemManager *items,
unsigned int n_columns,
unsigned int position);
gboolean gtk_grid_view_is_multirow_tile (GtkListItemManager *items,
unsigned int n_columns,
GtkListTile *tile);
void gtk_grid_view_split_tiles_by_columns (GtkListItemManager *items,
guint n_columns);
G_END_DECLS
+11 -15
View File
@@ -1970,13 +1970,10 @@ gtk_label_activate_link_open (GtkWidget *widget,
GVariant *parameter)
{
GtkLabel *self = GTK_LABEL (widget);
if (self->select_info)
{
GtkLabelLink *link = self->select_info->context_link;
GtkLabelLink *link = self->select_info->context_link;
if (link)
emit_activate_link (self, link);
}
if (link)
emit_activate_link (self, link);
}
static void
@@ -1985,18 +1982,17 @@ gtk_label_activate_link_copy (GtkWidget *widget,
GVariant *parameter)
{
GtkLabel *self = GTK_LABEL (widget);
if (self->select_info)
GtkLabelLink *link = self->select_info->context_link;
if (link)
{
GtkLabelLink *link = self->select_info->context_link;
GdkClipboard *clipboard;
if (link)
{
GdkClipboard *clipboard;
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_text (clipboard, link->uri);
}
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_text (clipboard, link->uri);
}
else
g_print ("no link ?!\n");
}
static void
+4 -11
View File
@@ -1004,8 +1004,6 @@ gtk_list_item_manager_merge_list_items (GtkListItemManager *self,
* It is not valid for either tile to have 0 items after
* the split.
*
* This function does not update the tiles' areas.
*
* Returns: The new tile
**/
GtkListTile *
@@ -1039,6 +1037,10 @@ gtk_list_tile_split (GtkListItemManager *self,
*
* Note that this only looks forward, but never backward.
*
* A special case here are filler tiles. They only get
* collected, when they are explicitly passed in, but never
* otherwise.
*
* Returns: The next tile or NULL if everything was gc'ed
**/
static GtkListTile *
@@ -1091,15 +1093,6 @@ gtk_list_tile_gc (GtkListItemManager *self,
return tile;
}
/*
* gtk_list_item_manager_gc_tiles:
* @self: the listitemmanager
*
* Removes all tiles of type GTK_LIST_TILE_REMOVED
* and merges item tiles as much as possible.
*
* This function does not update the tiles' areas.
*/
void
gtk_list_item_manager_gc_tiles (GtkListItemManager *self)
{
+2 -5
View File
@@ -1094,7 +1094,6 @@ gtk_menu_button_get_icon_name (GtkMenuButton *menu_button)
* gtk_menu_button_set_always_show_arrow: (attributes org.gtk.Method.set_property=always-show-arrow)
* @menu_button: a `GtkMenuButton`
* @always_show_arrow: whether to show a dropdown arrow even when using an icon
* or a custom child
*
* Sets whether to show a dropdown arrow even when using an icon or a custom
* child.
@@ -1123,11 +1122,9 @@ gtk_menu_button_set_always_show_arrow (GtkMenuButton *menu_button,
* gtk_menu_button_get_always_show_arrow: (attributes org.gtk.Method.get_property=always-show-arrow)
* @menu_button: a `GtkMenuButton`
*
* Gets whether to show a dropdown arrow even when using an icon or a custom
* child.
* Gets whether to show a dropdown arrow even when using an icon.
*
* Returns: whether to show a dropdown arrow even when using an icon or a custom
* child.
* Returns: whether to show a dropdown arrow even when using an icon
*
* Since: 4.4
*/
+1 -1
View File
@@ -1494,7 +1494,7 @@ create_application_page (GtkPrintOperation *op)
memset (&page, 0, sizeof (page));
page.dwSize = sizeof (page);
page.dwFlags = PSP_DLGINDIRECT | PSP_USETITLE | PSP_PREMATURE;
page.hInstance = NULL;
page.hInstance = GetModuleHandle (NULL);
page.pResource = template;
tab_label = op->priv->custom_tab_label;
+2 -5
View File
@@ -809,12 +809,9 @@ gtk_stack_accessible_get_first_accessible_child (GtkAccessible *accessible)
{
GtkStack *stack = GTK_STACK (accessible);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
GtkAccessible *page_accessible = NULL;
GtkStackPage *page = g_ptr_array_index (priv->children, 0);
if (priv->children->len > 0)
page_accessible = GTK_ACCESSIBLE (g_object_ref (g_ptr_array_index (priv->children, 0)));
return page_accessible;
return GTK_ACCESSIBLE (g_object_ref (page));
}
static void
+35 -16
View File
@@ -33,19 +33,38 @@
#include <commctrl.h>
#undef STRICT
extern IMAGE_DOS_HEADER __ImageBase;
static inline HMODULE
this_module ()
{
return (HMODULE) &__ImageBase;
}
/* In practice, resulting DLL will have manifest resource under index 2.
* Fall back to that value if we can't find resource index programmatically.
*/
#define EMPIRIC_MANIFEST_RESOURCE_INDEX 2
static HMODULE gtk_dll;
extern HINSTANCE _gdk_dll_hinstance;
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
gtk_dll = (HMODULE) hinstDLL;
_gdk_dll_hinstance = hinstDLL;
break;
default:
break;
}
return TRUE;
}
static BOOL CALLBACK
find_first_manifest (HMODULE module_handle,
LPCSTR resource_type,
@@ -92,7 +111,7 @@ _gtk_load_dll_with_libgtk3_manifest (const char *dll_name)
DWORD error_code;
resource_name = NULL;
EnumResourceNames (this_module (), RT_MANIFEST, find_first_manifest,
EnumResourceNames (gtk_dll, RT_MANIFEST, find_first_manifest,
(LONG_PTR) &resource_name);
if (resource_name == NULL)
@@ -103,7 +122,7 @@ _gtk_load_dll_with_libgtk3_manifest (const char *dll_name)
activation_ctx_descriptor.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID |
ACTCTX_FLAG_HMODULE_VALID |
ACTCTX_FLAG_SET_PROCESS_DEFAULT;
activation_ctx_descriptor.hModule = this_module ();
activation_ctx_descriptor.hModule = gtk_dll;
activation_ctx_descriptor.lpResourceName = resource_name;
activation_ctx_handle = CreateActCtx (&activation_ctx_descriptor);
error_code = GetLastError ();
@@ -111,7 +130,7 @@ _gtk_load_dll_with_libgtk3_manifest (const char *dll_name)
if (activation_ctx_handle == INVALID_HANDLE_VALUE &&
error_code != ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET)
g_warning ("Failed to CreateActCtx for module %p, resource %p: %lu",
this_module (), resource_name, GetLastError ());
gtk_dll, resource_name, GetLastError ());
else if (error_code != ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET)
{
activation_cookie = 0;
@@ -138,7 +157,7 @@ _gtk_get_libdir (void)
static char *gtk_libdir = NULL;
if (gtk_libdir == NULL)
{
char *root = g_win32_get_package_installation_directory_of_module (this_module ());
char *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
char *slash = strrchr (root, '\\');
if (slash != NULL &&
g_ascii_strcasecmp (slash + 1, ".libs") == 0)
@@ -169,7 +188,7 @@ _gtk_get_localedir (void)
while (*--p != '/')
;
root = g_win32_get_package_installation_directory_of_module (this_module ());
root = g_win32_get_package_installation_directory_of_module (gtk_dll);
temp = g_build_filename (root, p, NULL);
g_free (root);
@@ -188,7 +207,7 @@ _gtk_get_datadir (void)
static char *gtk_datadir = NULL;
if (gtk_datadir == NULL)
{
char *root = g_win32_get_package_installation_directory_of_module (this_module ());
char *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
gtk_datadir = g_build_filename (root, "share", NULL);
g_free (root);
}
@@ -202,7 +221,7 @@ _gtk_get_sysconfdir (void)
static char *gtk_sysconfdir = NULL;
if (gtk_sysconfdir == NULL)
{
char *root = g_win32_get_package_installation_directory_of_module (this_module ());
char *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
gtk_sysconfdir = g_build_filename (root, "etc", NULL);
g_free (root);
}
@@ -215,7 +234,7 @@ _gtk_get_data_prefix (void)
{
static char *gtk_data_prefix = NULL;
if (gtk_data_prefix == NULL)
gtk_data_prefix = g_win32_get_package_installation_directory_of_module (this_module ());
gtk_data_prefix = g_win32_get_package_installation_directory_of_module (gtk_dll);
return gtk_data_prefix;
}
+1 -7
View File
@@ -5947,9 +5947,6 @@ gtk_window_get_mnemonics_visible (GtkWindow *window)
* @setting: the new value
*
* Sets whether mnemonics are supposed to be visible.
*
* This property is maintained by GTK based on user input,
* and should not be set by applications.
*/
void
gtk_window_set_mnemonics_visible (GtkWindow *window,
@@ -6035,14 +6032,11 @@ unset_focus_visible (gpointer data)
}
/**
* gtk_window_set_focus_visible: (attributes org.gtk.Method.set_property=focus-visible)
* gtk_window_set_focus_visible: (attributes org.gtk.MEthod.set_property=focus-visible)
* @window: a `GtkWindow`
* @setting: the new value
*
* Sets whether focus rectangles are supposed to be visible.
*
* This property is maintained by GTK based on user input,
* and should not be set by applications.
*/
void
gtk_window_set_focus_visible (GtkWindow *window,
@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="@GTK_MANIFEST_VERSION@"
processorArchitecture="*"
name="org.gnome.GTK"
version="1.0.0.0"
processorArchitecture="@EXE_MANIFEST_ARCHITECTURE@"
name="libgtk3"
type="win32"
/>
<description>GTK is a multi-platform GUI toolkit based on GObject</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
processorArchitecture="@EXE_MANIFEST_ARCHITECTURE@"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
+3 -5
View File
@@ -1014,9 +1014,7 @@ gtkversion_cdata.set('GTK_VERSION', gtk_version)
gtkversion_cdata.set('GTK_API_VERSION', gtk_api_version)
if host_machine.system() == 'windows'
v = gtk_binary_version.split('.')
gtk_manifest_version = '.'.join(v.get(0, '0'), v.get(1, '0'), v.get(2, '0'), v.get(3, '0'))
gtkversion_cdata.set('GTK_MANIFEST_VERSION', gtk_manifest_version)
gtkversion_cdata.set('EXE_MANIFEST_ARCHITECTURE', '*')
endif
gtkversion = configure_file(input: 'gtkversion.h.in',
@@ -1099,8 +1097,8 @@ if win32_enabled
configuration: gtkversion_cdata,
)
win32_manifest = configure_file(input: 'libgtk.manifest.in',
output: 'libgtk.manifest',
win32_manifest = configure_file(input: 'libgtk4.manifest.in',
output: 'libgtk4.manifest',
configuration: gtkversion_cdata,
)
+27 -27
View File
@@ -1,32 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk40">
<object class="GtkFilterListModel" id="filter_model">
<signal name="notify::pending" handler="rows_changed_cb" object="GtkFontChooserWidget" swapped="1"/>
<property name="incremental">1</property>
<property name="filter">
<object class="GtkEveryFilter" id="multi_filter">
<child>
<object class="GtkStringFilter">
<binding name="search">
<lookup name="text">search_entry</lookup>
</binding>
<property name="expression">
<closure type="gchararray" swapped="1" function="get_font_name"/>
</property>
</object>
</child>
<child>
<object class="GtkCustomFilter" id="custom_filter"/>
</child>
<child>
<object class="GtkCustomFilter" id="user_filter"/>
</child>
</object>
</property>
<object class="GtkSingleSelection" id="selection">
<signal name="notify::selected-item" handler="selection_changed_cb" object="GtkFontChooserWidget" swapped="0"/>
<signal name="items-changed" handler="rows_changed_cb" object="GtkFontChooserWidget" swapped="1"/>
<property name="model">
<object class="GtkSingleSelection" id="selection">
<signal name="notify::selected-item" handler="selection_changed_cb" object="GtkFontChooserWidget" swapped="0"/>
<signal name="items-changed" handler="rows_changed_cb" object="GtkFontChooserWidget" swapped="1"/>
<object class="GtkFilterListModel" id="filter_model">
<signal name="notify::pending" handler="rows_changed_cb" object="GtkFontChooserWidget" swapped="1"/>
<property name="incremental">1</property>
<property name="filter">
<object class="GtkEveryFilter" id="multi_filter">
<child>
<object class="GtkStringFilter">
<binding name="search">
<lookup name="text">search_entry</lookup>
</binding>
<property name="expression">
<closure type="gchararray" swapped="1" function="get_font_name"/>
</property>
</object>
</child>
<child>
<object class="GtkCustomFilter" id="custom_filter"/>
</child>
<child>
<object class="GtkCustomFilter" id="user_filter"/>
</child>
</object>
</property>
</object>
</property>
</object>
@@ -141,7 +141,7 @@
<property name="has-frame">1</property>
<child>
<object class="GtkListView" id="family_face_list">
<property name="model">filter_model</property>
<property name="model">selection</property>
<signal name="activate" handler="row_activated_cb" swapped="no"/>
<property name="factory">
<object class="GtkBuilderListItemFactory">
+22 -18
View File
@@ -35,7 +35,7 @@ msgstr ""
"Project-Id-Version: gtk+ 2.8.2\n"
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/gtk/-/issues/\n"
"POT-Creation-Date: 2023-05-12 13:13+0000\n"
"PO-Revision-Date: 2023-05-30 11:18+0100\n"
"PO-Revision-Date: 2023-05-12 11:18+0100\n"
"Last-Translator: Jordi Mas i Hernàndez <jmas@softcatala.org>\n"
"Language-Team: Catalan <tradgnome@softcatala.org>\n"
"Language: ca\n"
@@ -3275,52 +3275,44 @@ msgid "Initial state"
msgstr "Estat inicial"
#: gtk/gtkprintoperation.c:1684
# N.T.: Usat com a nom de pestanya
msgctxt "print operation status"
msgid "Preparing to print"
msgstr "Preparant-se per a imprimir"
msgstr "S'està preparant per a imprimir"
#: gtk/gtkprintoperation.c:1685
# N.T.: Usat com a nom de pestanya
msgctxt "print operation status"
msgid "Generating data"
msgstr "Generant les dades"
msgstr "S'estan generant les dades"
#: gtk/gtkprintoperation.c:1686
# N.T.: Usat com a nom de pestanya
msgctxt "print operation status"
msgid "Sending data"
msgstr "Enviant les dades"
msgstr "S'estan enviant les dades"
#: gtk/gtkprintoperation.c:1687
# N.T.: Usat com a nom de pestanya
msgctxt "print operation status"
msgid "Waiting"
msgstr "Esperant"
msgstr "S'està esperant"
# N.T.: Usat com a nom de pestanya
#: gtk/gtkprintoperation.c:1688
msgctxt "print operation status"
msgid "Blocking on issue"
msgstr "Bloquejat per un problema"
msgstr "Bloquejat a causa d'un problema"
# N.T.: Usat com a nom de pestanya
#: gtk/gtkprintoperation.c:1689
msgctxt "print operation status"
msgid "Printing"
msgstr "Imprimint"
msgstr "S'està imprimint"
# N.T.: Usat com a nom de pestanya
#: gtk/gtkprintoperation.c:1690
msgctxt "print operation status"
msgid "Finished"
msgstr "Finalitzat"
msgstr "S'ha finalitzat"
# N.T.: Usat com a nom de pestanya
#: gtk/gtkprintoperation.c:1691
msgctxt "print operation status"
msgid "Finished with error"
msgstr "Finalitzat amb error"
msgstr "S'ha finalitzat amb error"
#: gtk/gtkprintoperation.c:2234
#, c-format
@@ -6358,7 +6350,7 @@ msgstr "_Ordenació de les pàgines:"
#: gtk/ui/gtkprintunixdialog.ui:474
msgid "_Only print:"
msgstr "_Imprimeix només:"
msgstr "_Només imprimeix:"
#: gtk/ui/gtkprintunixdialog.ui:490
msgid "All sheets"
@@ -7439,3 +7431,15 @@ msgstr ""
"No hi ha el fitxer índex de tema a «%s».\n"
"Si realment voleu crear una memòria cau d'icones aquí, utilitzeu --ignore-theme-index.\n"
#~ msgid "Tab"
#~ msgstr "Pestanya"
# FIXME
#~ msgid "Print to LPR"
#~ msgstr "Imprimeix a LPR"
#~ msgid "Pages Per Sheet"
#~ msgstr "Pàgines per full"
#~ msgid "Command Line"
#~ msgstr "Línia d'ordres"
-4
View File
@@ -25,7 +25,3 @@ f {
g {
font-family: Macaroni al dente, Tomato sauce;
}
h {
font-family: 楷体;
}
-4
View File
@@ -25,7 +25,3 @@ f {
g {
font-family: "Macaroni al dente", "Tomato sauce";
}
h {
font-family: "楷体";
}
-6
View File
@@ -2,7 +2,6 @@
#include <epoxy/gl.h>
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkgltextureprivate.h"
static cairo_surface_t *
make_surface (void)
@@ -203,11 +202,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
texture = gdk_gl_texture_builder_build (builder, NULL, NULL);
g_assert_true (gdk_gl_texture_get_context (GDK_GL_TEXTURE (texture)) == context);
g_assert_true (gdk_gl_texture_get_id (GDK_GL_TEXTURE (texture)) == id);
g_assert_false (gdk_gl_texture_has_mipmap (GDK_GL_TEXTURE (texture)));
g_assert_true (gdk_gl_texture_get_sync (GDK_GL_TEXTURE (texture)) == sync);
data = g_malloc0 (64 * 64 * 4);
gdk_texture_download (texture, data, 64 * 4);
File diff suppressed because it is too large Load Diff
-55
View File
@@ -717,60 +717,6 @@ test_enabled (void)
g_object_unref (g_object_ref_sink (text));
}
#define MY_TYPE_GTK_ACTIONABLE (my_gtk_actionable_get_type ())
G_DECLARE_FINAL_TYPE (MyGtkActionable, my_gtk_actionable, MY, GTK_ACTIONABLE, GtkButton)
struct _MyGtkActionable
{
GtkButton parent_instance;
};
G_DEFINE_FINAL_TYPE (MyGtkActionable, my_gtk_actionable, GTK_TYPE_BUTTON);
static void
test_cb (GtkWidget *sender,
const char *name,
GVariant *param)
{
}
static void
my_gtk_actionable_init (MyGtkActionable *actionable)
{
gtk_actionable_set_action_name (GTK_ACTIONABLE (actionable), "test.test");
}
static void
my_gtk_actionable_class_init (MyGtkActionableClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_install_action (widget_class, "test.test", NULL, test_cb);
}
/* Test that actions are correctly notified after reparenting */
static void
test_reparenting (void)
{
GtkWidget *window, *actionable;
window = gtk_window_new ();
actionable = g_object_new (MY_TYPE_GTK_ACTIONABLE, NULL);
gtk_window_set_child (GTK_WINDOW (window), actionable);
g_assert_true (gtk_widget_get_sensitive (actionable));
g_object_ref (actionable);
gtk_window_set_child (GTK_WINDOW (window), NULL);
g_assert_false (gtk_widget_get_sensitive (actionable));
gtk_window_set_child (GTK_WINDOW (window), actionable);
g_object_unref (actionable);
g_assert_true (gtk_widget_get_sensitive (actionable));
g_object_unref (window);
}
int
main (int argc,
char *argv[])
@@ -786,7 +732,6 @@ main (int argc,
g_test_add_func ("/action/overlap2", test_overlap2);
g_test_add_func ("/action/introspection", test_introspection);
g_test_add_func ("/action/enabled", test_enabled);
g_test_add_func ("/action/reparenting", test_reparenting);
return g_test_run();
}
-114
View File
@@ -23,7 +23,6 @@
static GQuark number_quark;
static GQuark changes_quark;
static GQuark selection_quark;
static guint
get (GListModel *model,
@@ -53,25 +52,6 @@ model_to_string (GListModel *model)
return g_string_free (string, FALSE);
}
static char *
selection_to_string (GListModel *model)
{
GString *string = g_string_new (NULL);
guint i;
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
if (!gtk_selection_model_is_selected (GTK_SELECTION_MODEL (model), i))
continue;
if (string->len > 0)
g_string_append (string, " ");
g_string_append_printf (string, "%u", get (model, i));
}
return g_string_free (string, FALSE);
}
static GListStore *
new_store (guint start,
guint end,
@@ -113,14 +93,6 @@ add (GListStore *store,
g_string_set_size (changes, 0); \
}G_STMT_END
#define assert_selection(model, expected) G_STMT_START{ \
char *s = selection_to_string (G_LIST_MODEL (model)); \
if (!g_str_equal (s, expected)) \
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#model " == " #expected, s, "==", expected); \
g_free (s); \
}G_STMT_END
static GListStore *
new_empty_store (void)
{
@@ -589,90 +561,6 @@ test_sections (void)
g_object_unref (sorted);
}
static void
selection_changed (GListModel *model,
guint position,
guint n_items,
GString *changes)
{
if (changes->len)
g_string_append (changes, ", ");
g_string_append_printf (changes, "%u:%u", position, n_items);
}
#define assert_selection_changes(model, expected) G_STMT_START{ \
GString *chchanges = g_object_get_qdata (G_OBJECT (model), selection_quark); \
if (!g_str_equal (chchanges->str, expected)) \
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#model " == " #expected, changes->str, "==", expected); \
g_string_set_size (chchanges, 0); \
}G_STMT_END
static void
test_selections (void)
{
GListStore *store;
GtkSelectionModel *selection;
GtkFilter *filter;
GtkFilterListModel *filtermodel;
GString *changes;
store = new_store (1, 10, 1);
selection = GTK_SELECTION_MODEL (gtk_multi_selection_new (G_LIST_MODEL (store)));
filter = GTK_FILTER (gtk_custom_filter_new (is_larger_than, GUINT_TO_POINTER (5), NULL));
filtermodel = gtk_filter_list_model_new (G_LIST_MODEL (selection), filter);
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT (filtermodel), selection_quark, changes, free_changes);
g_signal_connect (filtermodel, "selection-changed", G_CALLBACK (selection_changed), changes);
assert_selection (filtermodel, "");
g_assert_false (gtk_selection_model_is_selected (GTK_SELECTION_MODEL (filtermodel), 3));
gtk_selection_model_select_item (selection, 3, FALSE);
assert_selection (selection, "4");
assert_selection (filtermodel, "");
g_assert_false (gtk_selection_model_is_selected (GTK_SELECTION_MODEL (filtermodel), 3));
assert_selection_changes (filtermodel, "");
gtk_selection_model_select_item (selection, 8, FALSE);
assert_selection (selection, "4 9");
assert_selection (filtermodel, "9");
g_assert_true (gtk_selection_model_is_selected (GTK_SELECTION_MODEL (filtermodel), 3));
assert_selection_changes (filtermodel, "3:1");
gtk_selection_model_select_item (GTK_SELECTION_MODEL (filtermodel), 0, FALSE);
assert_selection (selection, "6 9");
assert_selection (filtermodel, "6 9");
assert_selection_changes (filtermodel, "0:1");
gtk_selection_model_select_item (GTK_SELECTION_MODEL (filtermodel), 1, TRUE);
assert_selection (selection, "7");
assert_selection (filtermodel, "7");
assert_selection_changes (filtermodel, "0:4");
gtk_selection_model_select_all (GTK_SELECTION_MODEL (filtermodel));
assert_selection (selection, "6 7 8 9 10");
assert_selection (filtermodel, "6 7 8 9 10");
assert_selection_changes (filtermodel, "0:5");
gtk_selection_model_unselect_range (GTK_SELECTION_MODEL (filtermodel), 1, 3);
assert_selection (selection, "6 10");
assert_selection (filtermodel, "6 10");
assert_selection_changes (filtermodel, "1:3");
gtk_selection_model_select_range (GTK_SELECTION_MODEL (filtermodel), 0, 3, TRUE);
assert_selection (selection, "6 7 8");
assert_selection (filtermodel, "6 7 8");
assert_selection_changes (filtermodel, "1:4");
g_object_unref (filtermodel);
}
int
main (int argc, char *argv[])
{
@@ -681,7 +569,6 @@ main (int argc, char *argv[])
number_quark = g_quark_from_static_string ("Hell and fire was spawned to be released.");
changes_quark = g_quark_from_static_string ("What did I see? Can I believe what I saw?");
selection_quark = g_quark_from_static_string ("Mana mana, badibidibi");
g_test_add_func ("/filterlistmodel/create", test_create);
g_test_add_func ("/filterlistmodel/empty_set_filter", test_empty_set_filter);
@@ -690,7 +577,6 @@ main (int argc, char *argv[])
g_test_add_func ("/filterlistmodel/empty", test_empty);
g_test_add_func ("/filterlistmodel/add_remove_item", test_add_remove_item);
g_test_add_func ("/filterlistmodel/sections", test_sections);
g_test_add_func ("/filterlistmodel/selections", test_selections);
return g_test_run ();
}
+87 -6
View File
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include "gtk/gtklistitemmanagerprivate.h"
#include "gtk/gtklistbaseprivate.h"
#include "gtk/gtkgridviewprivate.h"
static GListModel *
create_source_model (guint min_size, guint max_size)
@@ -374,7 +375,66 @@ print_changes_cb (GListModel *model,
}
static void
test_exhaustive (void)
check_tile_invariants_for_columns (GtkListItemManager *items,
unsigned int n_columns)
{
GtkListTile *tile;
for (tile = gtk_list_item_manager_get_first (items);
tile != NULL;
tile = gtk_rb_tree_node_get_next (tile))
{
g_assert (tile->type != GTK_LIST_TILE_REMOVED);
if (tile->n_items > 1)
{
unsigned int pos, col, col2, end;
pos = gtk_list_tile_get_position (items, tile);
col = gtk_grid_view_get_column_for_position (items, n_columns, pos);
col2 = gtk_grid_view_get_column_for_position (items, n_columns, pos + tile->n_items - 1);
gtk_grid_view_get_section_for_position (items, pos + tile->n_items - 1, NULL, &end);
if (gtk_grid_view_is_multirow_tile (items, n_columns, tile))
{
g_assert_true (col == 0);
g_assert_true (col2 == n_columns - 1 || pos + tile->n_items == end);
}
else
{
g_assert_true (col2 == col + tile->n_items - 1);
g_assert_true (col2 <= n_columns);
}
}
}
}
static void
check_grid_view (GtkListItemManager *items)
{
for (unsigned int n_columns = 1; n_columns < 10; n_columns++)
{
if (g_test_verbose ())
g_test_message ("GC");
gtk_list_item_manager_gc_tiles (items);
if (g_test_verbose ())
print_list_item_manager_tiles (items);
if (g_test_verbose ())
g_test_message ("grid split %u columns", n_columns);
gtk_grid_view_split_tiles_by_columns (items, n_columns);
if (g_test_verbose ())
print_list_item_manager_tiles (items);
check_tile_invariants_for_columns (items, n_columns);
}
}
static void
test_exhaustive (gboolean grid)
{
GtkListItemTracker *trackers[N_TRACKERS];
GListStore *store;
@@ -412,9 +472,14 @@ test_exhaustive (void)
switch (g_test_rand_int_range (0, 6))
{
case 0:
if (g_test_verbose ())
g_test_message ("GC and checking");
check_list_item_manager (items, trackers, N_TRACKERS);
if (grid)
check_grid_view (items);
else
{
if (g_test_verbose ())
g_test_message ("GC and checking");
check_list_item_manager (items, trackers, N_TRACKERS);
}
break;
case 1:
@@ -484,7 +549,10 @@ test_exhaustive (void)
}
}
check_list_item_manager (items, trackers, N_TRACKERS);
if (grid)
check_grid_view (items);
else
check_list_item_manager (items, trackers, N_TRACKERS);
for (i = 0; i < N_TRACKERS; i++)
gtk_list_item_tracker_free (items, trackers[i]);
@@ -492,6 +560,18 @@ test_exhaustive (void)
gtk_window_destroy (GTK_WINDOW (widget));
}
static void
test_exhaustive_list (void)
{
test_exhaustive (FALSE);
}
static void
test_exhaustive_grid (void)
{
test_exhaustive (TRUE);
}
int
main (int argc, char *argv[])
{
@@ -499,7 +579,8 @@ main (int argc, char *argv[])
g_test_add_func ("/listitemmanager/create", test_create);
g_test_add_func ("/listitemmanager/create_with_items", test_create_with_items);
g_test_add_func ("/listitemmanager/exhaustive", test_exhaustive);
g_test_add_func ("/listitemmanager/exhaustive", test_exhaustive_list);
g_test_add_func ("/gridview/split", test_exhaustive_grid);
return g_test_run ();
}
+2 -2
View File
@@ -78,7 +78,7 @@ quit_iteration_loop (gpointer user_data)
}
static void
timed_loop (guint millis)
wait (guint millis)
{
gboolean keep_running = TRUE;
@@ -145,7 +145,7 @@ generate_focus_chain (GtkWidget *window,
}
g_string_append_printf (output, "%s\n", name);
timed_loop (100);
wait (100);
count++;
if (!first)