Compare commits

..
Author SHA1 Message Date
a72f1efc63 Bump version to 2.24.34 2026-10-19 18:10:00 +02:00
c1872f2e96 gdkrgb: no vector code for CPUs it is not for
Every set of vector instructions was compiled on every system, as an
empty function where it could not be built: MMX on PowerPC, AltiVec on
x86.  And a build for a CPU that has SSE2 anyway (x86-64, or -msse2 and
later in CFLAGS) carried the MMX code, which SSE2 replaces wherever it
runs; one for ARM with NEON carried ARMv6 code the same way.

configure now builds only the sets of the CPU family built for, and
none that a set the build can take for granted does entirely: no MMX
where SSE2 is there anyway, no ARMv6 where NEON is.  AArch64, where the
NEON file was simply compiled without flags, is looked at like the
others.  The empty stand-ins are gone, and so are the files from the
MSVC makefile, where none of them could be built.
2026-10-19 18:01:54 +02:00
fb2da8786c filechooser: MCI video in a window of ours, and by extension
Tried under Wine: "put window at" left the video window of MCI where
it was, at the top left of the dialog and at the size of the video.  MCI
now draws into a child window we make and move over the preview, with
"window handle" and "put destination", which every version knows.

Where DirectShow (the mpegvideo device) cannot open a file, the device
MCI has for its extension takes it: waveaudio for WAV, the sequencer for
MIDI.  And as the type of a file on Windows is its extension, and not
every system has a MIME type in the registry for .avi or .mp3, sound and
video are also told by a short list of extensions.
2026-10-19 17:26:08 +02:00
8bf037a864 po: the new strings from GTK 3, Caja and Nautilus
Strings of the fork that GTK 3, Caja or Nautilus have too, as the labels
of the file information ("Type:", "Location:", "Dimensions:"...),
"Audio/Video", "Open With %s", the emoji and file names messages, now
come with their translations from there, in this order, where those are
complete and not fuzzy: 6054 strings in 104 languages.  Obsolete entries
of the same strings make room for them.

German gets the strings no one else has yet.
2026-10-19 16:36:26 +02:00
82361cfd6f filechooser: the preview panel as Caja's information pane
The name stands under the picture in bold and centred, and below the
details a button opens the file with the program the system has for its
type, "Open With ...", both as in the information pane of Caja.  The
string comes translated from there.

gtkmain.h is included for gtk_get_current_event_time(); on Windows no
other header brought it in.
2026-10-19 16:34:00 +02:00
3f065539f5 filechooser: a bar to seek in sound and video
Under the picture of what plays, a bar shows where it is and moves it
there when dragged, with the time beside the buttons ("0:12 / 1:30").
GStreamer and the Media Control Interface seek themselves, xine starts
playing at the time; FFmpeg starts its two programs again from there,
which is why a seek waits until the bar rests for a moment.  The length
comes from ffprobe where it is installed; without it, the bar stays
off.

GStreamer seeks to the nearest key frame, which is what weak machines
manage quickly.
2026-10-19 16:19:32 +02:00
1dd0ceb854 filechooser: the preview panel takes the width it is given
As in Caja and Nautilus, a handle between the files and the panel beside
them makes the panel wider or narrower, from 160 pixels to half of the
space; the width is kept with the other settings.  The picture grows
with it, up to the 256 pixels of a large thumbnail, and the lines of
information wrap to it.
2026-10-19 16:19:25 +02:00
cf9fab57cc filechooser: play sound and video in the preview
Sound and video files get a play/pause and a stop button under their
picture in the panel beside the files.  Nothing plays before they are
pressed, and nothing is loaded before: GTK+ needs none of this to build
or to run, it uses what it finds installed.

 - GStreamer 1.x, opened as a library where it uses the same GLib as
   the program (on Linux and the BSDs, and from Homebrew or MacPorts).
   It scales the pictures to the size of the preview itself.
 - xine-lib 1.2, opened as a library, with its raw video output.
 - FFmpeg, as the programs: ffmpeg decodes the pictures into a pipe at
   25 a second and the size of the preview, ffplay plays the sound;
   pausing stops both.
 - On Windows the Media Control Interface every version has, from 3.1
   on, with its video window put over the preview.

The preferences have a switch for all of it and, as the panel, a choice
of what plays.  Where nothing is installed, the panel says what to
install.  The buttons take their icons and tooltips from the stock items
Play, Pause and Stop, so they are translated already.
2026-10-19 16:11:36 +02:00
07d7ebbf84 filechooser: more about the file beside the preview
The panel beside the files lists, as the file managers do: the type, the
size, where the file is, the size of a picture (from its thumbnail),
when it was changed, read and made, its owner and group, and where a
link points.  What the list does not know yet is asked of GIO in the
background, so a slow disk or network share holds nothing up.

The name of a picture format the system has no name for is now found
from its MIME type; before, the file itself was read for it, on the
main thread.
2026-10-19 16:09:26 +02:00
fd5c1f403f introspection: the old API in Gtk-2.0.gir again
Since f0d1c05ea the scanner got -DGTK_DISABLE_DEPRECATED, and
gtktextlayout.h, gtkprivate.h and gtkmarshal.h were left out, so
Gtk-2.0.gir lost everything deprecated that 2.24.33 had in it: GtkCList,
GtkCTree, GtkOptionMenu, GtkComboBoxEntry, the rulers, GtkItemFactory,
gtk_signal_*, GtkTextLayout... 592 functions and types.  Programs in
Python or JavaScript that still use them broke.

The scanner gets -UGDK_DISABLE_DEPRECATED -UGTK_DISABLE_DEPRECATED again
as before, and the headers come back; the warnings that came with them
are fixed by the annotations of the commit before.
2026-10-19 15:59:37 +02:00
c9aafbc940 introspection: annotate the old API
The deprecated API of GTK+ 2 (GtkCList, GtkCTree, GtkItemFactory, the
gtk_signal_ and gtk_type_ functions, the old toolbar calls...) lacked
annotations g-ir-scanner asks for: transfer of returned objects, the
scope of callbacks, the types in lists, the hooks that return the old
hook.  92 warnings with --warn-all, and 74 functions bindings could not
call.  Only comments change.

Two functions stay out of reach, as before: gtk_ctree_export_to_gnode()
and gtk_text_layout_get_line_display() return structures that are freed
in ways that need a boxed type.
2026-10-19 15:59:30 +02:00
cc08634511 x11: pass drags on to the windows plugins make in ours
Plugin UIs (LV2 through suil, VST, JUCE, LSP) draw in X windows of their
own, made inside a window of the host.  A drag source only ever talks to
the toplevel, so the plugin never heard of a drag over it, and dropping
a file on it did nothing (GNOME/gtk#2329).

The XEmbed specification asks the embedder to act as the drag-and-drop
proxy of its client.  Now, while a drag is over a window that GDK does
not know and that is XdndAware, its XdndEnter, XdndPosition, XdndLeave
and XdndDrop go on to it.  They name our toplevel as the source, so its
answers come back here even from plugins that put their own window in
them, and they go on to the real source with ours.  GTK meanwhile sees
the drag leave its widgets, and its own answers are held back.

Clients of a GtkSocket that GDK knows as foreign windows are still left
to the proxy GTK has for them.  A toplevel without X windows inside,
which most are, is asked that once per drag and then costs nothing.

A GtkSocket now makes its toplevel take drags once something is
embedded, as the plugin may make its window later.
2026-10-19 15:49:32 +02:00
e2e6e8df6e thumbnails: give up between the slow steps too
Reading the size of a picture and scanning a JPEG each wait for the disk,
which on a slow USB stick or a busy NFS server takes a while.  A request
that is no longer wanted now ends after the step it is in, not only
between the chunks of decoding.
2026-10-19 15:37:56 +02:00
4bbb723012 thumbnails: ask the installed thumbnailers for other files
What gdk-pixbuf cannot read, a PDF, a video, a WebP without its loader,
now gets its thumbnail from the thumbnailers of the freedesktop.org
thumbnailer specification, if one is installed for its type.  They run
as programs of their own, one at a time like everything here, and are
killed when the file scrolls out of sight or after 20 seconds.

Their pictures are made no bigger than asked, as some of them ignore
the size.  A failure is only remembered when the thumbnailer ran and
gave nothing, not when it was stopped or could not be started.

On Windows and macOS, documents and videos are asked of the shell's
cache and of Quick Look; a miss there is not remembered, as the shell
may have it later.
2026-10-19 15:37:56 +02:00
0c2f6c9ac8 gdkrgb: section headings as plain comments
They began with /**, which g-ir-scanner takes for documentation and
reports as errors.
2026-10-19 15:12:40 +02:00
233f6fec3a introspection: give the scanner the flags from AM_CPPFLAGS
Since INCLUDES became AM_CPPFLAGS, the GIR CFLAGS still named the empty
INCLUDES, so g-ir-scanner found neither GLib nor the other headers and
no .gir was made.
2026-10-19 15:08:00 +02:00
d9437da8dd cups: the request flags as unsigned bit-fields
A gint of one bit holds 0 and -1, so TRUE did not fit.
2026-10-19 14:48:45 +02:00
7922aeff74 tests, doc-shooter: ABS for a time_t, no unused colour sums 2026-10-19 14:48:24 +02:00
d143858abc gdkwindow-x11, imcontextxim: drop a dead mask and a self-assignment 2026-10-19 14:48:24 +02:00
08c987975b gdkgc-x11: the XCopyGC mask without shifting a negative value 2026-10-19 14:48:24 +02:00
bb7df35bfe x11: Motif DnD bytes and dash lengths as unsigned bytes
Values past 127 went into plain char, where they don't fit.
2026-10-19 14:48:24 +02:00
5b18315e87 alias scripts: plain tests instead of macros that expand to defined
IN_FILE and IN_HEADER were defined as "defined", which is undefined
behaviour; clang warned about it some thousand times per build.  The
generated files now test defined() directly, with the same result.
2026-10-19 14:43:29 +02:00
fc9f73926f scrolling: go smoothly past handlers that let the wheel through
A program's widget with its own scroll handler kept the smooth events of
a high-resolution wheel from the scrolled window around it, so a canvas
like GnomeCanvas in xournal scrolled in whole steps (issue #22).  Once
its handler lets a whole step through to the scrolled window, with the
same modifiers, the smooth events go past it from then on; it still gets
every step, and when it takes one, the smooth events stop going past it.
2026-10-19 14:30:17 +02:00
0224e940a0 gail tests: table cells and text boundaries without deprecated calls
ATK 2.12 deprecated the index, row and column calls of AtkTable for
AtkTableCell, and ATK 2.10 the text calls by boundary; gail has neither
replacement, and these tests check its implementations of the old ones.
With such ATK they now ask those implementations directly.
2026-10-19 14:14:52 +02:00
4503f3e916 gail tests: hear the focus through the focused state
ATK 2.9.4 deprecated the focus trackers and the focus handlers of
AtkComponent for the state-change signal.  testfocus.h gives the test
modules and ferret the object whose "focused" state is set (by a global
event listener, which gail has), testobject listens to state-change on
the objects; with older ATK both keep the old calls.
2026-10-19 14:14:10 +02:00
9edcc1e497 testcomponent: compare position and size without hiding warnings
The deprecated ATK calls were wrapped in G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
with ATK 2.12 and later the test now asks the implementations they lead
to, before that the calls themselves.
2026-10-19 14:12:26 +02:00
fe1839c6a0 build: gettext infrastructure from gettext 0.22.5
The m4 files and the po Makefiles were from gettext 0.18, whose macros
newer autoconf calls obsolete (AC_TRY_LINK, AC_TRY_RUN, AM_PROG_MKDIR_P).
These are from 0.22.5, with config.rpath and ABOUT-NLS; the others in m4/
are not used with AM_GNU_GETTEXT([external]) and stay.  autopoint 0.19.6
and later brings those of the installed gettext (0.20 at least).
2026-10-19 14:12:06 +02:00
6fb0bdd501 po-properties: af: drop four stray \v from the translations
msgfmt warned about them; they were typos at the start of a word.
2026-10-19 14:12:05 +02:00
fd6f1f3cf1 gail: drop two clist helpers nothing calls 2026-10-19 14:10:32 +02:00
6e6bfd0a5e tests: no variables without a use, none read unset 2026-10-19 14:10:32 +02:00
77c70dc65a ms-windows engine, ime: drop what is computed and never used
The separator states in xp_theme.c stood before the first case of their
switch and never ran; the code that was really used stays as it was.
2026-10-19 14:10:05 +02:00
149c5b7f0f toolitem, text: the right enum and no doubled parentheses 2026-10-19 14:09:23 +02:00
a44a145186 textutil: drag icon text wraps as GTK_WRAP_WORD_CHAR
It took PANGO_WRAP_WORD_CHAR, which as a GtkWrapMode is GTK_WRAP_WORD.
Same change as GTK+ 3 commit d1e218f4ab by Yosef Or Boczko.
2026-10-19 14:09:22 +02:00
ffd1f32d7a textlayout, toolitemgroup, treeview: drop counts nothing reads
In totally_invisible_line() the count was the first branch of the
toggle tests; toggles have no bytes, so they are tested on their own.
2026-10-19 14:09:22 +02:00
becbc4b24e gtksignal: drop two unused GtkArg helpers
gtkobject.c has its own copies, the ones here were never called.
2026-10-19 14:05:19 +02:00
0d1743b105 printoperation-win32: hand the driver data to base64 as bytes 2026-10-19 14:05:19 +02:00
e27528f38b statusicon, selection: no X11-only variables elsewhere
And the icon update on Windows is indented as it runs.
2026-10-19 14:05:18 +02:00
9b568b689f mountoperation: print a GPid as a number on Windows too
There it is a handle, which %d does not take; GTK+ 3 does the same.
2026-10-19 14:04:29 +02:00
4e6e22b57c menubar, filesel: drop counts nothing reads
And look for the slash after ~ only where ~ is understood.
2026-10-19 14:04:29 +02:00
9efadc7e36 gtkmain: walk GTK_LOCALEDIR through a pointer, not the literal 2026-10-19 14:03:48 +02:00
92ae960572 fontsel: clamp the typed size as an integer
MAX (0.1, ...) went into a gint, so the 0.1 was 0 anyway.
2026-10-19 14:03:48 +02:00
12ed8713a6 clipboard: get the clipboard widget only where X11 needs it 2026-10-19 14:03:48 +02:00
003f2d55e6 builderparser: write the element name test plainly 2026-10-19 14:03:48 +02:00
3c7a39dbcf gdkrgb: drop a count nothing reads 2026-10-19 14:03:01 +02:00
f212ed3dbc gdk: GDK_DEBUG=gdkrgb only for gdkrgb
The test used && where & was meant, so any debug flag made GdkRGB
verbose.
2026-10-19 14:03:00 +02:00
af5fd539a8 win32: drop gdk_win32_window_shape_combine_mask()
Nothing calls it since the client-side windows; shapes come through
the region version.
2026-10-19 14:02:42 +02:00
f668d15ceb win32: drop variables that are only assigned 2026-10-19 14:02:39 +02:00
5b5d73d1b6 win32: g_win32_check_windows_version() where GLib has it
g_win32_get_windows_version() is deprecated since GLib 2.44; older
GLib keeps using it.
2026-10-19 14:02:19 +02:00
6f9bcbb93f win32: keep clipboard text as gchar 2026-10-19 14:02:18 +02:00
80f23332f9 win32: tablet coordinates from the axis minimum, as on X11
x_min and y_min were read but not used, so a tablet whose axes don't
start at 0 was off by that much.
2026-10-19 14:02:18 +02:00
e21c09de7e win32: PS_ALTERNATE for dotted cosmetic pens, as meant
The test for a cosmetic pen was written so that it never held, and the
second dash was compared as the first.  Dashes of one pixel on and one
off with a cosmetic pen now take PS_ALTERNATE, which draws the same
dots; scaled windows keep the user style (gdk_win32_hdc_get()).
2026-10-19 14:02:18 +02:00
24d295ac7d win32: try the second font fallback too
The counter went up twice per round, so the generic family was never
tried when the similar font was missing as well.
2026-10-19 14:02:18 +02:00
b03929ed60 win32: G_ADD_PRIVATE for the drag context
g_type_class_add_private() is deprecated; G_ADD_PRIVATE is there since
GLib 2.38, the oldest we support.  The X11 one already uses it.
2026-10-19 14:02:17 +02:00
33979d7381 gtk-update-icon-cache: give the manifest resource its numbers
The .rc took the names from winbase.h, which does not define them (they
are in winuser.h), so windres made a resource named "RT_MANIFEST" that
Windows never looks at, and the program, "update" in its name, could
ask for elevation.  The numbers need no header, and the mingw-w64
headers that warned about a macro defined twice are gone too.
2026-10-19 14:01:59 +02:00
7834820bdf po: give xgettext the keywords it had before
Since the switch to GNU gettext, the strings with a context (C_, NC_)
and in po-properties all of them (P_) no longer went into the .pot
files.  Back to what the GLib Makefile.in.in passed.
2026-10-19 13:55:44 +02:00
35002f3a70 x11, immulticontext: no unused code without XComposite, XDamage or NLS 2026-10-19 13:53:58 +02:00
5b17dd6811 tests: run the test programs with --tap instead of gtester
gtester is deprecated since GLib 2.62 and warned on every make check;
with newer GLib it also lost track of failing tests (textbuffer failed
unnoticed).  Every GLib we support has --tap.  The report targets still
use gtester and gtester-report.
2026-10-19 13:53:26 +02:00
8ecaf25352 tests: make the text buffer's image without the XPM loader
Newer gdk-pixbuf may come without it; the test then warned.
2026-10-19 13:52:32 +02:00
f84842b2b8 testpixbuf: show the XPM images only where gdk-pixbuf reads XPM 2026-10-19 13:52:13 +02:00
334e6eed44 testpixbuf: inline the two images as resources
gdk_pixbuf_new_from_inline() is deprecated, and newer gdk-pixbuf no
longer installs gdk-pixbuf-csource, so the demos did not build there.
glib-compile-resources comes with every GLib we support.
2026-10-19 13:51:58 +02:00
32cbd190c2 gtk: own copy of GLib's notify queue
gobjectnotifyqueue.c, which gtkwidget.c and gtkcontainer.c included for
the child property notifications, now uses the deprecated GTrashStack.
gtknotifyqueue.h is the same code without it (LGPL 2.1 or later, like
the original by Tim Janik and Red Hat).
2026-10-19 13:50:39 +02:00
bce01889c6 ferret: read text with atk_text_get_string_at_offset()
With ATK before 2.10, which does not have it, the boundary calls
stay.
2026-10-19 13:49:29 +02:00
2d9df97e69 gail tests: connect to property-change directly 2026-10-19 13:49:05 +02:00
46475cf89b gail: call its own table and focus handler code directly
The ATK wrappers it went through are deprecated; for these objects
they only lead back to the same functions.
2026-10-19 13:48:09 +02:00
03a627d8e1 ferret: check what write() returns, close the socket 2026-10-19 13:46:58 +02:00
07976be6d1 treestore: check the first child when moving after nothing 2026-10-19 13:46:33 +02:00
490e2823ef gdk/x11: pass the cursor bits as the bitmap call wants them 2026-10-19 13:46:33 +02:00
9fb7bc2940 gtk: make the alias sections match the files again
The 2.24.32 marshallers get their aliases like everything else, and
the files that export nothing don't include gtkaliasdef.c.  Makes
aliasfilescheck pass.
2026-10-19 13:46:33 +02:00
122fc23214 gtk: list the input hint and purpose types in gtk.symbols
They are exported since the input hints came, but were missing in the
list, so abicheck failed and the Windows .def did not have them.
2026-10-19 13:46:32 +02:00
6d333d5a32 fileoperation: make undo and redo more careful
An undo that stops halfway keeps the rest, only one runs at a time, and
restoring from the trash never overwrites a file that's there now. On
Windows only the file that was trashed comes back. A question whose
window was closed now cancels instead of waiting forever.
2026-10-18 17:59:34 +02:00
41200466c0 clipboard: exchange files with Explorer and the Finder
Uses CF_HDROP and Preferred DropEffect on Windows and
NSFilenamesPboardType on the Mac.
2026-10-18 17:24:39 +02:00
a009f8f759 filechooser: add Connect to Server
Same as in GTK 3 and Nautilus, and shares their list of servers. GVfs
does the mounting; on Windows the shell connects to \\server\share,
on the Mac the Finder does it (Cmd+K).
2026-10-18 17:07:10 +02:00
ddab0eedd9 filechooser: eject and unmount from the sidebar
Like GTK 3. The tooltip shows the free space, and a copy that won't fit
asks first.
2026-10-18 16:55:08 +02:00
b086e1f775 filechooser: drag and drop like a file manager
Files can be dropped onto folders, the path bar and the sidebar, also
from other programs. Same file system moves, otherwise it copies; Ctrl
copies, Shift moves, both link. Handles XdndDirectSave (Firefox,
Chromium, archive managers) and paths as text. Folders open when you
hover over them and the list scrolls at the edges. Also adds Paste
Into Folder.
2026-10-18 16:46:56 +02:00
0c96353c22 filechooser: add undo and redo for file operations
Covers copy, move, trash, rename and new folders, shared by all file
choosers of a program (Ctrl+Z, Ctrl+Shift+Z or Ctrl+Y). Trashed files
come back from the freedesktop trash with or without GVfs, from the
macOS trash, or through the shell from the Windows Recycle Bin.
2026-10-18 16:36:18 +02:00
50eaf35f3d filechooser: add back and forward navigation
Buttons next to the view, Alt+Left/Right, the Back and Forward keys,
Cmd+[ and ] on the Mac, and the side buttons of the mouse.
2026-10-18 16:04:48 +02:00
51b9e7bb06 filechooser: add a Type column
Like GTK 3, it shows the kind of file (Image, Text, Archive...) so that
formats of one kind sort together. TypeFormat=description or mime in
gtkfilechooser.ini shows the description or MIME type instead.
2026-10-18 15:49:27 +02:00
3e735a77ef filechooser: cut, copy and paste files
Works like a file manager: folders are copied with everything in them,
there's a progress row with Cancel, and conflicts ask whether to skip,
replace, merge or rename. Moves are renames where possible. Works with
the clipboard of Nautilus, Caja, Thunar, PCManFM and Dolphin.
2026-10-18 15:45:53 +02:00
6b45510503 filechooser: dim hidden files and backups
From the warning-cleanups branch.
2026-10-18 14:25:56 +02:00
6eeaa39c8b po: German translations for the file chooser menu
From the warning-cleanups branch.
2026-10-18 14:10:20 +02:00
4707adff3b filechooser: show the current folder in the location entry
In Open and Select Folder mode the entry follows the current folder
until something is typed. Programs get the same files as with an empty
entry before.

From the warning-cleanups branch.
2026-10-18 13:41:38 +02:00
28bd68db15 filechooser: copy selected files to the clipboard
Ctrl+C and the context menu put the files on the clipboard the way file
managers expect, plus their paths as text.

From the warning-cleanups branch.
2026-10-18 13:41:38 +02:00
a52972c7b7 filechooser: use-after-free and selection fixes from GTK 3
Backported from GTK 3:

- no use of a freed chooser or path bar after closing
- a file selected in a hidden dialog stays selected
- too long names and existing files in create-folder mode give an error
- insensitive accept buttons stay unused
- the first row no longer overwrites typed names
- the button follows menu and drops
- private recent items stay hidden
- unknown MIME types are quiet
- icon cache and thin icons

Upstream commits:

- 2c40c2b7c8 (Matthias Clasen)
- 70eb35d569 (Volker Sobek)
- 63bc3542ce (Matthias Clasen)
- 3ebcc5a7d5 (Daniel Boles)
- fcd3321fa7 (Руслан Ижбулатов)
- 0f929fb6e3 (Matthias Clasen)
- 5111f7af99 (Kai Willadsen)
- edcddf6561 (Benjamin Otte)
- 0352d88b8a (Luca Bacci)
- 90ca7fb3c9 (Gaël Bonithon)
- b940122c4a (Timothy Arceri)
- 080f8740f2 (Siegfried-Angel Gevatter Pujals)
- 79c1095512 (Matthias Clasen)
- 32e75adf6a (Federico Mena Quintero)
- 0367f785ef (Matthias Clasen)
- b01f371ce6 (Nelson Benítez León)
- 096b49013a (Matthias Clasen)
2026-10-18 13:41:38 +02:00
48e5d50e3b filechooser: error and leak fixes from GTK 3
Backported from GTK 3:

- the error for choosing a file where a folder is wanted shows again
- bookmark reordering no longer leaks the name
- the recent files menu frees an unfinished fill
- a NULL filter unsets the filter

Upstream commits:

- 3e6af07f46 (Paolo Borelli)
- fbb9447785 (Tristan Van Berkom)
- 84513df5a7 (Timothy Arceri)
2026-10-18 13:31:17 +02:00
6d3cf209af filechooser: search, location and mount fixes from GTK 3
Backported from GTK 3:

- search results
- the location entry in local-only mode
- folder activation
- long bookmark names
- recent filters by MIME type
- the process list of mount operations
- icon caches

Upstream commits:

- 8a53ed9e55 (Christoph Reiter)
- d254089308 (Cosimo Cecchi)
- abef21776d (Philip Withnall)
- 3923ba1605 (Matthias Clasen)
2026-10-18 13:31:17 +02:00
67ee22f8fa filechooser: only scale thumbnails down 2026-10-18 12:22:36 +02:00
b1af3691cf quartz: emulate pinch and three-finger swipe
Mac OS X 10.5.2 and later, same as on X11.
2026-10-18 12:22:36 +02:00
341a3d0029 quartz: bring back the accent popup when holding a key
10.7 and later, like GTK 3.24. The chosen character replaces the typed
one, and commands from Cocoa leave the key to GTK.

Backported from GTK 3:

- cfad43b80d (Suyuan Chang)
- d0b09a8823 (John Ralls)
2026-10-18 12:22:36 +02:00
691f296b3f quartz: make gtk_window_set_deletable() work
gdk_window_set_functions() now enables and disables the close, minimize
and zoom buttons (10.2 and later).
2026-10-18 11:48:41 +02:00
36f6cabbf7 quartz: input, clipboard and drag fixes from GTK 3
Backported from GTK 3:

- consumed modifiers of key presses
- clicks on the title bar
- page up and down
- Escape in input methods
- the clipboard owner
- clearing the drag pasteboard

Upstream commits:

- af6487d70c (Thomas Holder)
- f91b429839 (Jeremy Tan)
- 817e99640d (Jiří Techet)
- 3236c09d7d (Matt Rose)
- d0b09a8823 (John Ralls)
- 91f2ad4a2f (Kristian Rietveld)
- 0e4bac872c (Philip Chimento)
2026-10-18 11:48:40 +02:00
0bd37ed232 quartz: use high-resolution pictures on Retina screens
The scale factor API is the one of GTK 3 (8ad851f725 by
Michael Natterer).
2026-10-18 11:15:32 +02:00
62a17ef3cb quartz: expose only what was invalidated on 10.14+
gdk_quartz_set_use_cocoa_invalidation() and
GDK_QUARTZ_COCOA_INVALIDATION switch back to the old behaviour.

Taken from Ardour's YTK:

- 9efd521e, fe6a635c, 4fbdf0d6 (Paul Davis)
- aea9f1b6cf (Paul Davis) and 2d3eb0c6a7 (John Ralls), both GTK 3
2026-10-18 11:15:26 +02:00
e3ed9e0c2a quartz: use the window background before the first draw
Dark themes no longer flash light first.

Taken from Ardour's YTK.
2026-10-18 11:15:26 +02:00
1a30d253f5 quartz: let native subviews keep their clicks and drags
Taken from Ardour's YTK.
2026-10-18 11:15:26 +02:00
876be6d47b hsv: keep the color wheel pixels alive with the surface
Taken from Ardour's YTK.
2026-10-18 11:15:25 +02:00
38ee32db64 quartz: fix enter/leave on macOS 13 and Dock redraws
Also builds with the 10.4 SDK again.

Taken from Ardour's YTK, which has the enter/leave fix from GTK 3:

- 7e1a3ffa37 (John Ralls, GTK 3)
- ea461691 (Paul Davis)
2026-10-18 11:15:25 +02:00
dece7d509a quartz: fix fullscreen, window placement and modal hint
Taken from Ardour's YTK:

- fe7fd146 (Robin Gareus)
- ade9fb8c (Robin Gareus)
- 221fd82d (Paul Davis)
2026-10-18 11:15:25 +02:00
8dc64fe904 quartz: don't ask for userSpaceScaleFactor on newer macOS
Taken from Ardour's YTK:

- ecd22e9a (Robin Gareus)
2026-10-18 10:47:07 +02:00
e8f7b336e1 quartz: fix smooth scrolling build with SDKs before 10.7 2026-10-18 10:47:07 +02:00
d580303374 gtk: let pinches through GTK's own scrolling widgets
So it zooms where the program zooms, and the scrolled window that just
took the wheel doesn't keep it.
2026-10-18 10:47:07 +02:00
80e308944a gdk: emulate touchpad gestures for old programs
Like Windows does for its old programs: a pinch becomes Ctrl+wheel (one
step per 15%), a sideways swipe becomes the back or forward button.
The events are marked for gdk_event_get_touchpad_emulated(). On X11
this needs XInput 2.4 (libXi 1.8 and a server that has it).
2026-10-18 10:41:33 +02:00
7c2bf89fd5 win32: fix crash in get_entries_for_keyval with NULL keymap 2026-10-18 10:41:33 +02:00
726e282cff win32: use the Windows message font like GTK 3
Segoe UI 9, or Tahoma 8 on XP. Before pango 1.43 this is left to pango
for any font but Segoe UI. A theme that sets a font still wins.

Backported from GTK 3 commit 9e7cc89f4a by Christoph Reiter.
2026-10-18 10:41:33 +02:00
bd3df5bec1 win32: window, IME and monitor fixes from GTK 3
Backported from GTK 3:

- frameless windows maximize without covering the taskbar
- IME windows follow the scale
- monitor info and selection names without overflow or leak
- opacity on child windows is ignored quietly

Upstream commits:

- c61764b0f9 (Руслан Ижбулатов)
- c073a062b6 (Chun-wei Fan)
- ba6522d3f2 (Vasiliy Nuzha)
- 41026987be (Руслан Ижбулатов)
- 6dede1a0b7 (Руслан Ижбулатов)
2026-10-18 10:41:33 +02:00
b413703921 ms-windows: draw theme parts at the native resolution 2026-10-18 10:41:33 +02:00
b7f819f037 win32: add HiDPI support
GDK declares itself DPI aware, and at 192 dpi or more (or with
GDK_SCALE) it draws every pixel as two or more device pixels, so
windows keep their 96 dpi size. A remaining fraction goes to the
fonts. GDK_WIN32_DPI_AWARE=0 leaves the scaling to Windows.
2026-10-18 10:41:33 +02:00
62deba5c41 win32: add WM_TOUCH support
Windows 7 and later. Mouse messages that Windows makes from a finger
are marked as emulated.

Modelled on the multitouch support of Ardour's YTK (c88d3701 by
Robin Gareus).
2026-10-18 10:36:53 +02:00
d82c6516ae win32: only wait for the input types GDK handles
Programs built with newer headers spun on Windows 8 or missed events
on XP and 7.

Taken from Ardour's YTK:

- ddbe15fd (Robin Gareus)
2026-10-18 10:18:41 +02:00
de123d8ed5 print: PPD translations and print-to-file fixes from GTK 3
Backported from GTK 3:

- PPD options in the language of the user
- Print to File writes to Documents and adds to recent files
- the scale is applied after rotation and margins
- cancel stops a preview
- conflicts are checked for a new printer
- option widgets let go of their option
- radio options take their mnemonic

Upstream commits:

- 97ee5efb4b (Matthias Clasen)
- c85c3510e7 (Leo Wolf)
- 2c1839ae5f (Marek Kasik)
- d80953666e (Morten Welinder)
- ad764c8a58 (Alban Browaeys)
- f682aabf74 (Siegfried Gevatter (RainCT))
- 0fe9e481dd (Marek Kasik)
- da85312097 (Marek Kasik)
2026-10-18 10:18:40 +02:00
6eedf81e1e print: callback, title and driver fixes from GTK 3
Backported from GTK 3:

- a printer list callback stops when a handler destroys the backend
- CUPS job titles are cut to 255 bytes at a character boundary
- a second source file no longer leaks the first
- Windows driver settings stay with their printer

Upstream commits:

- 255225584e (Carlos Garcia Campos)
- 446659e80f (Rick Yorgason)
- 0387486407 (Marek Kasik)
- 90950b2d3d (Marek Kasik)
2026-10-18 10:18:40 +02:00
a1dec5205d cups: fix connection and request leaks
A connection and a request leaked with every job, a borrowed connection
was closed twice, and the TXT records of network printers weren't
freed. Avahi requests close their own connections now.

Upstream commits:

- 118b09c68c (Marek Kasik)
- 083f834dd7 (Marek Kasik)
- 9513d3b2a4 (Marek Kasik)
2026-10-18 10:18:40 +02:00
9caeed54ad cups: option, Kerberos and leak fixes from GTK 3
Backported from GTK 3:

- custom option values are checked before use
- Kerberos printers no longer ask for a password
- options of printer instances stay with the instance
- a resolution from the settings wins
- printer references no longer leak

Upstream commits:

- b9e91b9419 (Till Kamppeter)
- 9a0700e20c (Marek Kasik)
- e99e282b5a (Andre Heinecke)
- 315bb30220 (Matthias Clasen)
- 36effbb307 (Timothy Arceri)
2026-10-18 10:18:40 +02:00
d83328cd72 print: stop waiting for printers after five seconds
A print server that never answered blocked the print dialog forever.
2026-10-18 10:18:40 +02:00
ace34b5212 po: add "Remember password" translations from GTK 3
The translations are the ones of GTK 3, by the GNOME translation teams.
2026-10-18 10:18:40 +02:00
11b04da889 cups: store job passwords in the keyring like GTK 3
Based on GTK 3 commit 382d68ff8e by Andre Heinecke.
2026-10-18 10:18:40 +02:00
cd6e01acde cups: don't leak the entered password 2026-10-17 23:59:00 +02:00
aaccf7898a widgets: dnd, tooltip and menu fixes from GTK 3
Backported from GTK 3:

- selections to a vanished window and drags without targets are safe
- drag source events no longer leak
- tooltips hide on scroll, their window is freed with the display
- menu paging reads no stale heights
- a paned keeps a position set to its current value
- hidden active radio buttons let focus in
- small pages scroll at most half a page per wheel step
- tool buttons without an icon show their label
- a NULL title clears it

Upstream commits:

- d632474b74 (Matthias Clasen)
- 48770fda30 (Olivier Brunel)
- 057a50d58e (Behdad Esfahbod)
- 92ddf14457 (William Jon McCann)
- a265d8f32d (Philip Withnall)
- df0e5cc8e6 (Philip Chimento)
- c3deff17a6 (John Ralls)
- 276a510b4b (Cosimo Cecchi)
- 01136618b8 (Owen W. Taylor)
- 73e799474a (Matthias Clasen)
- 9a03fc906a (Matthias Clasen)
- c0ba041c73 (Michael Natterer)
- d38bf4825a (Javier Jardón)
2026-10-17 23:47:18 +02:00
7511c8ec00 treeview, combobox: fixes from GTK 3
Backported from GTK 3:

- a custom search entry is released with the view
- deleting a row with a selected child emits changed
- the first pixel of a column belongs to it
- grid lines in right-to-left order
- row deletions reach views that don't ref rows
- autosize columns outside a view are quiet
- combo popups free paths and read no uninitialized cells

Upstream commits:

- 55012318a6 (Vadim Godunko)
- 7faf5ee765 (Claudio Saavedra)
- c4224bf9d0 (Matthias Clasen)
- c15a7877e9 (Guillaume Desmottes)
- 67a00991b7 (Matthias Clasen)
2026-10-17 23:45:28 +02:00
4623eaed8e text: entry, label and text view fixes from GTK 3
Backported from GTK 3:

- setters during the first style of a text view no longer crash
- a text view destroyed during a selection drag keeps its buffer
- tags up to the end relayout
- a link handler that changes the label is safe
- label selections survive setting the same text
- cut, copy and paste with the keypad
- Select All only when there is text
- IM cursor positions in characters
- accelerator labels without XF86
- spin buttons take digits of other scripts

Upstream commits:

- ad1c0f7155 (Matthias Clasen)
- d7696bd25f (Tristan Van Berkom)
- c6a7a0889c (Bastien Nocera)
- 8f6cd8d86d (Sébastien Granjoux)
- f19ecbb850 (Matthias Clasen)
- 0d6cff45c3 (Matthias Clasen)
- b23eabbd64 (Sébastien Wilmet)
- 8da5111edd (Marek Kasik)
- f74a75ae7e (Matthias Clasen)
- 0840f13c15 (Timm Bäder)
- fa69e5f42d (Matthias Clasen)
- b6783933c9 (Matthias Clasen)
- 54c3f05848 (Matthew Barnes)
2026-10-17 23:32:21 +02:00
02596a975f gdk: visibility, RandR and event time fixes from GTK 3
Backported from GTK 3:

- client-side windows get visibility events when they ask
- unplugging a monitor while RandR is read no longer kills the program
- transient-for an offscreen window is ignored
- win32 event times survive 49.7 days of uptime
- win32 modifier keys are marked as such
- quartz moves windows in begin_move_drag
- quartz skips offscreen windows on monitor changes

Upstream commits:

- 7ec927a386 (Alexander Larsson)
- 4cf5ce2e08 (Charles Reiss)
- 394fe4b57e (Ryan Lortie)
- f3f998efd7 (fiddlerwoaroof)
- 0c72ce94ea (Luca Bacci)
- f74f81f06b (Руслан Ижбулатов)
- 0274b2c94e (Руслан Ижбулатов)
2026-10-17 20:34:36 +02:00
25d594e965 widgets: show-hidden, tool palette and -0 fixes from GTK 3
Backported from GTK 3:

- show-hidden set by the program isn't overridden by the settings
- tool palette groups move where asked
- no leaks in tool item group headers and unknown builder actions
- an entry icon replaced during a click keeps its release
- the sort order of the default sort column changes
- scales and spin buttons show 0 instead of -0

Upstream commits:

- e2b9caf26a (Matthias Clasen)
- 9753bea6a4 (Matthias Clasen)
- 18e8842a7e (Matthias Clasen)
- 88e372cd09 (Matthias Clasen)
- 5ca860dcaf (Matthias Clasen)
- f23e99b063 (Matthias Clasen)
- 53bc2566b3 (Matthias Clasen)
- 6a507c0b63 (Tristan Partin)
2026-10-17 19:31:18 +02:00
bb636048f2 gdk: event filter, X11 and quartz fixes from GTK 3
Backported from GTK 3:

- an event filter removed and re-added while running runs again
- an untrusted X client no longer dies on a beep
- no pid in a Flatpak sandbox that the window manager could kill
- quartz drops the pointers of a destroyed window
- win32 centers on a fully set rectangle

Upstream commits:

- 5ac848d229 (Руслан Ижбулатов)
- a73fa04e92 (Matthias Clasen)
- 9c84f7645e (Matthias Clasen)
- 749c863073 (John Ralls)
2026-10-17 19:31:18 +02:00
8b50a92bbd widgets: more fixes from GTK 3
Backported from GTK 3:

- mnemonics of markup labels with hidden underlines
- selecting in a label without a screen
- notebook action widgets get their requested size
- a window presented while hidden keeps the timestamp
- drag destinations start zeroed
- about dialog cursors belong to its display
- radio menu items accept a NULL group

Upstream commits:

- b5d678dab0 (Dan Winship)
- c2d1e3eeb0 (Matthias Clasen)
- 8e65fa1b43 (Sébastien Wilmet)
- f2279d5e51 (Tristan Van Berkom)
- bc6a3f8cd8 (Matthias Clasen)
- 5fa4a05ccc (Philip Withnall)
- e916568781 (jjacky)
- 8aecf2c06a (Matthias Clasen)
- ad05d84897 (Matthias Clasen)
2026-10-17 19:31:18 +02:00
1ee8565630 treeview, stores: transform and column drag fixes from GTK 3
Backported from GTK 3:

- stores convert values of a transformable type
- dragging a column header shows a window of that column's size

Upstream commits:

- a24f7564b5 (Cosimo Cecchi)
- e92e767246 (Cosimo Cecchi)
- 3c7a6581dc (Stefano Facchini)
2026-10-17 18:50:32 +02:00
8ea216978b x11: caps lock and translate queue fixes from GTK 3
Backported from GTK 3:

- the caps lock state is known before the first key event
- the translate queue is freed with its display

Upstream commits:

- 2226996b80 (Matthias Clasen)
- fbf1093d5c (Matthias Clasen)
2026-10-17 18:50:32 +02:00
0ff855d560 widgets: assorted fixes from GTK 3
Backported from GTK 3:

- about dialog links
- assistant pages changed in prepare
- radio menu items joining a group with an active item
- scale marks, tool palettes, notebook tab drags
- menu scrolling, tooltips
- startup notification of popups
- window group lists

Upstream commits:

- 2cabfcc801 (Matthias Clasen)
- 8e1878bc32 (Matthias Clasen)
- eeb9de80e1 (Xan Lopez)
- 04e727709d (Jasper St. Pierre)
- 00be62546f (Matthias Clasen)
- c298c7acce (Philip Chimento)
- 38dc4733c0 (Tristan Van Berkom)
- a37976dae0 (Tristan Van Berkom)
2026-10-17 18:50:25 +02:00
fafda6f9bf treeview, iconview, combobox: fixes from GTK 3
Backported from GTK 3:

- drags from empty views
- extra mouse buttons
- keys that only close the search
- cursor changes during destruction
- filter reordering
- expander clicks in combo popups
- combo box text items split by markup

Upstream commits:

- e8157126d8 (Tristan Van Berkom)
- 295ed0033e (Cosimo Cecchi)
- 510d84f682 (Kristian Rietveld)
- 1dcd209cdd (Matthias Clasen)
- a20ff44b09 (Daniel Boles)
- 2934482aee (Emmanuele Bassi)
- e60fa49fa7 (Rui Matos)
- 44a064fe30 (Kristian Rietveld)
- e35378ba37 (Thomas Holder)
- 63fe6de94d (Benjamin Otte)
- d3c427a767 (Matthias Clasen)
2026-10-17 18:13:35 +02:00
ff6019ff8d entry, textview: fixes from GTK 3
Backported from GTK 3:

- activatable defaults of entry icons
- display text ranges
- primary selection ownership
- empty inserts
- tag toggles at the end
- line width of justified text
- control characters in input methods

Upstream commits:

- 67efefde49 (Carlos Garnacho)
- 5fe9ebfe11 (Carlos Garnacho)
- 056acf92ec (Matthias Clasen)
- 73c8f30928 (Sebastien Lafargue)
- ff9eb56c6e (Jasper St. Pierre)
- 3511215730 (Paolo Borelli)
2026-10-17 18:13:35 +02:00
aa1a304fe9 gdk: event, shape, grab and focus fixes from GTK 3
Backported from GTK 3:

- event freeing
- child window shapes
- root coordinates of destroyed windows
- implicit grabs
- windows that don't take focus no longer offer WM_TAKE_FOCUS

Upstream commits:

- 809aab2c8e (Jasper St. Pierre)
- f96437317b (Carlos Garnacho)
- 651410fa2a (Carlos Garcia Campos)
- 3f78b251b9 (Carlos Garnacho)
- 41f4fd94df (Tomeu Vizoso)
2026-10-17 18:13:35 +02:00
62cba3edca entry, textview: add the emoji chooser from GTK 3.22
Opens with Ctrl+. or Ctrl+; or from the context menu. The search uses
the desktop language and recently used ones come first. The emoji data
from GTK 3 is only loaded when the chooser first opens.

Backported from GTK 3:

- 45b2e162ae (Matthias Clasen)
- a584bcb88e (Matthias Clasen)
- d56505f74d (Matthias Clasen)
- f922aee5e2 (Matthias Clasen)
- 90faa49a70 (Jeremy Bícha)

The emoji data comes from emojibase (MIT) and the Unicode CLDR
(Unicode License V3); both notices are in gtk/emoji/COPYING.
2026-10-17 18:04:50 +02:00
ac42292095 entry, textview: add placeholder text and input hints
Placeholder text from GTK 3.2, input purpose and hints from 3.6.
Password entries and spin buttons set them on their own.

Backported from GTK 3:

- ef061c4e96 (Carlos Garcia Campos)
- c27ddc66c5 (Jonh Wendell)
- 8a8c434737 (Krzesimir Nowak)
- 3cb4aa44b3 (Matthias Clasen)
- eaaee081b1 (Matthias Clasen)
- 7d1c1a8d20 (Matthias Clasen)
2026-10-17 18:04:50 +02:00
94bf53e488 gtk: add GtkFileChooserNative and GtkNativeDialog
Same API as GTK 3.20. Uses IFileDialog on Windows (the old common
dialogs on XP and ReactOS), NSOpenPanel/NSSavePanel on Mac OS X 10.4
and later, and the portal under Flatpak or with GTK_USE_PORTAL=1.
Otherwise it falls back to the GTK dialog. Also adds
gtk_file_filter_to_gvariant() and _new_from_gvariant() from 3.22.

Backported from GTK 3:

- 5094900180 (Alexander Larsson)
- 81cef0091e (Alexander Larsson)
- 01d0bac83e (Alexander Larsson)
- 693db082a1 (Alexander Larsson)
- 35181e793d (Matthias Clasen)
- 15e361e793 (Matthias Clasen)
- 0acb6a0e98 (Matthias Clasen)
- ce4c9a9ad6 (Tom Schoonjans)
- 32d87ac907 (Emilio Cobos Álvarez)
2026-10-17 18:04:49 +02:00
fdf1b58816 x11: per-monitor HiDPI
Each window takes the scale of the monitor it's on and switches when
it's moved, keeping its size in GDK pixels. Scales come from the
per-output resolution on Xlibre or GDK_MONITOR_SCALES. Changes apply
right away.
2026-10-17 18:04:49 +02:00
c475fe052f icons: high-resolution pictures on scaled screens 2026-10-17 17:22:24 +02:00
c717e77123 x11: add HiDPI support like GTK 3
With a scale of 2 or more (GDK_SCALE, Gdk/WindowScalingFactor, the
per-output resolution on Xlibre, Xft.dpi) everything is drawn in device
pixels while programs keep their sizes. Adds
gdk_window_get_scale_factor() and gdk_screen_get_monitor_scale_factor().

The scale factor API is the one of GTK 3 (8ad851f725 by
Michael Natterer).
2026-10-17 17:22:24 +02:00
57b1fcdede scrolledwindow: kinetic scrolling with a finger
Works in old programs too. Taps and a resting finger still go to the
widgets as before.

Modelled on the kinetic scrolling of GTK 3 (f6393199be by
Carlos Garcia Campos).
2026-10-17 17:22:23 +02:00
58a9c7bf63 gtk: add the touch-event signal
Backported from GTK 3 commit 680872815b by Matthias Clasen.
2026-10-17 17:22:23 +02:00
743c7a7e33 gdk: add touch events like GTK 3
GDK_TOUCH_MASK and the touch event types, using XInput 2.2 on X11.
Windows without the mask get the first finger as pointer events,
marked as emulated.

The touch API is the one of GTK 3 (commits 7f35708cee and bc8401d1ed by
Carlos Garnacho). The pointer emulation for windows without the
mask follows Ardour's YTK (952ec57a by Robin Gareus).
2026-10-17 17:22:23 +02:00
fd7f7b780f gdk: add GDK_SMOOTH_SCROLL_MASK
Same as in GTK 3.4: windows that ask for it get smooth scroll deltas,
all others keep the plain steps.

The API is the one of GTK 3.4 (commits 7b48a3c0bd by Carlos Garnacho
and 0efbbc6435 by Michael Natterer).
2026-10-17 17:22:23 +02:00
d4c2a29d9e scrolledwindow: drop leftover steps of an unused direction 2026-10-17 17:22:23 +02:00
3ac60bfbcf scrolledwindow: keep the wheel while scrolling
A child that scrolls too no longer takes the wheel away in the middle
of scrolling the outer window.
2026-10-17 17:22:23 +02:00
63aeeb1e37 scrolledwindow: animate wheel steps, scroll sideways with Shift 2026-10-17 17:22:23 +02:00
c33a268060 gdk: smooth scrolling on Windows and macOS 2026-10-17 17:11:15 +02:00
d298391bc9 gdk: smooth scrolling for high-resolution wheels and touchpads 2026-10-17 17:04:03 +02:00
6acf191fb0 filesystemmodel: free large folder models in idle slices 2026-10-17 16:59:09 +02:00
a518603f75 recentmanager: load lazily, don't reread our own writes 2026-10-17 16:36:26 +02:00
7e94e1c08e gdk: create the expose pixmap only when needed
Windows that draw themselves (video players, GL, Pale Moon) no longer
get a pixmap of the exposed size made and freed in the X server every
time.
2026-10-17 15:49:34 +02:00
77f8b18155 x11: don't read the X connection needlessly before polling
An empty main loop iteration, of which Pale Moon does tens of thousands
a second, now costs about a third of what it did.
2026-10-17 15:33:14 +02:00
467338d01b x11: cache window origins
gdk_window_get_origin() doesn't ask the X server every time anymore.
The position is kept until something can move the window, or for half
a second. Pale Moon called it thousands of times a second while the
mouse moved.
2026-10-17 15:26:19 +02:00
8c3130add7 icontheme: use GIcon pixbufs directly, detect SVG by suffix
Like GTK 3. The content type query used before also leaked its result.

Upstream commits:

- 03147b0e72 (Ryan Lortie)
- f929a61399 (Jasper St. Pierre)
2026-10-17 15:02:53 +02:00
eb7eee49be icontheme: scale missing sizes like Mac OS X
SVGs are rendered at twice the size and bitmaps taken from one at least
twice as big, then scaled down with Lanczos instead of bilinear.
2026-10-17 15:02:53 +02:00
35b734b1a5 stock icons: render all sizes from the SVGs
16, 18, 20, 24, 32 and 48 are rendered at twice the size and scaled
down with Lanczos, like Mac OS X does. An icon of the exact size now
wins over one within the threshold.
2026-10-17 15:02:53 +02:00
661814faf0 icontheme: even pixel blocks for fractional upscaling 2026-10-17 15:02:52 +02:00
fa5c4defa2 configure: add --enable-win32-time64
Builds 32-bit Windows with a 64-bit time_t, which msvcrt.dll has had
since Windows 2000, so XP and ReactOS work too. gtk+-2.0.pc passes the
flag on, since programs need the same time_t.
2026-10-17 13:51:51 +02:00
9cdebc8291 recentmanager: add 64-bit _unix() time getters 2026-10-17 13:51:51 +02:00
8c3081232b directfb: take event times from the 64-bit clock 2026-10-17 13:51:50 +02:00
b31c0210e0 cups: get the document size without fstat() 2026-10-17 13:51:50 +02:00
f04fe55bac thumbnails: use the 64-bit stat for FUSE mounts 2026-10-17 13:51:50 +02:00
ce7f86f05e recentmanager: check if a file exists without its times 2026-10-17 13:51:50 +02:00
8e91be460f search: walk folders ourselves instead of using nftw()
nftw() skipped folders changed after 2038 with a 32-bit time_t, and
Windows doesn't have it, so the search found nothing there.
2026-10-17 13:51:50 +02:00
8a1c1fe8bf fileselection: use 64-bit folder times 2026-10-17 13:51:50 +02:00
e349c1b111 gtk, gdk: use the monotonic clock for polling intervals 2026-10-17 13:51:50 +02:00
d86aabf1f6 gtk: correct current time after 2038 with 32-bit time_t
Recent item ages, Today/Yesterday in the file chooser, the calendar
and the CUPS print time. Uses clock_gettime64 on Linux.
2026-10-17 13:51:50 +02:00
46e9e4d823 gtk: 64-bit file times for rc files and icon caches
Adds gtktimeprivate.h (statx on Linux, FILETIME on Windows, unsigned
32 bit elsewhere). After 2038 changes went unnoticed and the icon
cache was given up.
2026-10-17 13:36:11 +02:00
76e2e9392d gtk: time submenus and app launches with the monotonic clock 2026-10-17 13:36:03 +02:00
22e603ee99 cups: compute the UTC print time without time()
This also fixes zones with quarter hours like Nepal, which came out an
hour wrong.
2026-10-17 12:17:32 +02:00
407a31fc72 x11: use the monotonic clock for colormap syncs 2026-10-17 12:17:16 +02:00
944e7d9ffe filechooser: read modification times as 64 bit
Drops the GTimeVal fallback that ends in 2038 on 32-bit systems and on
Windows, and no longer creates a GDateTime for every cell.
2026-10-17 12:13:03 +02:00
f73ca30823 recentchooser: fix sort overflow for far-apart times 2026-10-17 12:03:33 +02:00
935817582d recentmanager: use 64-bit time for item ages 2026-10-17 12:03:33 +02:00
b582666b63 fontsel: size the family list to the widest family again
Like the autosized column in vanilla GTK, but measured in one go, kept
for the next dialog with the same fonts, and done in idle slices when
there are thousands of fonts.
2026-10-17 11:16:09 +02:00
237736fad9 fontsel: show a family's styles together with its preview 2026-10-17 11:15:01 +02:00
cf19f77699 fontsel: keep the style when switching family 2026-10-17 11:14:25 +02:00
93cd95b174 fontsel: update the preview after the lists are redrawn 2026-10-17 11:13:58 +02:00
58851eea33 fontsel: list thousands of fonts quickly 2026-10-17 11:13:26 +02:00
a47206e0a6 pixbuf engine: keep theme image pieces in the X server 2026-10-17 11:12:39 +02:00
326f4a3085 gtkstyle: clip default theme drawing to the drawn area 2026-10-17 11:05:52 +02:00
aa9939264e gdk: let external engines find the area cairo helper
It's registered as type data on GdkDrawable, so the same engine still
loads into other GTK 2 builds and falls back to gdk_cairo_create()
there.
2026-10-17 01:37:38 +02:00
92c6e6abf8 pixbuf engine: clip image parts only around themselves 2026-10-16 22:58:51 +02:00
90df8be3fa gdkcairo: add gdk_cairo_create_in_area_libgtk_only()
Gives theme engines a cairo context clipped only to the window clip
rectangles that touch the area being drawn.
2026-10-16 22:42:50 +02:00
6db19d9277 gdkwindow: skip clip recomputation for new unmapped windows 2026-10-16 22:42:49 +02:00
a38351545b gdkwindow: only recompute clips of overlapping siblings 2026-10-16 22:38:38 +02:00
91efbe0977 sizegroup: mark visited groups with a flag and a set 2026-10-16 22:33:03 +02:00
7cf2cc660b gdkwindow: don't recompute clips for input-only windows 2026-10-16 21:17:10 +02:00
42ee594e3c rc: cache rc set matches per widget path 2026-10-16 20:32:43 +02:00
82d570154a rc: look up class path types once per theme 2026-10-16 20:30:11 +02:00
b8726b4f53 entry: find the invisible char once per style and font map 2026-10-16 20:26:01 +02:00
5c1b2333ff scale: measure the value text once per size request 2026-10-16 20:25:29 +02:00
42424722a5 gtkwidget: cache where windowless containers draw
It's kept until allocation, mapping, parent or style change, so an
expose doesn't walk every child of every container anymore.
2026-10-16 19:56:36 +02:00
c5e9ecb8e4 gdkwindow: keep the window clip on the GC while painting 2026-10-16 19:55:22 +02:00
aa55defff0 x11: don't resend the clip and tile origin on every flush 2026-10-16 19:53:18 +02:00
bb97d1cfd6 cellrenderertext: hash the layout cache 2026-10-16 19:49:19 +02:00
6de2f8c5d3 textlayout: don't relayout unwrapped text on width changes 2026-10-16 19:49:19 +02:00
6949ae7256 liststore: don't walk up the sequence on every compare 2026-10-16 19:38:41 +02:00
9f4d03fc9c liststore: sort with collation keys, read values once 2026-10-16 19:35:42 +02:00
d89ff56eed treedatalist: sort with collation keys, read values once 2026-10-16 19:35:42 +02:00
592c2ed435 gdk: clip gdk_draw_layout() only around the text 2026-10-16 19:35:42 +02:00
aded12b225 gdk: don't clip GC cairo contexts to the window twice 2026-10-16 19:35:36 +02:00
86aee38b99 pixbuf engine: cache stretched theme image pieces 2026-10-16 19:35:36 +02:00
f69a1fd9d4 icontheme: hand out copies of small icons loaded last 2026-10-16 19:35:32 +02:00
dc3a6c9f82 textlayout: cache all lines drawn last
Redrawing or scrolling a text view no longer lays out the same lines
again.

Inspired by the line display cache of GTK 4 (commit 9926e6ebde by
Christian Hergert).
2026-10-16 16:44:00 +02:00
9b1ee6de31 textbtree: answer at once for tags applied nowhere 2026-10-16 16:32:45 +02:00
95c0df3897 textview: skip the pointer lookup in buffers without tags 2026-10-16 16:06:17 +02:00
de8315084b textbtree: keep the path from the root on the stack 2026-10-16 16:00:07 +02:00
d674c58f74 liststore, treestore: collect varargs values in one step 2026-10-16 15:31:37 +02:00
1a4b43b331 x11: look up the WM hint atom only once
Backported from GTK 3 commit 6eea6ddcc3 by John Lindgren.
2026-10-16 15:28:40 +02:00
f8b91f36dc gdkwindow: don't copy child windows when processing updates 2026-10-16 15:20:58 +02:00
c38cf39264 container: don't pass exposes to children outside the area 2026-10-16 15:07:39 +02:00
37d5c049a0 gdkwindow: drop children outside the expose early 2026-10-16 15:06:22 +02:00
6c5e5f3ee6 tooltip: don't lay out the text twice per motion 2026-10-16 14:36:20 +02:00
75e3c0e379 spinner: only animate while mapped
Backported from GTK 3 commit f5a06df3dc by Javier Jardón.
2026-10-16 14:26:35 +02:00
75aabbc59f iconview: fill a view in linear instead of quadratic time 2026-10-16 14:25:08 +02:00
744d62b4c5 gdkwindow: skip region work when raising the top window
Backported from GTK 3 commit b5eddb0aa1 by Jasper St. Pierre.
2026-10-16 14:24:53 +02:00
cb3cd96555 label: don't relayout when the same text is set again 2026-10-16 14:20:06 +02:00
84c775f015 textbtree: quick visibility check when no tag hides text 2026-10-16 14:19:04 +02:00
de659462a0 treeview: only query the pointer for a pressed expander 2026-10-16 14:16:48 +02:00
5e9f1cd453 icontheme: skip theme directories without icons 2026-10-16 14:14:59 +02:00
39335a1e12 gtksettings: stop the cursor blinking after 10 seconds 2026-10-16 14:14:40 +02:00
daf7c22489 gtkstyle: check style property requests only before caching 2026-10-16 14:13:04 +02:00
27eec123f8 gdkcairo: convert cached theme icons for cairo only once 2026-10-16 14:10:40 +02:00
242681544a gtkwidget: skip the child walk when a widget covers the expose 2026-10-16 14:09:16 +02:00
f47437b814 x11: skip XChangeGC when only the origins change 2026-10-16 14:06:25 +02:00
a04ddf45a8 gdkregion: fast path for intersecting with a rectangle 2026-10-16 13:51:26 +02:00
f9c6999ef1 gtkwidget: don't copy the draw border on every expose 2026-10-16 13:50:35 +02:00
0ac6256f25 gtkwidget: remember which style property a name stands for 2026-10-16 13:50:23 +02:00
aae13dbac4 gtkstyle: draw dotted focus lines per edge, not per dash 2026-10-16 13:48:14 +02:00
2dbbb46066 cellrenderertext: lay out the text once per cell 2026-10-16 13:47:56 +02:00
0abd3735b2 gdkrgb: add ARMv6 paths for the Raspberry Pi 1 and Zero 2026-10-16 13:47:42 +02:00
6b3e8b172f gdkcairo: faster pixel conversion without SIMD
Read and write each pixel as one word and multiply red and blue
together.
2026-10-16 13:47:28 +02:00
a8774c33db gdkrgb: add AVX2 paths for 32-bit pixels 2026-10-16 13:47:28 +02:00
ae1b4dab44 gdkrgb: add SSSE3 kernels for Atom and Core 2 2026-10-16 13:47:28 +02:00
15f0bcb27a gdk: add rgbsimdbench to check and time the SIMD kernels 2026-10-16 13:47:28 +02:00
7c91040408 gdkrgb: add pshufw, pmulhuw and 3DNow! kernels
Each kernel is picked on its own depending on what the CPU can do, so
Pentium IIIs and older Athlons get the parts they support.
2026-10-16 13:47:23 +02:00
488ec64633 gdkrgb: add SIMD kernels for 15-bit pixels 2026-10-16 13:46:54 +02:00
4455848b3b gdkcairo: use the SIMD kernels for pixbuf conversion 2026-10-16 13:46:48 +02:00
526d720ec5 gdkrgb: add NEON paths for ARMv7 and AArch64 2026-10-16 13:46:39 +02:00
15bba9319b gdkrgb: add AltiVec paths for G4 and G5 2026-10-16 13:46:18 +02:00
c906ea3279 gdkrgb: add MMX paths for CPUs without SSE2 2026-10-16 13:46:18 +02:00
8e7fc8d68c gdkrgb: add SSE2 paths, picked at runtime 2026-10-16 13:46:11 +02:00
97e25f736e x11: make room for all eight visual depths 2026-10-16 13:46:04 +02:00
e26541b6f8 gdk: share one pixel reader between pixbuf-drawable and GdkRGB 2026-10-16 13:45:58 +02:00
62da54e328 gdk: drop the unused mediaLib detection
Nothing in GDK calls it anymore since gdk_draw_pixbuf() uses cairo.
Only the detection code and an outdated note in the docs were left.
2026-10-16 13:45:38 +02:00
97f0af7784 x11: blend with RENDER unless GdkRGB does it better 2026-10-16 13:45:38 +02:00
86349ccf5b gdk: blend pixbufs in the drawable's own format on any depth 2026-10-16 13:45:31 +02:00
5ebfb141db gdkrgb: merge gdkrgb16.c into one conversion engine
All depths go through the same converters now instead of a separate
file for 16 bit. The public API is unchanged.
2026-10-16 13:45:23 +02:00
ae550e943b x11: use the image byte order for the bits of 1-bit images 2026-10-16 13:45:18 +02:00
c37868f626 gdkrgb: pick visuals by color bits, including 30-bit ones 2026-10-16 13:45:11 +02:00
493bd64a93 gdkrgb: walk the colormap lut lists to their end 2026-10-16 13:45:03 +02:00
ae4f961eed filechooser: handle Enter in the location entry
Taken from Ardour's YTK:

- 3acc8c76 (Robin Gareus)
2026-10-16 13:44:50 +02:00
f3e908344c filechooser: name the image format in the preview 2026-10-16 13:44:41 +02:00
143e6fcc8e thumbnails: read the JPEG Exif orientation ourselves 2026-10-16 13:44:26 +02:00
df74bd0d5f filechoosersettings: fix leak of the settings folder name 2026-10-16 13:44:12 +02:00
0cad3c0215 filethumbnail: fix Windows type detection and tiny thumbnails 2026-10-16 12:38:02 +02:00
081f1247f9 filechooser: use the shell for the Recycle Bin
GLib's call made the shell ask for confirmation for every single file.
2026-10-16 12:34:05 +02:00
c4a50d5e03 filechooser: add a preferences dialog
For now it holds the size limits for thumbnails, with a separate one
for network shares.
2026-10-16 09:51:30 +02:00
ae970f1a79 filechooser: use Explorer and Quick Look thumbnails 2026-10-16 09:43:52 +02:00
0d6e5533c2 filechooser: reuse thumbnails made by other file managers
Any size from the shared thumbnail cache is used, checked the same way
GLib does it.
2026-10-16 09:41:33 +02:00
ae9bfb033f quartz: pass all dragged files to the Finder 2026-10-16 09:25:00 +02:00
75afe829b2 filechooser: allow dragging several files at once 2026-10-16 09:12:16 +02:00
411be011b9 filechooser: return icon view selections in display order 2026-10-16 09:12:16 +02:00
dacd7b2ed3 iconview: fix double click after clicking another item 2026-10-16 08:59:14 +02:00
c086f9c11e filechooser: detect network shares on all platforms 2026-10-16 08:59:14 +02:00
9c25fb8a86 filechooser: use the Finder trash on macOS 2026-10-16 06:40:51 +02:00
4bcdc2eed2 filechooser: add a built-in preview pane
It's only shown for programs that don't set a preview widget of their
own.
2026-10-16 06:40:51 +02:00
c43ae2f944 filechooser: add a compact view 2026-10-16 06:40:51 +02:00
a73f195c16 filechooser: show truncated names in a tooltip 2026-10-16 06:40:50 +02:00
0b4c964f4a filechooser: add "Visit File" for search and recent results 2026-10-16 06:30:54 +02:00
02a610f008 filechooser: move files to the trash with Delete 2026-10-16 06:30:54 +02:00
b1f2512b67 filechooser: rename files in place with F2 2026-10-16 06:30:48 +02:00
a4bb92e839 filechooser: add thumbnails to the icon view
Thumbnails are made in the background, and outdated ones are dropped.
2026-10-16 06:10:19 +02:00
03f9a1911e selection: no critical when a callback destroys the widget 2026-10-16 00:17:28 +02:00
82baa569a2 gtk-demo: fix leaks in appwindow, builder and images 2026-10-16 00:15:43 +02:00
827d0f156b gtk-demo: forget the assistant window on destroy 2026-10-16 00:13:44 +02:00
ebfeda01cc gtk-demo: stop the list store spinner on destroy 2026-10-16 00:12:11 +02:00
01375ea50b x11: fix cursors from pixbufs without alpha 2026-10-16 00:01:28 +02:00
3b469092e7 recentmanager: create the folder for the recent list
Taken from Ardour's YTK:

- 76b25163 (Robin Gareus)
2026-10-15 22:21:03 +02:00
68b05b152e gdkpixmap: set the mask to NULL when XPM loading fails 2026-10-15 22:03:10 +02:00
e9799be573 gtk-update-icon-cache: fail on unknown options
An unknown option used to be taken as the icon directory. Messages that
can't be converted to the locale are printed as they are.
2026-10-15 22:01:29 +02:00
0efdcf98dc icontheme: return a copy of the load error 2026-10-15 22:01:00 +02:00
d1bf2a34db dnd: fix the vertical hot spot of the default drag icon
Backported from GTK 3 commit 9f51d8948f by Maks Naumov.
2026-10-15 19:34:36 +02:00
7eaf29379f linkbutton: free the tooltip texts
Backported from GTK 3 commit 088cf99763 by Mohammed Sadiq.
2026-10-15 18:55:10 +02:00
8a4c99379b printunixdialog: release the parent folder after the check
Backported from GTK 3 commit 7fbf6a67a2 by Matthias Clasen.
2026-10-15 17:39:58 +02:00
b1fba59e39 textbufferserialize: free the tag list
Backported from GTK 3 commit a0f2e6990f by Paolo Borelli.
2026-10-15 17:39:58 +02:00
9c1537b0ec clipboard: free the old cached targets 2026-10-15 17:39:52 +02:00
90d9446ea2 menushell: free the key list after a mnemonic activation
Backported from GTK 3 commit b097729d5a by Matthias Clasen.
2026-10-15 17:26:54 +02:00
8deebb25ac print: end the job with an error when writing fails
All backends used to loop forever on a failed write.

Backported from GTK 3 commit 2adacca119 by Carlos Garcia Campos.
2026-10-15 17:06:32 +02:00
d909571975 colorbutton: hold a reference while color-set runs 2026-10-15 16:40:46 +02:00
7559ae288f clipboard: forget the store timeout once it fired
Backported from GTK 3 commit 599ab80c63 by Gaël Bonithon.
2026-10-15 16:31:08 +02:00
6fc7829b6c x11: handle files without a basename in the launch context
Backported from GTK 3 commit 536da7a15c by Matthias Clasen.
2026-10-15 16:22:48 +02:00
720b691102 entrycompletion: avoid division by zero with zero row height
Backported from GTK 3 commit 94dbefda1c by Benjamin Otte.
2026-10-15 16:22:48 +02:00
383f88a9d0 x11: ignore a nested emulated move or resize
Backported from GTK 3 commit e834a2b089 by Matthias Clasen.
2026-10-15 16:18:02 +02:00
3beab3b115 x11: fix endless loop looking up drag contexts
Backported from GTK 3 commit f77b690e26 by Edward Sheldrake.
2026-10-15 16:12:02 +02:00
c98c537dbc selection: ignore requests from a destroyed requestor window 2026-10-15 16:06:10 +02:00
15ef87a7b6 textiter: don't read before the line attributes
Backported from GTK 3 commit ca3d87ce70 by Matthias Clasen.
2026-10-15 15:45:18 +02:00
9dc515c29c textlayout: don't free a missing line display on zero moves
Backported from GTK 3 commit 02e2f7dc56 by Matthias Clasen.
2026-10-15 14:08:04 +02:00
64d849f8f0 x11: fix out-of-bounds read in the key type shift level
Backported from GTK 3 commit e75310a445 by Matthias Clasen.
2026-10-15 14:08:03 +02:00
e1a840186f x11: skip vanished child windows when listing children
Backported from GTK 3 commit 430ea2fff6 by Maks Naumov.
2026-10-15 14:08:02 +02:00
88c1c434cd treestore: don't crash when reordering a row without children
Backported from GTK 3 commit 0d2d1904b1 by Olivier Brunel.
2026-10-15 14:08:01 +02:00
7dd2375e9f icontheme: fix crash on directories without a Context key
Backported from GTK 3 commit 21cd322df9 by Emmanuele Bassi.
2026-10-15 11:46:11 +02:00
6dff9147fb immulticontext: disconnect surrounding handlers from the old IM
Backported from GTK 3 commit 822705fe3e by Alexandr Miloslavskiy.
2026-10-15 11:42:19 +02:00
7b28df566f recentchooser: fix assertion when dragging recent files
Backported from GTK 3 commit e5eb59a2f8 by Hiroyuki Ito.
2026-10-15 11:39:17 +02:00
686fff335d printer: don't use the freed backend list when enumerating
Backported from GTK 3 commit 931f7863ec by Marek Kasik.
2026-10-15 11:39:17 +02:00
24a2f6dad4 textbufferserialize: reject bad section lengths
Negative lengths or lengths running past the data used to hang or read
out of bounds.
2026-10-15 11:30:51 +02:00
869ad66e19 notebook: fix crash on button release without pages 2026-10-15 11:30:51 +02:00
c5f7672ee1 gail, iconview: use atk_component_get_extents()
From the warning-cleanups branch.
2026-10-15 11:30:51 +02:00
aecee2b1ac gtk, win32: use the result of g_string_free()
From the warning-cleanups branch.
2026-10-15 11:30:51 +02:00
20bdcce69b win32: add two casts newer compilers ask for
Taken from Ardour's YTK:

- ee0b7601 (EZ4Stephen)
2026-10-15 10:02:18 +02:00
8c73c33ef3 build: no symbol aliases on Windows
A GLib built with clang claims visibility support there, but the
Windows sources don't define any aliases.
2026-10-15 10:02:18 +02:00
c9c7a294c1 gtk: export the nine marshallers from 2.24.32 again
2.24.32 exported them by accident, and programs built against it link
to them.
2026-10-15 09:54:09 +02:00
d1ad63a098 headers: don't mark _get_type and _quark functions const
They register types as a side effect, and newer compilers drop calls
whose result isn't used.

The same change as GTK 3 commit f30efa7759 by Matthias Clasen.
2026-10-15 09:53:23 +02:00
13a6a8be1c gtk: support GDK_NO_XSETTINGS and GTK_LOCALEDIR
Taken from Ardour's YTK:

- adeebb8f (Paul Davis)
- 42eb1188 (jean-emmanuel)
2026-10-15 09:51:50 +02:00
adea3e34af gtkmodules: also look in /usr/lib/gtk-2.0 on multiarch
Based on Debian's 098_multiarch_module_path.patch by Steve Langasek,
which Ardour's YTK carries as well.
2026-10-15 09:14:43 +02:00
b422502d7a gtk-update-icon-cache: read directories sorted, stat once 2026-10-15 09:08:00 +02:00
8c1c905be0 build: drop fallbacks for unsupported dependency versions
The minimum versions are listed in INSTALL now.
2026-10-15 09:07:46 +02:00
4851a82452 ms-windows: don't use a deprecated size call 2026-10-15 09:07:31 +02:00
9a491e585a gtkfilesystem: bound the shared file icon cache 2026-10-13 15:56:01 +02:00
21087a4009 filechooser: no blocking file system calls when changing folders 2026-10-13 15:56:01 +02:00
89850b3602 filechooser: query icons only for the rows on screen 2026-10-13 15:56:01 +02:00
6cf67e8b7c filechooser: give all names in the icon view the same height 2026-10-13 15:56:01 +02:00
da49e7bb79 gtkiconview: reuse cell layouts across relayouts, avoid O(n) walks per row
The cached cell layout is dropped together with the item size, so changes
still have to come with a row-changed, just like for the item size.
2026-10-13 15:56:01 +02:00
32175fcd80 filechooser: use fixed-height mode for the file list 2026-10-13 15:56:01 +02:00
e98b38f46e filechooser: use fast-content-type, read files only for MIME filters 2026-10-13 15:56:01 +02:00
7453c733c7 filechooser: show the files of a folder while it is still loading 2026-10-13 15:56:01 +02:00
76887647a1 gtkfilesystemmodel: keep nodes by stable ID and show files while loading
Files go to an unsorted tail and are merged into the sorted rows in short
slices, so a folder shows up while it is still loading. Filtering and
sorting run in the background as well; _gtk_file_system_model_flush()
brings the rows up to date where the chooser needs them right away.
2026-10-13 15:56:01 +02:00
0663c0f616 filechooser: select the row under the pointer on right click 2026-10-13 15:56:01 +02:00
810008f25e filechooser: add "Copy Location" to the context menu 2026-10-13 15:56:01 +02:00
2d8c88972d filechooser: create the icon view zoom scale on demand 2026-10-13 15:56:01 +02:00
212df8a74e fontsel: localize common font style names 2026-08-10 14:08:34 +02:00
0f4142b31a introspection: add GdkWin32 GIR generation 2026-08-10 12:05:31 +02:00
f14303e16f introspection: pass compiler and GTK DLL path to scanner 2026-08-09 23:10:13 +02:00
ea73f6812c gtk: replace deprecated tooltip timestamp ABI field 2026-08-07 08:53:00 +02:00
782a2948b8 gail: update AtkValue test modules
Use a shared private compatibility helper in the GAIL test modules.

Exercise the modern AtkValue API when ATK 2.12 or newer is available while retaining the legacy test path for older ATK versions.

Initialize temporary GValues explicitly and keep the helper symbols private to the test modules.
2026-08-07 08:53:00 +02:00
a116a5d13b gail: implement modern AtkValue interface
Add compile-time support for the modern AtkValue API available since ATK 2.12 while retaining compatibility with older ATK versions.

Implement direct modern value, range, increment and setter methods for adjustments, paned widgets, progress bars, ranges, scale buttons and spin buttons.

Keep the implementation private, avoid per-instance memory overhead and preserve the existing exported ABI.
2026-08-07 08:53:00 +02:00
d0c4346396 cups: use modern HTTP connection helpers when available
Detect httpConnect2 and httpReconnect2 at configure time.

Preserve blocking, encryption, timeout and reconnect semantics while retaining the legacy CUPS APIs as compile-time fallbacks.
2026-08-07 08:53:00 +02:00
0911aa2f2f gtk: remove unused IM module query function pointers
Keep symbol validation while avoiding unused typed variables and assignments.
2026-08-07 08:53:00 +02:00
672b195592 gtk: reuse cached module path list
Avoid computing and allocating the module path list a second time.
2026-08-07 08:53:00 +02:00
450e784037 gtk: replace deprecated IM module parser helpers
Use local compile-time selected parser helpers with a legacy Pango fallback.

Avoid temporary string decompression allocations and use unlocked stdio where available.
2026-08-07 08:53:00 +02:00
73183e1a30 gdk: add high-depth RGB image drawing
Add RGB48 and RGBX64 drawing APIs with direct conversion for common 15-, 16-, 24-, 30- and 32-bit TrueColor visuals. Preserve the existing GdkRGB path as a fallback for unsupported visuals and maximum dithering.
2026-08-05 12:15:23 +02:00
8984300bba gdk: optimize packed StaticColor conversion 2026-08-04 21:26:05 +02:00
a923aa3120 gdk: fix packed StaticColor dithering 2026-08-04 19:41:58 +02:00
b58fc23765 gdk: support 2-bit StaticColor visuals 2026-08-04 19:08:54 +02:00
e92e770558 gdk: support 3-bit StaticColor visuals 2026-08-04 18:52:31 +02:00
be64a902a5 gdk: optimize native big-endian RGB565 paths
Add native big-endian four-pixel converters for RGB565, grayscale RGB565, and dithered RGB565.

Select the block converters only where cross-target code generation is favorable: RGB on PowerPC, s390x, ARMv5+, and AArch64; grayscale on PowerPC, ARMv5+, AArch64, and m68k; and dither on PowerPC. Retain the scalar fallbacks everywhere else.

The little-endian machine code remains byte-for-byte unchanged. No runtime endian checks, allocations, or additional image buffers are introduced.

Validated with a complete build and test suite, deterministic and randomized big-endian formula tests, exact little-endian .text comparison, and cross-target code-generation checks.
2026-08-04 17:57:34 +02:00
71023e0333 gdk: add endian-aware 30-bit RGB converters
Add specialized converters for both 10:10:10 channel layouts and both X image byte orders.

Preserve depth-30 padding bits, avoid invalid negative shifts in the generic converter and select endian conversion at compile time.

Validated with a real Xvfb 30-bit A/B pixel test and cross-target endian store checks.

Derived from downstream commit 02a2c61f2d.

Co-authored-by: Daemonratte <daemonratte@daemonratte.net>
2026-08-04 15:34:12 +02:00
00177dd11c docs: use top_srcdir for GDK X11 header reference
Based on the MSYS2 0005-Fix-header-ref.all.patch.

Use an explicit top_srcdir-relative path for gdkx.h in the GDK reference documentation instead of a fragile relative path.
2026-08-04 14:02:32 +02:00
b622340b5b print: preserve default-printer wait during status updates
Based on the openSUSE gtk2-default-printer.patch.

Avoid treating printer status updates as user-driven printer selection changes, so the print dialog can continue waiting for a default printer that may appear later.
2026-08-04 12:41:19 +02:00
757774345d win32: quote icon cache manifest in resource file
Based on the MSYS2 0024-gtk-update-icon-cache-rc-quote.patch.

Quote the manifest path when generating the gtk-update-icon-cache resource file so windres parses it correctly.
2026-08-04 09:00:57 +02:00
4d7fc95583 win32: initialize key state before updating keymap
Based on the MSYS2 0023-gdkkeys-win32.c-fix-initialisation-of-key_state-in-u.patch.

Clear the key_state array before using it during keymap updates so stale state cannot affect layout handling, including Japanese IME input.
2026-08-04 09:00:57 +02:00
d181fe8fc3 icontheme: detect SVG icons by extension on Win32
Based on the MSYS2 0022-icontheme-win32-detect-SVG-files-by-extension.patch.

Some Windows systems report .svg files with a generic or incorrect content type. On Win32, fall back to the .svg extension so SVG icons can still be detected.
2026-08-04 09:00:57 +02:00
65f949bcde win32: improve mouse window lookup through transparent children
Based on the MSYS2 0013_fix_mouse_events.patch.

Use CWP_SKIPTRANSPARENT while walking from the desktop window, but stop skipping transparent windows after the first level so transparent child windows are still considered correctly.
2026-08-04 09:00:57 +02:00
8d4015ee54 quartz: avoid extra resize-idle updates on Big Sur and newer
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

Keep the existing gdk_window_process_all_updates() call for non-Quartz targets and for older macOS releases, but avoid this extra resize-idle update path on Big Sur and newer where it can contribute to expensive full-window redraw behaviour.
2026-08-04 08:45:38 +02:00
c1fc6ed642 quartz: avoid extra content invalidation on Big Sur and newer
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

Keep the existing Mojave-era setNeedsDisplay workaround for macOS 10.14 and 10.15, but avoid the extra full-window invalidation on Big Sur and newer where it can cause expensive redraw behaviour.
2026-08-04 08:45:38 +02:00
9d7c7e63d6 quartz: request 8-bit layer contents on Big Sur and newer
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

Use a dynamic Objective-C call to request 8-bit layer contents on macOS 11 and newer, avoiding a hard QuartzCore/CALayer compile-time dependency and preserving old behaviour on older macOS releases.
2026-08-04 08:45:38 +02:00
fe45d0944c quartz: avoid screen update suppression on Mojave and newer
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

NSDisableScreenUpdates and NSEnableScreenUpdates are deprecated on newer macOS releases. Keep using them for older macOS versions, but avoid them on Mojave and newer.
2026-08-04 08:45:38 +02:00
21fdf2eeaa quartz: use CGContext accessor on Yosemite and newer
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

Use the modern NSGraphicsContext CGContext accessor on Yosemite and newer, matching the existing Quartz window code, while preserving graphicsPort for older macOS versions.
2026-08-04 08:45:38 +02:00
8b7fda063e quartz: map macOS 11 and newer to internal OS versions
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

GTK2 represents macOS 10.x releases by their minor version. Read the major version as well and map macOS 11 and newer into the same sequence so Big Sur and later releases can be detected correctly.
2026-08-04 08:45:38 +02:00
0bc8029032 quartz: avoid focus locking on Mojave and newer
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

The NSView focus-locking API is deprecated on newer macOS releases and can cause expensive redraw behaviour. Keep the old path for older macOS versions, but avoid lockFocusIfCanDraw/unlockFocus on Mojave and newer.
2026-08-04 08:45:38 +02:00
72dcfc7ca5 quartz: add newer macOS version constants
Based on the MacPorts patch-gdkquartz-osx-versions.diff.

Extend the Quartz OS version enum so later macOS-specific code can
distinguish Catalina, Big Sur, Monterey, Ventura, Sonoma, and Sequoia
while preserving the existing older constants.
2026-08-04 08:45:38 +02:00
292e512bc4 build: disable GNU visibility aliases on Apple platforms
Based on the MacPorts patch-aliases.diff.

Keep the existing GNU visibility alias generation on other platforms, but avoid it on Apple targets where this alias mechanism is not suitable.
2026-08-04 08:45:38 +02:00
d8b26dc0b7 gtktrayicon: use explicit void prototypes for reserved slots
Based on the Mageia gtk+-2.24.32-warnings.patch.

Declare the reserved GtkTrayIconClass function pointers with explicit void parameter lists to avoid strict-prototype warnings without changing the class layout.
2026-08-04 08:37:17 +02:00
790b8c2b69 gtkrc: search XDG data dirs for themes
Based on the Guix gtk2-theme-paths.patch by Jookia.

Keep the existing ~/.themes and gtk_rc_get_theme_dir() lookup paths, but check g_get_system_data_dirs() in between so profile- and prefix-based theme installations can be found.
2026-08-03 16:06:17 +02:00
0e8d6a76b6 tests: fix GtkBuilder signal callback prototypes
Based on the Guix gtk2-fix-builder-test.patch.

The callbacks are connected to notify-style signals and must take a
GParamSpec pointer, not a GParamSpec by value. This avoids stack/register
ABI problems on platforms such as ppc64el.
2026-08-03 15:55:03 +02:00
1227 changed files with 75263 additions and 13221 deletions

207
ABOUT-NLS
View file

@ -1,206 +1 @@
1 Notes on the Free Translation Project
***************************************
Free software is going international! The Free Translation Project is
a way to get maintainers of free software, translators, and users all
together, so that free software will gradually become able to speak many
languages. A few packages already provide translations for their
messages.
If you found this `ABOUT-NLS' file inside a distribution, you may
assume that the distributed package does use GNU `gettext' internally,
itself available at your nearest GNU archive site. But you do _not_
need to install GNU `gettext' prior to configuring, installing or using
this package with messages translated.
Installers will find here some useful hints. These notes also
explain how users should proceed for getting the programs to use the
available translations. They tell how people wanting to contribute and
work on translations can contact the appropriate team.
When reporting bugs in the `intl/' directory or bugs which may be
related to internationalization, you should tell about the version of
`gettext' which is used. The information can be found in the
`intl/VERSION' file, in internationalized packages.
1.1 Quick configuration advice
==============================
If you want to exploit the full power of internationalization, you
should configure it using
./configure --with-included-gettext
to force usage of internationalizing routines provided within this
package, despite the existence of internationalizing capabilities in the
operating system where this package is being installed. So far, only
the `gettext' implementation in the GNU C library version 2 provides as
many features (such as locale alias, message inheritance, automatic
charset conversion or plural form handling) as the implementation here.
It is also not possible to offer this additional functionality on top
of a `catgets' implementation. Future versions of GNU `gettext' will
very likely convey even more functionality. So it might be a good idea
to change to GNU `gettext' as soon as possible.
So you need _not_ provide this option if you are using GNU libc 2 or
you have installed a recent copy of the GNU gettext package with the
included `libintl'.
1.2 INSTALL Matters
===================
Some packages are "localizable" when properly installed; the programs
they contain can be made to speak your own native language. Most such
packages use GNU `gettext'. Other packages have their own ways to
internationalization, predating GNU `gettext'.
By default, this package will be installed to allow translation of
messages. It will automatically detect whether the system already
provides the GNU `gettext' functions. If not, the included GNU
`gettext' library will be used. This library is wholly contained
within this package, usually in the `intl/' subdirectory, so prior
installation of the GNU `gettext' package is _not_ required.
Installers may use special options at configuration time for changing
the default behaviour. The commands:
./configure --with-included-gettext
./configure --disable-nls
will, respectively, bypass any pre-existing `gettext' to use the
internationalizing routines provided within this package, or else,
_totally_ disable translation of messages.
When you already have GNU `gettext' installed on your system and run
configure without an option for your new package, `configure' will
probably detect the previously built and installed `libintl.a' file and
will decide to use this. This might not be desirable. You should use
the more recent version of the GNU `gettext' library. I.e. if the file
`intl/VERSION' shows that the library which comes with this package is
more recent, you should use
./configure --with-included-gettext
to prevent auto-detection.
The configuration process will not test for the `catgets' function
and therefore it will not be used. The reason is that even an
emulation of `gettext' on top of `catgets' could not provide all the
extensions of the GNU `gettext' library.
Internationalized packages usually have many `po/LL.po' files, where
LL gives an ISO 639 two-letter code identifying the language. Unless
translations have been forbidden at `configure' time by using the
`--disable-nls' switch, all available translations are installed
together with the package. However, the environment variable `LINGUAS'
may be set, prior to configuration, to limit the installed set.
`LINGUAS' should then contain a space separated list of two-letter
codes, stating which languages are allowed.
1.3 Using This Package
======================
As a user, if your language has been installed for this package, you
only have to set the `LANG' environment variable to the appropriate
`LL_CC' combination. If you happen to have the `LC_ALL' or some other
`LC_xxx' environment variables set, you should unset them before
setting `LANG', otherwise the setting of `LANG' will not have the
desired effect. Here `LL' is an ISO 639 two-letter language code, and
`CC' is an ISO 3166 two-letter country code. For example, let's
suppose that you speak German and live in Germany. At the shell
prompt, merely execute `setenv LANG de_DE' (in `csh'),
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
This can be done from your `.login' or `.profile' file, once and for
all.
You might think that the country code specification is redundant.
But in fact, some languages have dialects in different countries. For
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
country code serves to distinguish the dialects.
The locale naming convention of `LL_CC', with `LL' denoting the
language and `CC' denoting the country, is the one use on systems based
on GNU libc. On other systems, some variations of this scheme are
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
locales supported by your system for your language by running the
command `locale -a | grep '^LL''.
Not all programs have translations for all languages. By default, an
English message is shown in place of a nonexistent translation. If you
understand other languages, you can set up a priority list of languages.
This is done through a different environment variable, called
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
for the purpose of message handling, but you still need to have `LANG'
set to the primary language; this is required by other parts of the
system libraries. For example, some Swedish users who would rather
read translations in German than English for when Swedish is not
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
Special advice for Norwegian users: The language code for Norwegian
bokma*l changed from `no' to `nb' recently (in 2003). During the
transition period, while some message catalogs for this language are
installed under `nb' and some older ones under `no', it's recommended
for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and
older translations are used.
In the `LANGUAGE' environment variable, but not in the `LANG'
environment variable, `LL_CC' combinations can be abbreviated as `LL'
to denote the language's main dialect. For example, `de' is equivalent
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
(Portuguese as spoken in Portugal) in this context.
1.4 Translating Teams
=====================
For the Free Translation Project to be a success, we need interested
people who like their own language and write it well, and who are also
able to synergize with other translators speaking the same language.
Each translation team has its own mailing list. The up-to-date list of
teams can be found at the Free Translation Project's homepage,
`https://translationproject.org/', in the "Teams" area.
If you'd like to volunteer to _work_ at translating messages, you
should become a member of the translating team for your own language.
The subscribing address is _not_ the same as the list itself, it has
`-request' appended. For example, speakers of Swedish can send a
message to `sv-request@li.org', having this message body:
subscribe
Keep in mind that team members are expected to participate
_actively_ in translations, or at solving translational difficulties,
rather than merely lurking around. If your team does not exist yet and
you want to start one, or if you are unsure about what to do or how to
get started, please write to `coordinator@translationproject.org' to
reach the coordinator for all translator teams.
The English team is special. It works at improving and uniformizing
the terminology in use. Proven linguistic skills are praised more than
programming skills, here.
1.5 Available Packages
======================
The translation matrix previously here was badly outdated and has been removed.
The most up-to-date matrix with full percentage details can be found at:
`https://translationproject.org/extra/matrix.html'
The translation project homepage:
`https://translationproject.org/html/welcome.html'
1.6 Using `gettext' in new packages
===================================
If you are writing a freely available program and want to
internationalize it you are welcome to use GNU `gettext' in your
package. Of course you have to respect the GNU Library General Public
License which covers the use of the GNU `gettext' library. This means
in particular that even non-free programs can use `libintl' as a shared
library, whereas only free software can use `libintl' as a static
library or use modified versions of `libintl'.
Once the sources are changed appropriately and the setup can handle
the use of `gettext' the only thing missing are the translations. The
Free Translation Project is also available for packages which are not
developed inside the GNU project. Therefore the information given above
applies also for every other Free Software Project. Contact
`coordinator@translationproject.org' to make the `.pot' files available
to the translation teams.
<https://www.gnu.org/software/gettext/manual/html_node/Users.html>

View file

@ -4,8 +4,8 @@ Prerequisites
GTK+ requires the following packages:
- The GLib, Pango, GdkPixbuf, ATK and cairo libraries, available at the same
location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.28.0,
Pango 1.20, GdkPixbuf 2.21.0, ATK 1.29.2 and cairo 1.6.0.
location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.38.0,
Pango 1.22, GdkPixbuf 2.21.0, ATK 1.29.2, cairo 1.6 and FriBidi 0.19.2.
- gobject-introspection 0.9.3 or newer.

View file

@ -31,10 +31,17 @@ XVFB_START = \
# test: run all tests in cwd and subdirs
test: test-cwd test-recurse
# test-cwd: run tests in cwd
# test-cwd: run tests in cwd, each one itself with TAP output, as
# gtester is deprecated since GLib 2.62 (the reports below still use it)
test-cwd: ${TEST_PROGS}
@$(SKIP_GDKTARGET) || test -z "${TEST_PROGS}" || { \
$(XVFB_START) && { set -e; $(TESTS_ENVIRONMENT) ${GTESTER} --verbose ${TEST_PROGS}; }; \
$(XVFB_START) && { \
failed= ; \
for prog in ${TEST_PROGS} ; do \
$(TESTS_ENVIRONMENT) ./$$prog --tap || failed="$$failed $$prog" ; \
done ; \
test -z "$$failed" || { echo "Gtk+Tests:ERROR: failed:$$failed" ; exit 1 ; } ; \
}; \
}
# test-recurse: run tests in subdirs
test-recurse:

View file

@ -150,12 +150,6 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if sys/sysinfo.h is available */
/* #undef HAVE_SYS_SYSINFO_H */
/* Define to 1 if sys/systeminfo.h is available */
/* #undef HAVE_SYS_SYSTEMINFO_H */
/* Define to 1 if you have the <sys/time.h> header file. */
#ifndef _MSC_VER
#define HAVE_SYS_TIME_H 1
@ -280,12 +274,6 @@
/* Whether to load modules via .la files rather than directly */
/* #undef USE_LA_MODULES */
/* Define to 1 if medialib is available and should be used */
/* #undef USE_MEDIALIB */
/* Define to 1 if medialib 2.5 is available */
/* #undef USE_MEDIALIB25 */
/* Define to 1 if XXM is available and should be used */
#ifndef _MSC_VER
# define USE_MMX 1

View file

@ -2,7 +2,7 @@
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2010 Free Software Foundation, Inc.
# Copyright 1996-2024 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
@ -25,7 +25,7 @@
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except MSVC,
# All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
@ -57,13 +57,6 @@ else
aix*)
wl='-Wl,'
;;
darwin*)
case $cc_basename in
xlc*)
wl='-Wl,'
;;
esac
;;
mingw* | cygwin* | pw32* | os2* | cegcc*)
;;
hpux9* | hpux10* | hpux11*)
@ -72,9 +65,7 @@ else
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux* | k*bsd*-gnu)
linux* | k*bsd*-gnu | kopensolaris*-gnu)
case $cc_basename in
ecc*)
wl='-Wl,'
@ -85,17 +76,26 @@ else
lf95*)
wl='-Wl,'
;;
pgcc | pgf77 | pgf90)
nagfor*)
wl='-Wl,-Wl,,'
;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
xl* | bgxl* | bgf* | mpixl*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ F* | *Sun*Fortran*)
wl=
;;
*Sun\ C*)
wl='-Wl,'
;;
@ -103,13 +103,24 @@ else
;;
esac
;;
newsos6)
;;
*nto* | *qnx*)
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
rdos*)
;;
solaris*)
wl='-Wl,'
case $cc_basename in
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
wl='-Qoption ld '
;;
*)
wl='-Wl,'
;;
esac
;;
sunos4*)
wl='-Qoption ld '
@ -171,15 +182,14 @@ if test "$with_gnu_ld" = yes; then
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we cannot use
# them.
ld_shlibs=no
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
@ -198,11 +208,13 @@ if test "$with_gnu_ld" = yes; then
ld_shlibs=no
fi
;;
haiku*)
;;
interix[3-9]*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
gnu* | linux* | k*bsd*-gnu)
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
@ -325,10 +337,14 @@ else
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
bsdi[45]*)
;;
@ -342,33 +358,20 @@ else
;;
darwin* | rhapsody*)
hardcode_direct=no
if test "$GCC" = yes ; then
if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
:
else
case $cc_basename in
xlc*)
;;
*)
ld_shlibs=no
;;
esac
ld_shlibs=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
freebsd2.[01]*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd* | dragonfly*)
freebsd* | dragonfly* | midnightbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
@ -420,6 +423,8 @@ else
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
*nto* | *qnx*)
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
hardcode_direct=yes
@ -515,7 +520,12 @@ case "$host_os" in
library_names_spec='$libname$shrext'
;;
amigaos*)
library_names_spec='$libname.a'
case "$host_cpu" in
powerpc*)
library_names_spec='$libname$shrext' ;;
m68k)
library_names_spec='$libname.a' ;;
esac
;;
beos*)
library_names_spec='$libname$shrext'
@ -534,19 +544,18 @@ case "$host_os" in
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd1*)
freebsd[23].*)
library_names_spec='$libname$shrext$versuffix'
;;
freebsd* | dragonfly*)
case "$host_os" in
freebsd[123]*)
library_names_spec='$libname$shrext$versuffix' ;;
*)
library_names_spec='$libname$shrext' ;;
esac
freebsd* | dragonfly* | midnightbsd*)
library_names_spec='$libname$shrext'
;;
gnu*)
library_names_spec='$libname$shrext'
;;
haiku*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
@ -582,7 +591,7 @@ case "$host_os" in
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux* | k*bsd*-gnu)
linux* | k*bsd*-gnu | kopensolaris*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
@ -594,7 +603,7 @@ case "$host_os" in
newsos6)
library_names_spec='$libname$shrext'
;;
nto-qnx*)
*nto* | *qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
@ -625,6 +634,9 @@ case "$host_os" in
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
tpf*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;

View file

@ -13,8 +13,8 @@ AC_PREREQ(2.62)
m4_define([gtk_major_version], [2])
m4_define([gtk_minor_version], [24])
m4_define([gtk_micro_version], [33])
m4_define([gtk_interface_age], [33])
m4_define([gtk_micro_version], [34])
m4_define([gtk_interface_age], [34])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
m4_define([gtk_version],
@ -32,6 +32,8 @@ m4_define([gtk_api_version], [2.0])
m4_define([gtk_binary_version], [2.10.0])
# required versions of other packages
# What the code needs, no more: newer API is used only where a version
# check allows it (GLib 2.38 for g_file_trash_async)
m4_define([glib_required_version], [2.38.0])
m4_define([pango_required_version], [1.22])
m4_define([atk_required_version], [1.29.2])
@ -250,6 +252,10 @@ AC_ARG_ENABLE(xrandr,
[AS_HELP_STRING([--enable-xrandr],
[support XRandR extension if available [default=yes]])],,
[enable_xrandr="yes"])
AC_ARG_ENABLE(xinput2,
[AS_HELP_STRING([--enable-xinput2],
[smooth scrolling with XInput 2.1 if available [default=yes]])],,
[enable_xinput2="yes"])
AC_ARG_ENABLE(xfixes,
[AS_HELP_STRING([--enable-xfixes],
[support XFixes extension if available [default=yes]])],,
@ -347,6 +353,25 @@ changequote([,])dnl
CPPFLAGS="$CPPFLAGS -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES"
# A 64-bit time_t on 32-bit Windows: msvcrt.dll has had the 64-bit time
# functions since Windows 2000 (so XP and ReactOS have them), but MinGW
# keeps time_t at 32 bits there unless asked. It changes the ABI of the
# time_t functions of GtkRecentInfo, so programs must be built the same
# way; gtk+-2.0.pc passes the flag on. The _unix functions of
# GtkRecentInfo give 64-bit times either way.
AC_ARG_ENABLE(win32-time64,
[AS_HELP_STRING([--enable-win32-time64],
[on 32-bit Windows, build with a 64-bit time_t (changes the ABI of the time_t functions of GtkRecentInfo) [default=no]])],,
[enable_win32_time64=no])
win32_time64_cflags=
if test x"$os_win32" = xyes && test x"$enable_win32_time64" = xyes; then
case "$host" in
x86_64-*|aarch64-*) ;;
*) win32_time64_cflags='-D__MINGW_USE_VC2005_COMPAT'
CFLAGS="$CFLAGS $win32_time64_cflags" ;;
esac
fi
# Ensure MSVC-compatible struct packing convention is used when
# compiling for Win32 with gcc.
# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
@ -399,6 +424,11 @@ PKG_CHECK_MODULES(BASE_DEPENDENCIES,
gdk-pixbuf-2.0 >= gdk_pixbuf_required_version dnl
fribidi >= fribidi_required_version])
PKG_CHECK_EXISTS([atk >= 2.12],
[AC_DEFINE([HAVE_ATK_VALUE_2_12], [1],
[Define if ATK provides the 2.12 AtkValue interface])])
## In addition to checking that cairo is present, we also need to
## check that the correct cairo backend is there. E.g. if the GDK
## target is win32 we need the cairo-win32 backend and so on.
@ -469,9 +499,165 @@ if test "x$enable_rebuilds" = "xyes" && \
fi
AC_SUBST(REBUILD)
AC_CHECK_FUNCS(lstat mkstemp flockfile getc_unlocked)
AC_CHECK_FUNCS(lstat mkstemp flockfile getc_unlocked _getc_nolock)
AC_CHECK_FUNCS(localtime_r)
#
# Vector instructions for GdkRGB. Each instruction set has a file of its
# own, compiled with the flags found here; CPUs without it are told apart
# at run time (getauxval() or elf_aux_info() where cpuid doesn't). Only
# the sets of the CPU family built for are built, and not those a set
# the build may take for granted does entirely: no MMX where SSE2 is
# there anyway (x86-64, or -msse2 and later in CFLAGS), no ARMv6 where
# NEON is (AArch64, or -mfpu=neon).
#
AC_CHECK_FUNCS(getauxval elf_aux_info)
dnl GTK_CHECK_SIMD_FLAGS(NAME, FLAGS|OTHER FLAGS, PROLOGUE, BODY):
dnl sets NAME_CFLAGS to the first flags the test compiles with (which may
dnl be none), and gtk_have_NAME to yes if there are such flags
AC_DEFUN([GTK_CHECK_SIMD_FLAGS],
[AC_MSG_CHECKING([for flags to compile $1 code])
$1_CFLAGS=
gtk_have_$1=no
gtk_save_CFLAGS="$CFLAGS"
gtk_simd_list='$2'
gtk_save_IFS="$IFS"
IFS='|'
for gtk_simd_flags in $gtk_simd_list; do
IFS="$gtk_save_IFS"
CFLAGS="$gtk_save_CFLAGS $gtk_simd_flags"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],
[$1_CFLAGS="$gtk_simd_flags"
gtk_have_$1=yes
break])
done
IFS="$gtk_save_IFS"
CFLAGS="$gtk_save_CFLAGS"
if test "x$gtk_have_$1" = xyes; then
AC_MSG_RESULT([${$1_CFLAGS:-none needed}])
else
AC_MSG_RESULT([not possible])
fi
AC_SUBST($1_CFLAGS)])
MMX_CFLAGS=
SSE2_CFLAGS=
SSSE3_CFLAGS=
AVX2_CFLAGS=
ALTIVEC_CFLAGS=
ARMV6_CFLAGS=
NEON_CFLAGS=
for gtk_set in MMX SSE2 SSSE3 AVX2 ALTIVEC ARMV6 NEON; do
eval gtk_have_$gtk_set=no
done
case "$host_cpu" in
i?86|x86_64|amd64)
AC_MSG_CHECKING([whether the build may take SSE2 for granted])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if !defined(__SSE2__) && !defined(__x86_64__)
#error not for granted
#endif]], [])],
[gtk_base_sse2=yes], [gtk_base_sse2=no])
AC_MSG_RESULT([$gtk_base_sse2])
if test "x$gtk_base_sse2" = xno; then
GTK_CHECK_SIMD_FLAGS([MMX], [-mmmx],
[#include <mmintrin.h>
#ifndef __MMX__
#error no MMX
#endif],
[__m64 v = _mm_setzero_si64 (); v = _mm_mullo_pi16 (v, v); _mm_empty ();])
fi
GTK_CHECK_SIMD_FLAGS([SSE2], [-msse2],
[#include <emmintrin.h>
#ifndef __SSE2__
#error no SSE2
#endif],
[__m128i v = _mm_setzero_si128 (); v = _mm_mullo_epi16 (v, v); (void) v;])
GTK_CHECK_SIMD_FLAGS([SSSE3], [-mssse3],
[#include <tmmintrin.h>
#ifndef __SSSE3__
#error no SSSE3
#endif],
[__m128i v = _mm_setzero_si128 (); v = _mm_shuffle_epi8 (v, v); (void) v;])
dnl not with MinGW: GCC does not align its stack for AVX there (GCC
dnl bug 54412), and unoptimized builds would crash on spills
case "$host_os" in
mingw*|cygwin*) ;;
*)
GTK_CHECK_SIMD_FLAGS([AVX2], [-mavx2],
[#include <immintrin.h>
#ifndef __AVX2__
#error no AVX2
#endif],
[__m256i v = _mm256_setzero_si256 (); v = _mm256_shuffle_epi8 (v, v); (void) v;])
;;
esac
;;
powerpc*|ppc*)
GTK_CHECK_SIMD_FLAGS([ALTIVEC], [-maltivec],
[#include <altivec.h>
#if !defined(__ALTIVEC__) || !defined(__BIG_ENDIAN__)
#error no big endian AltiVec
#endif],
[vector unsigned short v = vec_splats ((unsigned short) 1); v = vec_mladd (v, v, v); (void) v;])
;;
arm*)
AC_MSG_CHECKING([whether the build may take NEON for granted])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if !defined(__ARM_NEON) && !defined(__ARM_NEON__)
#error not for granted
#endif]], [])],
[gtk_base_neon=yes], [gtk_base_neon=no])
AC_MSG_RESULT([$gtk_base_neon])
dnl the media instructions of ARMv6, for builds for older ARMs too
if test "x$gtk_base_neon" = xno; then
GTK_CHECK_SIMD_FLAGS([ARMV6], [|-march=armv6],
[#if !defined(__ARM_ARCH_6__) && !(defined(__ARM_ARCH) && __ARM_ARCH >= 6)
#error no ARMv6
#endif
#if defined(__ARMEB__) || (defined(__thumb__) && !defined(__thumb2__))
#error no little endian ARM code
#endif],
[unsigned int r, x = 1; __asm__ ("uxtab16 %0, %1, %2, ror #8" : "=r" (r) : "r" (x), "r" (x)); (void) r;])
fi
dnl toolchains for the Raspberry Pi 1 default to ARMv6, which has no NEON
GTK_CHECK_SIMD_FLAGS([NEON], [-mfpu=neon|-march=armv7-a -mfpu=neon],
[#include <arm_neon.h>
#if (!defined(__ARM_NEON) && !defined(__ARM_NEON__)) || defined(__ARM_BIG_ENDIAN)
#error no little endian NEON
#endif],
[uint8x8x4_t v = vld4_u8 ((const unsigned char *) 0); (void) v;])
;;
aarch64*|arm64*)
dnl always there
GTK_CHECK_SIMD_FLAGS([NEON], [],
[#include <arm_neon.h>
#if !defined(__ARM_NEON) || defined(__ARM_BIG_ENDIAN)
#error no little endian NEON
#endif],
[uint8x8x4_t v = vld4_u8 ((const unsigned char *) 0); (void) v;])
;;
esac
for gtk_set in MMX SSE2 SSSE3 AVX2 ALTIVEC ARMV6 NEON; do
if eval test "x\$gtk_have_$gtk_set" = xyes; then
AC_DEFINE_UNQUOTED([GDK_RGB_SIMD_$gtk_set], [1])
fi
done
AH_TEMPLATE([GDK_RGB_SIMD_MMX], [Define to build the MMX code of GdkRGB])
AH_TEMPLATE([GDK_RGB_SIMD_SSE2], [Define to build the SSE2 code of GdkRGB])
AH_TEMPLATE([GDK_RGB_SIMD_SSSE3], [Define to build the SSSE3 code of GdkRGB])
AH_TEMPLATE([GDK_RGB_SIMD_AVX2], [Define to build the AVX2 code of GdkRGB])
AH_TEMPLATE([GDK_RGB_SIMD_ALTIVEC], [Define to build the AltiVec code of GdkRGB])
AH_TEMPLATE([GDK_RGB_SIMD_ARMV6], [Define to build the ARMv6 code of GdkRGB])
AH_TEMPLATE([GDK_RGB_SIMD_NEON], [Define to build the NEON code of GdkRGB])
AM_CONDITIONAL(GDK_RGB_SIMD_MMX, test "x$gtk_have_MMX" = xyes)
AM_CONDITIONAL(GDK_RGB_SIMD_SSE2, test "x$gtk_have_SSE2" = xyes)
AM_CONDITIONAL(GDK_RGB_SIMD_SSSE3, test "x$gtk_have_SSSE3" = xyes)
AM_CONDITIONAL(GDK_RGB_SIMD_AVX2, test "x$gtk_have_AVX2" = xyes)
AM_CONDITIONAL(GDK_RGB_SIMD_ALTIVEC, test "x$gtk_have_ALTIVEC" = xyes)
AM_CONDITIONAL(GDK_RGB_SIMD_ARMV6, test "x$gtk_have_ARMV6" = xyes)
AM_CONDITIONAL(GDK_RGB_SIMD_NEON, test "x$gtk_have_NEON" = xyes)
# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
AC_LINK_IFELSE(
@ -547,8 +733,11 @@ if test "$gtk_ok" = "yes"; then
[Define to 1 if sigsetjmp is available])
fi
# i18n stuff
AM_GNU_GETTEXT_VERSION([0.19.3])
# i18n stuff: the macros in m4/ and the po/ Makefiles are from gettext
# 0.22.5; autopoint 0.19.6 and later brings those of the gettext that
# is installed, older ones those of the version given here
AM_GNU_GETTEXT_VERSION([0.20])
AM_GNU_GETTEXT_REQUIRE_VERSION([0.20])
AM_GNU_GETTEXT([external])
LIBS="$LIBS $LIBINTL"
@ -953,38 +1142,6 @@ AM_CONDITIONAL(INCLUDE_IM_XIM, [test x"$INCLUDE_xim" = xyes])
AC_HEADER_SYS_WAIT
# Checks to see whether we should include mediaLib
# support.
#
AC_CHECK_HEADER(sys/systeminfo.h,
AC_DEFINE(HAVE_SYS_SYSTEMINFO_H, 1,
[Define to 1 if sys/systeminfo.h is available]))
AC_CHECK_HEADER(sys/sysinfo.h,
AC_DEFINE(HAVE_SYS_SYSINFO_H, 1,
[Define to 1 if sys/sysinfo.h is available]))
AC_MSG_CHECKING(for mediaLib 2.3)
use_mlib25=no
# Check for a mediaLib 2.3 function since that is what the GTK+ mediaLib
# patch requires.
AC_CHECK_LIB(mlib, mlib_ImageSetStruct, use_mlib=yes, use_mlib=no)
if test $use_mlib = yes; then
AC_DEFINE(USE_MEDIALIB, 1,
[Define to 1 if medialib is available and should be used])
MEDIA_LIB=-lmlib
AC_MSG_CHECKING(for mediaLib 2.5)
# Check for a mediaLib 2.5 function since that is what is needed for
# gdk_rgb_convert integration.
AC_CHECK_LIB(mlib, mlib_VideoColorRGBint_to_BGRAint, use_mlib25=yes, use_mlib25=no)
if test $use_mlib25 = yes; then
AC_DEFINE(USE_MEDIALIB25, 1,
[Define to 1 if medialib 2.5 is available])
fi
fi
AM_CONDITIONAL(USE_MEDIALIB, test $use_mlib = yes)
AM_CONDITIONAL(USE_MEDIALIB25, test $use_mlib25 = yes)
dnl Look for a host system's gdk-pixbuf-csource if we are cross-compiling
AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
@ -996,7 +1153,11 @@ if test $cross_compiling = yes; then
fi
fi
AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, no)
dnl the one of the build system, for the resources of demos/testpixbuf
AC_PATH_PROG(GLIB_COMPILE_RESOURCES_FOR_BUILD, glib-compile-resources, no)
if test x$GLIB_COMPILE_RESOURCES_FOR_BUILD = xno; then
AC_MSG_ERROR([glib-compile-resources of GLib is needed])
fi
if test ! -f $srcdir/gtk/gtkbuiltincache.h &&
test "x$REBUILD_PNGS" = "x#" ; then
@ -1269,6 +1430,24 @@ if test "x$gdktarget" = "xx11"; then
AM_CONDITIONAL(XINPUT_XFREE, test x$with_xinput = xxfree || test x$with_xinput = xyes)
# XInput 2.1 has the scroll valuators of high resolution wheels and
# touchpads; it is independent of the XInput 1 devices above
if test "x$enable_xinput2" != "xno" && $PKG_CONFIG --exists "xi >= 1.5" ; then
AC_DEFINE(HAVE_XINPUT2, 1, [Have XInput 2.1 for smooth scrolling])
# libXi 1.8 knows the touchpad gestures of XInput 2.4; whether the
# X server has them is asked at run time
if $PKG_CONFIG --exists "xi >= 1.8" ; then
AC_DEFINE(HAVE_XINPUT2_GESTURES, 1, [Have libXi 1.8 for the touchpad gestures of XInput 2.4])
fi
case " $X_PACKAGES " in
*" xi "*) ;;
*) X_PACKAGES="$X_PACKAGES xi" ;;
esac
fi
# Check for the RANDR extension
if test "x$enable_xrandr" != "xno" && $PKG_CONFIG --exists "xrandr >= 1.2.99" ; then
AC_DEFINE(HAVE_RANDR, 1, [Have the Xrandr extension library])
@ -1473,7 +1652,7 @@ GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X `$PKG_CONFIG --libs $PANGO_PAC
GTK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PACKAGES $GTK_PACKAGES` $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
if test x"$os_win32" = xyes; then
GTK_EXTRA_CFLAGS="$msnative_struct"
GTK_EXTRA_CFLAGS="$msnative_struct $win32_time64_cflags"
fi
GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
@ -1594,6 +1773,7 @@ else
gtk_save_libs="$LIBS"
LIBS="$CUPS_LIBS"
AC_CHECK_FUNCS(httpGetAuthString)
AC_CHECK_FUNCS(httpConnect2 httpReconnect2)
LIBS="$gtk_save_libs"
fi
fi

View file

@ -29,16 +29,13 @@ noinst_PROGRAMS = \
testpixbuf-scale \
pixbuf-demo
# Need to build test-inline-pixbufs.h for testpixbuf
# testpixbuf has two of the images inlined, as resources
noinst_PROGRAMS += testpixbuf
BUILT_SOURCES = test-inline-pixbufs.h
BUILT_SOURCES = testpixbuf-resources.c
test-inline-pixbufs.h: apple-red.png gnome-foot.png
$(GDK_PIXBUF_CSOURCE) --raw --build-list \
apple_red $(srcdir)/apple-red.png \
gnome_foot $(srcdir)/gnome-foot.png \
> test-inline-pixbufs.h \
|| (rm -f test-inline-pixbufs.h && false)
testpixbuf-resources.c: testpixbuf.gresource.xml apple-red.png gnome-foot.png
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES_FOR_BUILD) --target=$@ --sourcedir=$(srcdir) \
--generate-source --c-name testpixbuf $(srcdir)/testpixbuf.gresource.xml
testpixbuf_DEPENDENCIES = $(DEPS)
testpixbuf_drawable_DEPENDENCIES = $(DEPS)
@ -57,6 +54,7 @@ testanimation_LDADD = $(LDADDS)
pixbuf_demo_LDADD = $(LDADDS)
testpixbuf_SOURCES = testpixbuf.c pixbuf-init.c
nodist_testpixbuf_SOURCES = testpixbuf-resources.c
testpixbuf_drawable_SOURCES = testpixbuf-drawable.c pixbuf-init.c
testpixbuf_save_SOURCES = testpixbuf-save.c
testpixbuf_color_SOURCES = testpixbuf-color.c
@ -73,8 +71,9 @@ EXTRA_DIST += \
gnome-gimp.png \
gnome-gmush.png \
gnome-gsame.png \
gnu-keys.png
gnu-keys.png \
testpixbuf.gresource.xml
DISTCLEANFILES = test-inline-pixbufs.h
DISTCLEANFILES = testpixbuf-resources.c
-include $(top_srcdir)/git.mk

View file

@ -466,6 +466,7 @@ do_appwindow (GtkWidget *do_widget)
g_object_set_data_full (G_OBJECT (window), "ui-manager", merge,
g_object_unref);
gtk_ui_manager_insert_action_group (merge, action_group, 0);
g_object_unref (action_group);
gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (merge));

View file

@ -194,6 +194,8 @@ do_assistant (GtkWidget *do_widget)
create_page3 (assistant);
create_page4 (assistant);
g_signal_connect (assistant, "destroy",
G_CALLBACK (gtk_widget_destroyed), &assistant);
g_signal_connect (G_OBJECT (assistant), "cancel",
G_CALLBACK (on_assistant_close_cancel), &assistant);
g_signal_connect (G_OBJECT (assistant), "close",

View file

@ -27,6 +27,19 @@ about_activate (GtkAction *action)
gtk_widget_hide (about_dlg);
}
/* the about dialog and the builder go with the window */
static void
window_destroyed (GtkWidget *window,
gpointer user_data)
{
GObject *about_dlg = gtk_builder_get_object (builder, "aboutdialog1");
if (about_dlg)
gtk_widget_destroy (GTK_WIDGET (about_dlg));
g_object_unref (builder);
builder = NULL;
}
GtkWidget *
do_builder (GtkWidget *do_widget)
{
@ -51,6 +64,8 @@ do_builder (GtkWidget *do_widget)
gtk_widget_get_screen (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
g_signal_connect (window, "destroy",
G_CALLBACK (window_destroyed), NULL);
}
if (!gtk_widget_get_visible (window))

View file

@ -389,6 +389,8 @@ do_images (GtkWidget *do_widget)
}
image = gtk_image_new_from_pixbuf (pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
gtk_container_add (GTK_CONTAINER (frame), image);

View file

@ -216,6 +216,14 @@ window_closed (GtkWidget *widget,
return FALSE;
}
/* destroyed without being closed, the spinner must stop all the same */
static void
window_destroyed (GtkWidget *widget,
gpointer user_data)
{
window_closed (widget, NULL, user_data);
}
GtkWidget *
do_list_store (GtkWidget *do_widget)
{
@ -233,7 +241,7 @@ do_list_store (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "GtkListStore demo");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
G_CALLBACK (window_destroyed), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
vbox = gtk_vbox_new (FALSE, 8);

View file

@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "test-inline-pixbufs.h"
typedef struct {
FILE *imagefile;
@ -518,6 +517,37 @@ void size_func (GdkPixbufLoader *loader, gint width, gint height, gpointer data)
}
static gboolean
have_format (const gchar *name)
{
GSList *formats = gdk_pixbuf_get_formats (), *l;
gboolean found = FALSE;
for (l = formats; l && !found; l = l->next)
found = strcmp (gdk_pixbuf_format_get_name (l->data), name) == 0;
g_slist_free (formats);
return found;
}
/* one of the images inlined in testpixbuf-resources.c */
static GdkPixbuf *
pixbuf_from_resource (const char *name, GError **error)
{
gchar *path = g_strconcat ("/org/gtk/testpixbuf/", name, NULL);
GInputStream *stream = g_resources_open_stream (path, 0, error);
GdkPixbuf *pixbuf = NULL;
if (stream)
{
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error);
g_object_unref (stream);
}
g_free (path);
return pixbuf;
}
int
main (int argc, char **argv)
{
@ -561,7 +591,8 @@ main (int argc, char **argv)
NULL, NULL);
new_testrgb_window (pixbuf, NULL);
xpmp = xpms;
/* newer gdk-pixbuf may come without the XPM loader */
xpmp = have_format ("xpm") ? xpms : xpms + G_N_ELEMENTS (xpms) - 1;
while (*xpmp) {
pixbuf = gdk_pixbuf_new_from_xpm_data (*xpmp);
new_testrgb_window (pixbuf, NULL);
@ -569,7 +600,7 @@ main (int argc, char **argv)
}
/* Test loading from inline data. */
pixbuf = gdk_pixbuf_new_from_inline (-1, apple_red, FALSE, &error);
pixbuf = pixbuf_from_resource ("apple-red.png", &error);
if (!pixbuf)
{
fprintf (stderr, "failed to construct \"red apple\" pixbuf: %s\n",
@ -577,10 +608,11 @@ main (int argc, char **argv)
g_error_free (error);
}
else
new_testrgb_window (pixbuf, "Red apple from inlined RLE data");
new_testrgb_window (pixbuf, "Red apple from inlined PNG data");
pixbuf = gdk_pixbuf_new_from_inline (sizeof (gnome_foot), gnome_foot, TRUE, NULL);
new_testrgb_window (pixbuf, "GNOME Foot from inlined RLE data");
pixbuf = pixbuf_from_resource ("gnome-foot.png", NULL);
if (pixbuf)
new_testrgb_window (pixbuf, "GNOME Foot from inlined PNG data");
found_valid = TRUE;
} else {

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/testpixbuf">
<file>apple-red.png</file>
<file>gnome-foot.png</file>
</gresource>
</gresources>

View file

@ -37,7 +37,7 @@ IGNORE_HFILES= \
# Extra files to add when scanning (relative to $srcdir)
EXTRA_HFILES= \
../../../gdk/x11/gdkx.h
$(top_srcdir)/gdk/x11/gdkx.h
# CFLAGS and LDFLAGS for compiling scan program. Only needed
# if $(DOC_MODULE).types is non-empty.

View file

@ -335,6 +335,10 @@ gdk_draw_indexed_image
gdk_draw_gray_image
gdk_draw_rgb_32_image
gdk_draw_rgb_32_image_dithalign
gdk_draw_rgb_48_image
gdk_draw_rgb_48_image_dithalign
gdk_draw_rgbx_64_image
gdk_draw_rgbx_64_image_dithalign
GdkRgbDither
<SUBSECTION>
@ -1170,6 +1174,8 @@ gdk_get_show_events
gdk_set_show_events
gdk_event_set_screen
gdk_event_get_screen
gdk_event_get_scroll_deltas
gdk_event_get_pointer_emulated
<SUBSECTION>
gdk_setting_get

View file

@ -34,13 +34,6 @@ created in grayscale and direct color modes, and the visual is changed
in cases where a "better" visual than the default is available.
</para>
<para>
If GDK is built with the Sun mediaLib library, the GdkRGB functions are
accelerated using mediaLib, which provides hardware acceleration on Intel,
AMD, and Sparc chipsets. If desired, mediaLib support can be turned off
by setting the GDK_DISABLE_MEDIALIB environment variable.
</para>
<example>
<title>A simple example program using GdkRGB</title>
<programlisting>

View file

@ -407,6 +407,33 @@ nevertheless.
</para>
</formalpara>
<formalpara>
<title><envar>GDK_CORE_DEVICE_EVENTS</envar></title>
<para>
If set, GDK does not use XInput 2.1 and scrolls only by whole
wheel steps, as before smooth scrolling.
</para>
</formalpara>
<formalpara>
<title><envar>GDK_DISABLE_SIMD</envar>, <envar>GDK_RGB_SIMD</envar></title>
<para>
GDK converts and blends pixels with the vector instructions of the
CPU where it has them (MMX, the integer part of SSE, 3DNow!, SSE2, SSSE3,
AltiVec, NEON), with the same results as its C code. If
<envar>GDK_DISABLE_SIMD</envar> is set to anything but 0, only the
C code is used. <envar>GDK_RGB_SIMD</envar> chooses by hand, to
compare: <literal>c</literal> for none, the name of an instruction
set for that one, or <literal>kernel=set</literal> for a single
kernel, several separated by commas. The program
<command>rgbsimdbench</command> in the <filename>gdk</filename>
directory of the sources (<literal>make rgbsimdbench</literal>)
lists the kernels and sets and times them on the machine.
</para>
</formalpara>
<formalpara>
<title><envar>XDG_DATA_HOME</envar>, <envar>XDG_DATA_DIRS</envar></title>

View file

@ -91,7 +91,7 @@ create_shadow (GdkPixbuf *src)
{
for (x = 0; x < width; x++)
{
int sumr = 0, sumg = 0, sumb = 0, suma = 0;
int suma = 0;
for (i = 0; i < filter->size; i++)
{
@ -106,17 +106,7 @@ create_shadow (GdkPixbuf *src)
src_x < 0 || src_x > gdk_pixbuf_get_width (src))
continue;
sumr += src_pixels [src_y * src_rowstride +
src_x * src_bpp + 0] *
filter->data [i * filter->size + j];
sumg += src_pixels [src_y * src_rowstride +
src_x * src_bpp + 1] *
filter->data [i * filter->size + j];
sumb += src_pixels [src_y * src_rowstride +
src_x * src_bpp + 2] *
filter->data [i * filter->size + j];
/* only the alpha makes the shadow */
if (src_bpp == 4)
suma += src_pixels [src_y * src_rowstride +
src_x * src_bpp + 3] *

View file

@ -22,7 +22,6 @@ EXTRA_DIST += \
gdkkeysyms-update.pl \
gdk.def \
gdkmarshalers.list \
gdkmedialib.h \
gdkwindowimpl.h \
makeenums.pl \
makefile.msc \
@ -51,7 +50,7 @@ endif
# libtool stuff: set version and export symbols for resolving
# since automake doesn't support conditionalized libsomething_la_LDFLAGS
# we use the general approach here
LDADD = \
gdk_ldflags = \
$(GTK_LINK_FLAGS) \
-version-info $(LT_VERSION_INFO) \
-export-dynamic \
@ -59,13 +58,6 @@ LDADD = \
$(no_undefined) \
$(LIBTOOL_EXPORT_OPTIONS)
if USE_MEDIALIB
medialib_sources = \
gdkmedialib.c
else
medialib_sources =
endif
#
# setup source file variables
#
@ -115,11 +107,11 @@ gdk_built_private_headers = \
gdk_private_headers = \
gdkinternals.h \
gdkintl.h \
gdkrgbsimd.h \
gdkpoly-generic.h \
gdkregion-generic.h
gdk_c_sources = \
$(medialib_sources) \
gdk.c \
gdkapplaunchcontext.c \
gdkcairo.c \
@ -145,6 +137,7 @@ gdk_c_sources = \
gdkrectangle.c \
gdkregion-generic.c \
gdkrgb.c \
gdkrgbsimd.c \
gdkscreen.c \
gdkselection.c \
gdkvisual.c \
@ -173,22 +166,80 @@ common_sources = \
gdkmarshalers.c \
gdkmarshalers.h
# Vector versions of GdkRGB loops, each built with the flags of its
# instruction set; only those configure found useful for the CPU family
# built for.
gdk_rgb_simd_libs =
if GDK_RGB_SIMD_MMX
gdk_rgb_simd_libs += libgdk-rgb-mmx.la
endif
if GDK_RGB_SIMD_SSE2
gdk_rgb_simd_libs += libgdk-rgb-sse2.la
endif
if GDK_RGB_SIMD_SSSE3
gdk_rgb_simd_libs += libgdk-rgb-ssse3.la
endif
if GDK_RGB_SIMD_AVX2
gdk_rgb_simd_libs += libgdk-rgb-avx2.la
endif
if GDK_RGB_SIMD_ALTIVEC
gdk_rgb_simd_libs += libgdk-rgb-altivec.la
endif
if GDK_RGB_SIMD_ARMV6
gdk_rgb_simd_libs += libgdk-rgb-armv6.la
endif
if GDK_RGB_SIMD_NEON
gdk_rgb_simd_libs += libgdk-rgb-neon.la
endif
noinst_LTLIBRARIES = $(gdk_rgb_simd_libs)
EXTRA_LTLIBRARIES = \
libgdk-rgb-mmx.la \
libgdk-rgb-sse2.la \
libgdk-rgb-ssse3.la \
libgdk-rgb-avx2.la \
libgdk-rgb-altivec.la \
libgdk-rgb-armv6.la \
libgdk-rgb-neon.la
libgdk_rgb_mmx_la_SOURCES = gdkrgb-mmx.c
libgdk_rgb_mmx_la_CFLAGS = $(MMX_CFLAGS)
libgdk_rgb_sse2_la_SOURCES = gdkrgb-sse2.c
libgdk_rgb_sse2_la_CFLAGS = $(SSE2_CFLAGS)
libgdk_rgb_ssse3_la_SOURCES = gdkrgb-ssse3.c
libgdk_rgb_ssse3_la_CFLAGS = $(SSSE3_CFLAGS)
libgdk_rgb_avx2_la_SOURCES = gdkrgb-avx2.c
libgdk_rgb_avx2_la_CFLAGS = $(AVX2_CFLAGS)
libgdk_rgb_altivec_la_SOURCES = gdkrgb-altivec.c
libgdk_rgb_altivec_la_CFLAGS = $(ALTIVEC_CFLAGS)
libgdk_rgb_armv6_la_SOURCES = gdkrgb-armv6.c
libgdk_rgb_armv6_la_CFLAGS = $(ARMV6_CFLAGS)
libgdk_rgb_neon_la_SOURCES = gdkrgb-neon.c
libgdk_rgb_neon_la_CFLAGS = $(NEON_CFLAGS)
# Checks and times the kernels on this machine against the C code:
# make rgbsimdbench && ./rgbsimdbench
EXTRA_PROGRAMS = rgbsimdbench
rgbsimdbench_SOURCES = rgbsimdbench.c gdkrgbsimd.c
rgbsimdbench_CFLAGS = $(AM_CFLAGS)
rgbsimdbench_LDADD = $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
CLEANFILES += rgbsimdbench
libgdk_directfb_2_0_la_SOURCES = $(common_sources)
libgdk_directfb_2_0_la_LIBADD = directfb/libgdk-directfb.la $(GDK_DEP_LIBS)
libgdk_directfb_2_0_la_LDFLAGS = $(LDADD)
libgdk_directfb_2_0_la_LIBADD = directfb/libgdk-directfb.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
libgdk_directfb_2_0_la_LDFLAGS = $(gdk_ldflags)
libgdk_x11_2_0_la_SOURCES = $(common_sources)
libgdk_x11_2_0_la_LIBADD = x11/libgdk-x11.la $(GDK_DEP_LIBS)
libgdk_x11_2_0_la_LDFLAGS = $(LDADD)
libgdk_x11_2_0_la_LIBADD = x11/libgdk-x11.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
libgdk_x11_2_0_la_LDFLAGS = $(gdk_ldflags)
libgdk_quartz_2_0_la_SOURCES = $(common_sources) gdkkeynames.c
libgdk_quartz_2_0_la_LIBADD = quartz/libgdk-quartz.la $(GDK_DEP_LIBS)
libgdk_quartz_2_0_la_LDFLAGS = $(LDADD)
libgdk_quartz_2_0_la_LIBADD = quartz/libgdk-quartz.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
libgdk_quartz_2_0_la_LDFLAGS = $(gdk_ldflags)
libgdk_win32_2_0_la_SOURCES = $(common_sources) gdkkeynames.c
libgdk_win32_2_0_la_LIBADD = win32/libgdk-win32.la $(GDK_DEP_LIBS)
libgdk_win32_2_0_la_DEPENDENCIES = win32/libgdk-win32.la win32/rc/gdk-win32-res.o gdk.def
libgdk_win32_2_0_la_LDFLAGS = -Wl,win32/rc/gdk-win32-res.o -export-symbols $(srcdir)/gdk.def $(LDADD)
libgdk_win32_2_0_la_LIBADD = win32/libgdk-win32.la $(gdk_rgb_simd_libs) $(GDK_DEP_LIBS)
libgdk_win32_2_0_la_DEPENDENCIES = win32/libgdk-win32.la $(gdk_rgb_simd_libs) win32/rc/gdk-win32-res.o gdk.def
libgdk_win32_2_0_la_LDFLAGS = -Wl,win32/rc/gdk-win32-res.o -export-symbols $(srcdir)/gdk.def $(gdk_ldflags)
if HAVE_INTROSPECTION
@ -212,7 +263,12 @@ Gdk_2_0_gir_CFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_builddir)/gdk \
$(INCLUDES)
$(AM_CPPFLAGS)
if OS_WIN32
Gdk_2_0_gir_CFLAGS += -I$(srcdir)/win32 -I$(srcdir)
endif
INTROSPECTION_GIRS += Gdk-2.0.gir
if USE_X11
@ -260,7 +316,7 @@ GdkX11_2_0_gir_CFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_builddir)/gdk \
$(INCLUDES) \
$(AM_CPPFLAGS) \
-L$(top_builddir)/gdk
INTROSPECTION_GIRS += GdkX11-2.0.gir
@ -268,6 +324,69 @@ introspection_files += $(filter-out x11/gdkx.h, $(x11_introspection_files))
endif # USE_X11
if OS_WIN32
win32_introspection_files = \
win32/gdkapplaunchcontext-win32.c \
win32/gdkcolor-win32.c \
win32/gdkcursor-win32.c \
win32/gdkdisplay-win32.c \
win32/gdkdnd-win32.c \
win32/gdkdrawable-win32.c \
win32/gdkdrawable-win32.h \
win32/gdkevents-win32.c \
win32/gdkfont-win32.c \
win32/gdkgc-win32.c \
win32/gdkgeometry-win32.c \
win32/gdkglobals-win32.c \
win32/gdkimage-win32.c \
win32/gdkim-win32.c \
win32/gdkinput.c \
win32/gdkinput-win32.c \
win32/gdkinput-win32.h \
win32/gdkkeys-win32.c \
win32/gdkmain-win32.c \
win32/gdkpixmap-win32.c \
win32/gdkpixmap-win32.h \
win32/gdkprivate-win32.h \
win32/gdkproperty-win32.c \
win32/gdkscreen-win32.c \
win32/gdkselection-win32.c \
win32/gdkspawn-win32.c \
win32/gdktestutils-win32.c \
win32/gdkvisual-win32.c \
win32/gdkwin32.h \
win32/gdkwin32id.c \
win32/gdkwin32keys.h \
win32/gdkwindow-win32.c \
win32/gdkwindow-win32.h
GdkWin32-2.0.gir: $(gdktargetlib) Gdk-2.0.gir Makefile
GdkWin32_2_0_gir_SCANNERFLAGS = --identifier-prefix=Gdk --symbol-prefix=gdk --include-uninstalled=Gdk-2.0.gir
GdkWin32_2_0_gir_INCLUDES = Gio-2.0 GdkPixbuf-2.0 Pango-1.0
GdkWin32_2_0_gir_LIBS = $(gdktargetlib)
GdkWin32_2_0_gir_FILES = $(filter-out \
win32/gdkdrawable-win32.h \
win32/gdkinput-win32.h \
win32/gdkpixmap-win32.h \
win32/gdkprivate-win32.h \
win32/gdkwindow-win32.h, \
$(win32_introspection_files))
GdkWin32_2_0_gir_EXPORT_PACKAGES = gdk-win32-2.0
GdkWin32_2_0_gir_CFLAGS = \
-DGDK_COMPILATION \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_builddir)/gdk \
-I$(srcdir)/win32 \
-I$(srcdir) \
$(AM_CPPFLAGS) \
-L$(top_builddir)/gdk
INTROSPECTION_GIRS += GdkWin32-2.0.gir
introspection_files += $(filter-out win32/gdkwin32.h, $(win32_introspection_files))
endif # OS_WIN32
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
@ -409,7 +528,7 @@ INTROSPECTION_INTERMEDIATE_ITEMS = \
$(top_builddir)/build/win32/Gdk-2.0.gir.msvc.introspect \
$(top_builddir)/build/win32/Gdk_2_0_gir_list
Gdk_2_0_gir_MSVC_FILES = $(filter-out gdkmedialib.c, $(base_introspection_files))
Gdk_2_0_gir_MSVC_FILES = $(base_introspection_files)
Gdk_2_0_gir_MSVC_EXPORT_PACKAGES = $(Gdk_2_0_gir_EXPORT_PACKAGES)
Gdk_2_0_gir_MSVC_INCLUDE_GIRS = $(Gdk_2_0_gir_INCLUDES)
Gdk_2_0_gir_MSVC_LIBS = gdk-win32-2.0

View file

@ -366,11 +366,9 @@ gdk_event_send_client_message_for_display (GdkDisplay *display,
guint32
gdk_directfb_get_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return (guint32) tv.tv_sec * 1000 + tv.tv_usec / 1000;
/* milliseconds of the wall clock, as before, from the 64-bit time
* instead of the GTimeVal whose glong ends in 2038 on 32-bit systems */
return (guint32) (g_get_real_time () / 1000);
}
void

View file

@ -250,5 +250,20 @@ gdk_screen_is_composited (GdkScreen *screen)
return FALSE;
}
/* HiDPI: not scaled by this backend (yet) */
gint
_gdk_windowing_drawable_get_scale (GdkDrawable *drawable)
{
return 1;
}
gint
_gdk_windowing_screen_get_monitor_scale (GdkScreen *screen,
gint monitor_num)
{
return 1;
}
#define __GDK_SCREEN_X11_C__
#include "gdkaliasdef.c"

View file

@ -265,7 +265,7 @@ gdk_parse_args (int *argc,
}
g_option_context_free (option_context);
if (_gdk_debug_flags && GDK_DEBUG_GDKRGB)
if (_gdk_debug_flags & GDK_DEBUG_GDKRGB)
gdk_rgb_set_verbose (TRUE);
GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));

View file

@ -155,7 +155,7 @@ void gdk_rectangle_union (const GdkRectangle *src1,
const GdkRectangle *src2,
GdkRectangle *dest);
GType gdk_rectangle_get_type (void) G_GNUC_CONST;
GType gdk_rectangle_get_type (void);
#define GDK_TYPE_RECTANGLE (gdk_rectangle_get_type ())

View file

@ -44,11 +44,15 @@ gdk_event_free
gdk_event_get
gdk_event_get_axis
gdk_event_get_coords
gdk_event_get_event_sequence
gdk_event_get_root_coords
gdk_event_get_pointer_emulated
gdk_event_get_touchpad_emulated
gdk_event_get_screen
gdk_event_get_scroll_deltas
gdk_event_get_state
gdk_event_get_time
gdk_event_get_type G_GNUC_CONST
gdk_event_get_type
gdk_event_handler_set
gdk_event_new
gdk_event_peek
@ -186,7 +190,7 @@ gdk_utf8_to_compound_text
#if IN_HEADER(__GDK_PROPERTY_H__)
#if IN_FILE(__GDK_C__)
gdk_atom_get_type G_GNUC_CONST
gdk_atom_get_type
#endif
#endif
@ -229,54 +233,54 @@ gdk_x11_free_text_list
#if IN_HEADER(__GDK_ENUM_TYPES_H__)
#if IN_FILE(__GDK_ENUM_TYPES_C__)
gdk_rgb_dither_get_type G_GNUC_CONST
gdk_drag_protocol_get_type G_GNUC_CONST
gdk_input_source_get_type G_GNUC_CONST
gdk_input_condition_get_type G_GNUC_CONST
gdk_input_mode_get_type G_GNUC_CONST
gdk_axis_use_get_type G_GNUC_CONST
gdk_byte_order_get_type G_GNUC_CONST
gdk_cap_style_get_type G_GNUC_CONST
gdk_crossing_mode_get_type G_GNUC_CONST
gdk_extension_mode_get_type G_GNUC_CONST
gdk_event_mask_get_type G_GNUC_CONST
gdk_event_type_get_type G_GNUC_CONST
gdk_fill_get_type G_GNUC_CONST
gdk_rgb_dither_get_type
gdk_drag_protocol_get_type
gdk_input_source_get_type
gdk_input_condition_get_type
gdk_input_mode_get_type
gdk_axis_use_get_type
gdk_byte_order_get_type
gdk_cap_style_get_type
gdk_crossing_mode_get_type
gdk_extension_mode_get_type
gdk_event_mask_get_type
gdk_event_type_get_type
gdk_fill_get_type
#ifndef GDK_DISABLE_DEPRECATED
gdk_fill_rule_get_type G_GNUC_CONST
gdk_fill_rule_get_type
#endif
gdk_filter_return_get_type G_GNUC_CONST
gdk_function_get_type G_GNUC_CONST
gdk_grab_status_get_type G_GNUC_CONST
gdk_gravity_get_type G_GNUC_CONST
gdk_join_style_get_type G_GNUC_CONST
gdk_line_style_get_type G_GNUC_CONST
gdk_modifier_type_get_type G_GNUC_CONST
gdk_notify_type_get_type G_GNUC_CONST
gdk_overlap_type_get_type G_GNUC_CONST
gdk_owner_change_get_type G_GNUC_CONST
gdk_property_state_get_type G_GNUC_CONST
gdk_prop_mode_get_type G_GNUC_CONST
gdk_scroll_direction_get_type G_GNUC_CONST
gdk_setting_action_get_type G_GNUC_CONST
gdk_status_get_type G_GNUC_CONST
gdk_subwindow_mode_get_type G_GNUC_CONST
gdk_visibility_state_get_type G_GNUC_CONST
gdk_wm_decoration_get_type G_GNUC_CONST
gdk_wm_function_get_type G_GNUC_CONST
gdk_font_type_get_type G_GNUC_CONST
gdk_cursor_type_get_type G_GNUC_CONST
gdk_drag_action_get_type G_GNUC_CONST
gdk_gc_values_mask_get_type G_GNUC_CONST
gdk_window_attributes_type_get_type G_GNUC_CONST
gdk_window_class_get_type G_GNUC_CONST
gdk_window_edge_get_type G_GNUC_CONST
gdk_window_hints_get_type G_GNUC_CONST
gdk_window_state_get_type G_GNUC_CONST
gdk_window_type_get_type G_GNUC_CONST
gdk_window_type_hint_get_type G_GNUC_CONST
gdk_image_type_get_type G_GNUC_CONST
gdk_visual_type_get_type G_GNUC_CONST
gdk_filter_return_get_type
gdk_function_get_type
gdk_grab_status_get_type
gdk_gravity_get_type
gdk_join_style_get_type
gdk_line_style_get_type
gdk_modifier_type_get_type
gdk_notify_type_get_type
gdk_overlap_type_get_type
gdk_owner_change_get_type
gdk_property_state_get_type
gdk_prop_mode_get_type
gdk_scroll_direction_get_type
gdk_setting_action_get_type
gdk_status_get_type
gdk_subwindow_mode_get_type
gdk_visibility_state_get_type
gdk_wm_decoration_get_type
gdk_wm_function_get_type
gdk_font_type_get_type
gdk_cursor_type_get_type
gdk_drag_action_get_type
gdk_gc_values_mask_get_type
gdk_window_attributes_type_get_type
gdk_window_class_get_type
gdk_window_edge_get_type
gdk_window_hints_get_type
gdk_window_state_get_type
gdk_window_type_get_type
gdk_window_type_hint_get_type
gdk_image_type_get_type
gdk_visual_type_get_type
#endif
#endif
@ -285,7 +289,7 @@ gdk_visual_type_get_type G_GNUC_CONST
#ifndef GDK_DISABLE_DEPRECATED
gdk_font_from_description
#endif
gdk_font_get_type G_GNUC_CONST
gdk_font_get_type
gdk_font_ref
gdk_font_unref
#ifndef GDK_DISABLE_DEPRECATED
@ -325,6 +329,7 @@ gdk_fontset_load_for_display
#if IN_HEADER(__GDK_CAIRO_H__)
#if IN_FILE(__GDK_CAIRO_C__)
gdk_cairo_create
gdk_cairo_create_in_area_libgtk_only
gdk_cairo_reset_clip
gdk_cairo_set_source_color
gdk_cairo_set_source_pixbuf
@ -346,7 +351,7 @@ gdk_color_alloc
gdk_color_copy
gdk_color_equal
gdk_color_free
gdk_color_get_type G_GNUC_CONST
gdk_color_get_type
gdk_color_hash
gdk_colormap_alloc_color
gdk_colormap_get_system
@ -363,7 +368,7 @@ gdk_color_to_string
#if IN_HEADER(__GDK_COLOR_H__)
#if IN_FILE(__GDK_COLOR_X11_C__)
gdk_colormap_new
gdk_colormap_get_type G_GNUC_CONST
gdk_colormap_get_type
#ifndef GDK_DISABLE_DEPRECATED
gdk_colormap_change
gdk_colors_alloc
@ -380,7 +385,7 @@ gdk_colormap_get_screen
#if IN_HEADER(__GDK_CURSOR_H__)
#if IN_FILE(__GDK_CURSOR_C__)
gdk_cursor_get_type G_GNUC_CONST
gdk_cursor_get_type
gdk_cursor_get_cursor_type
gdk_cursor_new
gdk_cursor_ref
@ -412,7 +417,7 @@ gdk_device_get_name
gdk_device_get_n_axes
gdk_device_get_n_keys
gdk_device_get_source
gdk_device_get_type G_GNUC_CONST
gdk_device_get_type
gdk_device_set_axis_use
gdk_device_set_key
gdk_device_set_source
@ -458,7 +463,7 @@ gdk_display_close
gdk_display_get_core_pointer
gdk_display_get_event
gdk_display_get_pointer
gdk_display_get_type G_GNUC_CONST
gdk_display_get_type
gdk_display_get_window_at_pointer
gdk_display_is_closed
gdk_display_peek_event
@ -533,7 +538,7 @@ gdk_display_set_double_click_time
#if IN_HEADER(__GDK_DISPLAY_MANAGER_H__)
#if IN_FILE(__GDK_DISPLAY_MANAGER_C__)
gdk_display_manager_get
gdk_display_manager_get_type G_GNUC_CONST
gdk_display_manager_get_type
gdk_display_manager_list_displays
gdk_display_manager_set_default_display
gdk_display_manager_get_default_display
@ -544,7 +549,7 @@ gdk_display_manager_get_default_display
#if IN_FILE(__GDK_DND_X11_C__)
gdk_drag_abort
gdk_drag_begin
gdk_drag_context_get_type G_GNUC_CONST
gdk_drag_context_get_type
#ifndef GDK_DISABLE_DEPRECATED
gdk_drag_context_new
gdk_drag_context_ref
@ -598,7 +603,7 @@ gdk_drawable_get_visual
#endif
gdk_drawable_get_depth
gdk_drawable_get_image
gdk_drawable_get_type G_GNUC_CONST
gdk_drawable_get_type
gdk_drawable_get_visible_region
gdk_drawable_set_colormap
gdk_draw_arc
@ -630,7 +635,7 @@ gdk_draw_layout_with_colors
#if IN_HEADER(__GDK_GC_H__)
#if IN_FILE(__GDK_GC_C__)
gdk_gc_new
gdk_gc_get_type G_GNUC_CONST
gdk_gc_get_type
gdk_gc_new_with_values
#ifndef GDK_DISABLE_DEPRECATED
gdk_gc_ref
@ -672,7 +677,7 @@ gdk_gc_get_screen
#if IN_HEADER(__GDK_PIXMAP_X11_H__)
#if IN_FILE(__GDK_PIXMAP_X11_C__)
#ifdef GDK_WINDOWING_X11
gdk_pixmap_impl_x11_get_type G_GNUC_CONST
gdk_pixmap_impl_x11_get_type
#endif
#endif
#endif
@ -680,7 +685,7 @@ gdk_pixmap_impl_x11_get_type G_GNUC_CONST
#if IN_HEADER(__GDK_WINDOW_X11_H__)
#if IN_FILE(__GDK_WINDOW_X11_C__)
#ifdef GDK_WINDOWING_X11
gdk_window_impl_x11_get_type G_GNUC_CONST
gdk_window_impl_x11_get_type
#endif
#endif
#endif
@ -767,7 +772,7 @@ gdk_window_is_input_only
gdk_window_is_shaped
gdk_window_is_viewable
gdk_window_is_visible
gdk_window_object_get_type G_GNUC_CONST
gdk_window_object_get_type
gdk_window_peek_children
gdk_window_process_all_updates
gdk_window_process_updates
@ -777,6 +782,7 @@ gdk_window_remove_redirection
gdk_window_set_debug_updates
gdk_window_set_user_data
gdk_window_thaw_toplevel_updates_libgtk_only
gdk_window_set_touch_emulation_libgtk_only
gdk_window_thaw_updates
gdk_window_set_composited
gdk_pointer_grab
@ -788,6 +794,7 @@ gdk_window_get_display
gdk_window_get_visual
gdk_window_get_width
gdk_window_get_height
gdk_window_get_scale_factor
#endif
#endif
@ -801,7 +808,7 @@ gdk_offscreen_window_get_embedder
#if IN_HEADER(__GDK_INTERNALS_H__)
#if IN_FILE(__GDK_OFFSCREEN_WINDOW_C__)
gdk_offscreen_window_get_type G_GNUC_CONST
gdk_offscreen_window_get_type
#endif
#endif
@ -892,14 +899,14 @@ gdk_image_new_bitmap
#endif
gdk_image_get_pixel
gdk_image_put_pixel
gdk_image_get_type G_GNUC_CONST
gdk_image_get_type
#endif
#endif
#if IN_HEADER(__GDK_KEYS_H__)
#if IN_FILE(__GDK_KEYS_C__)
gdk_keymap_get_default
gdk_keymap_get_type G_GNUC_CONST
gdk_keymap_get_type
gdk_keyval_is_lower G_GNUC_CONST
gdk_keyval_is_upper G_GNUC_CONST
gdk_keyval_to_lower G_GNUC_CONST
@ -974,7 +981,7 @@ gdk_visual_get_best_with_both
gdk_visual_get_best_with_depth
gdk_visual_get_best_with_type
gdk_visual_get_screen
gdk_visual_get_type G_GNUC_CONST
gdk_visual_get_type
#endif
#endif
@ -999,7 +1006,7 @@ gdk_pango_context_set_colormap
gdk_pango_layout_get_clip_region
gdk_pango_layout_line_get_clip_region
gdk_pango_renderer_get_default
gdk_pango_renderer_get_type G_GNUC_CONST
gdk_pango_renderer_get_type
gdk_pango_renderer_new
gdk_pango_renderer_set_drawable
gdk_pango_renderer_set_gc
@ -1036,7 +1043,7 @@ gdk_pixmap_create_from_xpm
gdk_pixmap_colormap_create_from_xpm_d
gdk_pixmap_create_from_xpm_d
gdk_pixmap_get_size
gdk_pixmap_get_type G_GNUC_CONST
gdk_pixmap_get_type
gdk_pixmap_new
#endif
#endif
@ -1093,7 +1100,7 @@ gdk_region_polygon
#if IN_FILE(__GDK_RGB_C__)
gdk_rgb_cmap_free
gdk_rgb_cmap_copy
gdk_rgb_cmap_get_type G_GNUC_CONST
gdk_rgb_cmap_get_type
gdk_rgb_cmap_new
gdk_rgb_colormap_ditherable
gdk_rgb_ditherable
@ -1118,15 +1125,25 @@ gdk_draw_rgb_image_dithalign
#endif
#endif
#if IN_HEADER(__GDK_RGB_H__)
#if IN_FILE(__GDK_RGB_C__)
gdk_draw_rgb_48_image
gdk_draw_rgb_48_image_dithalign
gdk_draw_rgbx_64_image
gdk_draw_rgbx_64_image_dithalign
#endif
#endif
#if IN_HEADER(__GDK_SCREEN_H__)
#if IN_FILE(__GDK_SCREEN_C__)
gdk_screen_get_type G_GNUC_CONST
gdk_screen_get_type
gdk_screen_get_monitor_at_point
gdk_screen_get_monitor_at_window
gdk_screen_set_font_options
gdk_screen_get_font_options
gdk_screen_set_resolution
gdk_screen_get_resolution
gdk_screen_get_monitor_scale_factor
#endif
#endif
@ -1293,7 +1310,7 @@ gdk_win32_selection_add_targets
#if IN_HEADER(__GDK_WIN32_H__)
#if IN_FILE(__GDK_KEYS_WIN32_C__)
gdk_win32_keymap_get_type G_GNUC_CONST
gdk_win32_keymap_get_type
gdk_win32_keymap_check_compose
#endif
#endif
@ -1408,7 +1425,7 @@ gdk_xid_table_lookup_for_display
#if IN_HEADER(__GDK_APP_LAUNCH_CONTEXT_H__)
#if IN_FILE(__GDK_APP_LAUNCH_CONTEXT_C__)
gdk_app_launch_context_get_type G_GNUC_CONST
gdk_app_launch_context_get_type
gdk_app_launch_context_new
gdk_app_launch_context_set_display
gdk_app_launch_context_set_screen
@ -1421,7 +1438,7 @@ gdk_app_launch_context_set_icon_name
#if IN_HEADER(__GDK_WINDOW_IMPL_H__)
#if IN_FILE(__GDK_WINDOW_IMPL_C__)
gdk_window_impl_get_type G_GNUC_CONST
gdk_window_impl_get_type
#endif
#endif

View file

@ -17,7 +17,10 @@
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gdkcairo.h"
#include "gdkrgbsimd.h"
#include "gdkdrawable.h"
#include "gdkinternals.h"
#include "gdkregion-generic.h"
@ -30,6 +33,8 @@ gdk_ensure_surface_flush (gpointer surface)
cairo_surface_destroy (surface);
}
static const cairo_user_data_key_t surface_flush_key;
/**
* gdk_cairo_create:
* @drawable: a #GdkDrawable
@ -50,7 +55,6 @@ gdk_ensure_surface_flush (gpointer surface)
cairo_t *
gdk_cairo_create (GdkDrawable *drawable)
{
static const cairo_user_data_key_t key;
cairo_surface_t *surface;
cairo_t *cr;
@ -67,11 +71,60 @@ gdk_cairo_create (GdkDrawable *drawable)
* on X11 (where flushing is a no-op). For details, see
* https://bugzilla.gnome.org/show_bug.cgi?id=628291
*/
cairo_set_user_data (cr, &key, surface, gdk_ensure_surface_flush);
cairo_set_user_data (cr, &surface_flush_key, surface, gdk_ensure_surface_flush);
return cr;
}
/* gdk_cairo_create() for drawing that stays within @area (in the
* coordinates of @drawable): for a window whose clip has many
* rectangles, only those parts of it within @area make the clip */
cairo_t *
_gdk_cairo_create_in_area (GdkDrawable *drawable,
const GdkRectangle *area)
{
cairo_surface_t *surface;
cairo_t *cr;
if (!GDK_IS_WINDOW (drawable) ||
_gdk_window_get_cairo_clip_n_rects ((GdkWindow *) drawable) <= 2)
return gdk_cairo_create (drawable);
surface = _gdk_drawable_ref_cairo_surface (drawable);
cr = cairo_create (surface);
_gdk_window_set_cairo_clip_in_area ((GdkWindow *) drawable, cr, area);
cairo_set_user_data (cr, &surface_flush_key, surface, gdk_ensure_surface_flush);
return cr;
}
/**
* gdk_cairo_create_in_area_libgtk_only:
* @drawable: a #GdkDrawable
* @area: the area that will be drawn
*
* Like gdk_cairo_create(), for drawing that stays inside @area: of the
* clip of a window only the rectangles meeting @area are given to cairo,
* which within @area is the same clip. Theme engines that clip to the
* area they are given anyway spare cairo the whole clip of the window,
* which during an expose can be many rectangles, for each part they
* draw. Private to GTK+ and its modules.
*
* Return value: A newly created Cairo context. Free with
* cairo_destroy() when you are done drawing.
**/
cairo_t *
gdk_cairo_create_in_area_libgtk_only (GdkDrawable *drawable,
const GdkRectangle *area)
{
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
if (!area)
return gdk_cairo_create (drawable);
return _gdk_cairo_create_in_area (drawable, area);
}
/**
* gdk_cairo_reset_clip:
* @cr: a #cairo_t
@ -173,24 +226,8 @@ gdk_cairo_region (cairo_t *cr,
boxes[i].y2 - boxes[i].y1);
}
/**
* gdk_cairo_set_source_pixbuf:
* @cr: a #Cairo context
* @pixbuf: a #GdkPixbuf
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
*
* Sets the given pixbuf as the source pattern for the Cairo context.
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
*
* Since: 2.8
**/
void
gdk_cairo_set_source_pixbuf (cairo_t *cr,
const GdkPixbuf *pixbuf,
double pixbuf_x,
double pixbuf_y)
static cairo_surface_t *
gdk_cairo_surface_from_pixbuf (const GdkPixbuf *pixbuf)
{
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
@ -202,6 +239,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
cairo_format_t format;
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
const GdkRgbSimd *simd = _gdk_rgb_simd_get ();
cairo_status_t status;
int j;
@ -228,52 +266,60 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
{
guchar *p = gdk_pixels;
guchar *q = cairo_pixels;
gint done = 0;
/* vector code where there is some, C for the rest of the row */
if (n_channels == 3 && simd->rgb_to_x888)
done = simd->rgb_to_x888 ((guint32 *) q, p, width);
else if (n_channels == 4 && simd->rgba_to_argb)
done = simd->rgba_to_argb ((guint32 *) q, p, width);
p += done * n_channels;
q += done * 4;
/* One word out for each pixel, so that machines without vector
* units, the PowerPC G3 or ARMv5, store once, not three or four
* times; and the unused byte of RGB24 gets a value */
if (n_channels == 3)
{
guchar *end = p + 3 * width;
guchar *end = gdk_pixels + 3 * width;
guint32 *q32 = (guint32 *) q;
while (p < end)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
q[0] = p[2];
q[1] = p[1];
q[2] = p[0];
#else
q[1] = p[0];
q[2] = p[1];
q[3] = p[2];
#endif
p += 3;
q += 4;
}
for (; p < end; p += 3)
*q32++ = 0xff000000 | ((guint32) p[0] << 16) | (p[1] << 8) | p[2];
}
else
{
guchar *end = p + 4 * width;
guint t1,t2,t3;
guchar *end = gdk_pixels + 4 * width;
guint32 *q32 = (guint32 *) q;
#define MULT(d,c,a,t) G_STMT_START { t = c * a + 0x80; d = ((t >> 8) + t) >> 8; } G_STMT_END
while (p < end)
/* Red and blue 16 bits apart in one register, multiplied by
* alpha at once: c * a / 255 to the nearest, as
* ((t >> 8) + t) >> 8 with t = c * a + 0x80, which does not
* carry from one into the other. The pixel is read as one word
* as well. */
for (; p < end; p += 4)
{
guint32 w, a, rb, g;
memcpy (&w, p, 4);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
MULT(q[0], p[2], p[3], t1);
MULT(q[1], p[1], p[3], t2);
MULT(q[2], p[0], p[3], t3);
q[3] = p[3];
a = w >> 24;
rb = w & 0x00ff00ff; /* B << 16 | R */
g = (w >> 8) & 0xff;
#else
q[0] = p[3];
MULT(q[1], p[0], p[3], t1);
MULT(q[2], p[1], p[3], t2);
MULT(q[3], p[2], p[3], t3);
a = w & 0xff;
rb = (w >> 8) & 0x00ff00ff; /* R << 16 | B */
g = (w >> 16) & 0xff;
#endif
p += 4;
q += 4;
rb = rb * a + 0x00800080;
rb = ((((rb >> 8) & 0x00ff00ff) + rb) >> 8) & 0x00ff00ff;
g = g * a + 0x80;
g = ((g >> 8) + g) >> 8;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
rb = (rb << 16) | (rb >> 16); /* R << 16 | B */
#endif
*q32++ = (a << 24) | rb | (g << 8);
}
#undef MULT
}
gdk_pixels += gdk_rowstride;
@ -281,6 +327,104 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
}
out:
return surface;
}
/* GTK marks the pixbufs it renders for its icon caches with this,
* as no one may change them; their cairo surface is kept with them,
* so that a cached icon is neither converted nor uploaded again. */
#define PIXBUF_SHARED_KEY "gdk-pixbuf-shared"
static const cairo_user_data_key_t gdk_cairo_hidpi_key;
void
_gdk_cairo_surface_set_hidpi_scale (cairo_surface_t *surface,
gint scale)
{
cairo_surface_set_user_data (surface, &gdk_cairo_hidpi_key,
GINT_TO_POINTER (scale > 1 ? scale : 0), NULL);
}
/**
* gdk_cairo_set_source_pixbuf:
* @cr: a #Cairo context
* @pixbuf: a #GdkPixbuf
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
*
* Sets the given pixbuf as the source pattern for the Cairo context.
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
*
* Since: 2.8
**/
void
gdk_cairo_set_source_pixbuf (cairo_t *cr,
const GdkPixbuf *pixbuf,
double pixbuf_x,
double pixbuf_y)
{
static GQuark quark_shared, quark_surface;
cairo_surface_t *surface;
if (!quark_shared)
{
quark_shared = g_quark_from_static_string (PIXBUF_SHARED_KEY);
quark_surface = g_quark_from_static_string ("gdk-cairo-surface");
}
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 14, 0)
{
/* HiDPI: on a surface of the window system with more pixels than
* GDK's, the pixbuf's own picture of that resolution, if it has
* one, else its pixels as sharp blocks (where it is not scaled) */
gdouble sx = 1, sy = 1;
cairo_matrix_t m;
GdkPixbuf *hires;
cairo_surface_get_device_scale (cairo_get_target (cr), &sx, &sy);
if (sx == 1 && sy == 1)
sx = sy = GPOINTER_TO_INT (cairo_surface_get_user_data (cairo_get_target (cr),
&gdk_cairo_hidpi_key));
if (sx > 1 && sx == sy && sx == (gint) sx)
{
hires = _gdk_pixbuf_get_hires ((GdkPixbuf *) pixbuf, (gint) sx);
if (hires)
{
surface = gdk_cairo_surface_from_pixbuf (hires);
cairo_surface_set_device_scale (surface, sx, sy);
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
cairo_surface_destroy (surface);
return;
}
cairo_get_matrix (cr, &m);
if (m.xx == 1 && m.yy == 1 && m.xy == 0 && m.yx == 0)
{
surface = gdk_cairo_surface_from_pixbuf (pixbuf);
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
cairo_surface_destroy (surface);
return;
}
}
}
#endif
if (g_object_get_qdata (G_OBJECT (pixbuf), quark_shared))
{
surface = g_object_get_qdata (G_OBJECT (pixbuf), quark_surface);
if (!surface)
{
surface = gdk_cairo_surface_from_pixbuf (pixbuf);
g_object_set_qdata_full (G_OBJECT (pixbuf), quark_surface, surface,
(GDestroyNotify) cairo_surface_destroy);
}
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
return;
}
surface = gdk_cairo_surface_from_pixbuf (pixbuf);
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
cairo_surface_destroy (surface);
}

View file

@ -31,6 +31,10 @@
G_BEGIN_DECLS
cairo_t *gdk_cairo_create (GdkDrawable *drawable);
/* private, for the theme engines of GTK+ */
cairo_t *gdk_cairo_create_in_area_libgtk_only (GdkDrawable *drawable,
const GdkRectangle *area);
void gdk_cairo_reset_clip (cairo_t *cr,
GdkDrawable *drawable);

View file

@ -86,7 +86,7 @@ struct _GdkColormapClass
};
GType gdk_colormap_get_type (void) G_GNUC_CONST;
GType gdk_colormap_get_type (void);
GdkColormap* gdk_colormap_new (GdkVisual *visual,
gboolean allocate);
@ -140,7 +140,7 @@ gboolean gdk_color_equal (const GdkColor *colora,
const GdkColor *colorb);
gchar * gdk_color_to_string (const GdkColor *color);
GType gdk_color_get_type (void) G_GNUC_CONST;
GType gdk_color_get_type (void);
/* The following functions are deprecated */
#ifndef GDK_DISABLE_DEPRECATED

View file

@ -134,7 +134,7 @@ struct _GdkCursor
/* Cursors
*/
GType gdk_cursor_get_type (void) G_GNUC_CONST;
GType gdk_cursor_get_type (void);
GdkCursor* gdk_cursor_new_for_display (GdkDisplay *display,
GdkCursorType cursor_type);

View file

@ -138,7 +138,7 @@ struct _GdkDisplayPointerHooks
gint *win_y);
};
GType gdk_display_get_type (void) G_GNUC_CONST;
GType gdk_display_get_type (void);
GdkDisplay *gdk_display_open (const gchar *display_name);
const gchar * gdk_display_get_name (GdkDisplay *display);

View file

@ -54,7 +54,7 @@ struct _GdkDisplayManagerClass
GdkDisplay *display);
};
GType gdk_display_manager_get_type (void) G_GNUC_CONST;
GType gdk_display_manager_get_type (void);
GdkDisplayManager *gdk_display_manager_get (void);
GdkDisplay * gdk_display_manager_get_default_display (GdkDisplayManager *display_manager);

View file

@ -103,7 +103,7 @@ struct _GdkDragContextClass {
/* Drag and Drop */
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
GType gdk_drag_context_get_type (void);
#if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
GdkDragContext * gdk_drag_context_new (void);
#endif

View file

@ -84,6 +84,13 @@ gdk_drawable_class_init (GdkDrawableClass *klass)
klass->get_visible_region = gdk_drawable_real_get_visible_region;
klass->draw_pixbuf = gdk_drawable_real_draw_pixbuf;
klass->draw_drawable = gdk_drawable_real_draw_drawable;
/* how theme engines built outside GTK+, which must load into other
* builds of GTK+ 2 too, find gdk_cairo_create_in_area_libgtk_only():
* where this is not set they use gdk_cairo_create() */
g_type_set_qdata (G_TYPE_FROM_CLASS (klass),
g_quark_from_static_string ("gdk-cairo-create-in-area"),
(gpointer) gdk_cairo_create_in_area_libgtk_only);
}
static void
@ -794,12 +801,6 @@ gdk_draw_image (GdkDrawable *drawable,
* On older X servers, rendering pixbufs with an alpha channel involves round
* trips to the X server, and may be somewhat slow.
*
* If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf
* function is accelerated using mediaLib, which provides hardware
* acceleration on Intel, AMD, and Sparc chipsets. If desired, mediaLib
* support can be turned off by setting the GDK_DISABLE_MEDIALIB environment
* variable.
*
* Since: 2.2
*
* Deprecated: 2.22: Use gdk_cairo_set_source_pixbuf() and cairo_paint() or
@ -948,7 +949,7 @@ real_draw_glyphs (GdkDrawable *drawable,
cairo_t *cr;
cr = gdk_cairo_create (drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable, TRUE);
if (matrix)
{
@ -1078,7 +1079,7 @@ gdk_draw_trapezoids (GdkDrawable *drawable,
g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL);
cr = gdk_cairo_create (drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL, TRUE, drawable, TRUE);
for (i = 0; i < n_trapezoids; i++)
{
@ -1403,174 +1404,62 @@ composite (guchar *src_buf,
}
}
static void
composite_0888 (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height)
/* Blends @pixbuf over the drawable piece by piece, in the drawable's
* own pixel format. Returns FALSE, having drawn nothing, where GdkRGB
* can't do that (palettes, gray levels, dithering). */
static gboolean
composite_on_images (GdkDrawable *drawable,
GdkDrawable *real_drawable,
GdkGC *gc,
GdkPixbuf *pixbuf,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height,
GdkRgbDither dither)
{
guchar *src = src_buf;
guchar *dest = dest_buf;
GdkColormap *colormap = gdk_drawable_get_colormap (drawable);
guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
gint x0, y0;
while (height--)
if (!colormap)
return FALSE;
for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
{
gint twidth = width;
guchar *p = src;
guchar *q = dest;
gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
if (dest_byte_order == GDK_LSB_FIRST)
for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
{
while (twidth--)
{
guint t;
gint width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
gint xs0, ys0;
GdkImage *image;
t = p[3] * p[2] + (255 - p[3]) * q[0] + 0x80;
q[0] = (t + (t >> 8)) >> 8;
t = p[3] * p[1] + (255 - p[3]) * q[1] + 0x80;
q[1] = (t + (t >> 8)) >> 8;
t = p[3] * p[0] + (255 - p[3]) * q[2] + 0x80;
q[2] = (t + (t >> 8)) >> 8;
p += 4;
q += 4;
}
image = _gdk_image_get_scratch (gdk_drawable_get_screen (drawable),
width1, height1,
gdk_drawable_get_depth (drawable), &xs0, &ys0);
gdk_drawable_copy_to_image (drawable, image,
dest_x + x0, dest_y + y0,
xs0, ys0,
width1, height1);
/* this fails for the first piece or for none */
if (!_gdk_rgb_composite (colormap, image, xs0, ys0, width1, height1,
pixels + (src_y + y0) * rowstride + (src_x + x0) * 4,
rowstride, dither))
return FALSE;
gdk_draw_image (real_drawable, gc, image,
xs0, ys0,
dest_x + x0, dest_y + y0,
width1, height1);
}
else
{
while (twidth--)
{
guint t;
t = p[3] * p[0] + (255 - p[3]) * q[1] + 0x80;
q[1] = (t + (t >> 8)) >> 8;
t = p[3] * p[1] + (255 - p[3]) * q[2] + 0x80;
q[2] = (t + (t >> 8)) >> 8;
t = p[3] * p[2] + (255 - p[3]) * q[3] + 0x80;
q[3] = (t + (t >> 8)) >> 8;
p += 4;
q += 4;
}
}
src += src_rowstride;
dest += dest_rowstride;
}
}
#ifdef USE_MEDIALIB
static void
composite_0888_medialib (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height)
{
guchar *src = src_buf;
guchar *dest = dest_buf;
mlib_image img_src, img_dst;
mlib_ImageSetStruct (&img_dst,
MLIB_BYTE,
4,
width,
height,
dest_rowstride,
dest_buf);
mlib_ImageSetStruct (&img_src,
MLIB_BYTE,
4,
width,
height,
src_rowstride,
src_buf);
if (dest_byte_order == GDK_LSB_FIRST)
mlib_ImageBlendRGBA2BGRA (&img_dst, &img_src);
else
mlib_ImageBlendRGBA2ARGB (&img_dst, &img_src);
}
#endif
static void
composite_565 (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height)
{
guchar *src = src_buf;
guchar *dest = dest_buf;
while (height--)
{
gint twidth = width;
guchar *p = src;
gushort *q = (gushort *)dest;
while (twidth--)
{
guchar a = p[3];
guint tr, tg, tb;
guint tr1, tg1, tb1;
guint tmp = *q;
#if 1
/* This is fast, and corresponds to what composite() above does
* if we converted to 8-bit first.
*/
tr = (tmp & 0xf800);
tr1 = a * p[0] + (255 - a) * ((tr >> 8) + (tr >> 13)) + 0x80;
tg = (tmp & 0x07e0);
tg1 = a * p[1] + (255 - a) * ((tg >> 3) + (tg >> 9)) + 0x80;
tb = (tmp & 0x001f);
tb1 = a * p[2] + (255 - a) * ((tb << 3) + (tb >> 2)) + 0x80;
*q = (((tr1 + (tr1 >> 8)) & 0xf800) |
(((tg1 + (tg1 >> 8)) & 0xfc00) >> 5) |
((tb1 + (tb1 >> 8)) >> 11));
#else
/* This version correspond to the result we get with XRENDER -
* a bit of precision is lost since we convert to 8 bit after premultiplying
* instead of at the end
*/
guint tr2, tg2, tb2;
guint tr3, tg3, tb3;
tr = (tmp & 0xf800);
tr1 = (255 - a) * ((tr >> 8) + (tr >> 13)) + 0x80;
tr2 = a * p[0] + 0x80;
tr3 = ((tr1 + (tr1 >> 8)) >> 8) + ((tr2 + (tr2 >> 8)) >> 8);
tg = (tmp & 0x07e0);
tg1 = (255 - a) * ((tg >> 3) + (tg >> 9)) + 0x80;
tg2 = a * p[0] + 0x80;
tg3 = ((tg1 + (tg1 >> 8)) >> 8) + ((tg2 + (tg2 >> 8)) >> 8);
tb = (tmp & 0x001f);
tb1 = (255 - a) * ((tb << 3) + (tb >> 2)) + 0x80;
tb2 = a * p[0] + 0x80;
tb3 = ((tb1 + (tb1 >> 8)) >> 8) + ((tb2 + (tb2 >> 8)) >> 8);
*q = (((tr3 & 0xf8) << 8) |
((tg3 & 0xfc) << 3) |
((tb3 >> 3)));
#endif
p += 4;
q++;
}
src += src_rowstride;
dest += dest_rowstride;
}
return TRUE;
}
/* Implementation of the old vfunc in terms of the new one
@ -1706,101 +1595,26 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable *drawable,
if (gdk_pixbuf_get_has_alpha (pixbuf))
{
GdkVisual *visual = gdk_drawable_get_visual (drawable);
void (*composite_func) (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height) = NULL;
if (composite_on_images (drawable, real_drawable, gc, pixbuf,
src_x, src_y, dest_x, dest_y, width, height, dither))
return;
/* First we see if we have a visual-specific composition function that can composite
* the pixbuf data directly onto the image
/* Palettes, gray levels, dithering: composite against the
* drawable as 24-bit RGB, and convert back.
*/
if (visual)
{
gint bits_per_pixel = _gdk_windowing_get_bits_for_depth (gdk_drawable_get_display (drawable),
visual->depth);
composited = gdk_pixbuf_get_from_drawable (NULL,
drawable,
NULL,
dest_x, dest_y,
0, 0,
width, height);
if (visual->byte_order == (G_BYTE_ORDER == G_BIG_ENDIAN ? GDK_MSB_FIRST : GDK_LSB_FIRST) &&
visual->depth == 16 &&
visual->red_mask == 0xf800 &&
visual->green_mask == 0x07e0 &&
visual->blue_mask == 0x001f)
composite_func = composite_565;
else if (visual->depth == 24 && bits_per_pixel == 32 &&
visual->red_mask == 0xff0000 &&
visual->green_mask == 0x00ff00 &&
visual->blue_mask == 0x0000ff)
{
#ifdef USE_MEDIALIB
if (_gdk_use_medialib ())
composite_func = composite_0888_medialib;
else
composite_func = composite_0888;
#else
composite_func = composite_0888;
#endif
}
}
/* We can't use our composite func if we are required to dither
*/
if (composite_func && !(dither == GDK_RGB_DITHER_MAX && visual->depth != 24))
{
gint x0, y0;
for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
{
gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
{
gint xs0, ys0;
gint width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
GdkImage *image = _gdk_image_get_scratch (gdk_drawable_get_screen (drawable),
width1, height1,
gdk_drawable_get_depth (drawable), &xs0, &ys0);
gdk_drawable_copy_to_image (drawable, image,
dest_x + x0, dest_y + y0,
xs0, ys0,
width1, height1);
(*composite_func) (gdk_pixbuf_get_pixels (pixbuf) + (src_y + y0) * gdk_pixbuf_get_rowstride (pixbuf) + (src_x + x0) * 4,
gdk_pixbuf_get_rowstride (pixbuf),
(guchar*)image->mem + ys0 * image->bpl + xs0 * image->bpp,
image->bpl,
visual->byte_order,
width1, height1);
gdk_draw_image (real_drawable, gc, image,
xs0, ys0,
dest_x + x0, dest_y + y0,
width1, height1);
}
}
goto out;
}
else
{
/* No special composition func, convert dest to 24 bit RGB data, composite against
* that, and convert back.
*/
composited = gdk_pixbuf_get_from_drawable (NULL,
drawable,
NULL,
dest_x, dest_y,
0, 0,
width, height);
if (composited)
composite (gdk_pixbuf_get_pixels (pixbuf) + src_y * gdk_pixbuf_get_rowstride (pixbuf) + src_x * 4,
gdk_pixbuf_get_rowstride (pixbuf),
gdk_pixbuf_get_pixels (composited),
gdk_pixbuf_get_rowstride (composited),
width, height);
}
if (composited)
composite (gdk_pixbuf_get_pixels (pixbuf) + src_y * gdk_pixbuf_get_rowstride (pixbuf) + src_x * 4,
gdk_pixbuf_get_rowstride (pixbuf),
gdk_pixbuf_get_pixels (composited),
gdk_pixbuf_get_rowstride (composited),
width, height);
}
if (composited)
@ -1833,7 +1647,6 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable *drawable,
x_dither, y_dither);
}
out:
if (composited)
g_object_unref (composited);
}
@ -1975,5 +1788,30 @@ _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
}
/* HiDPI: a pixbuf of GTK+ can carry one with as many more pixels as a
* scale (icons of the icon theme and the stock icons do); drawn on a
* drawable of that scale, its pixels are those of the X server */
GdkPixbuf *
_gdk_pixbuf_get_hires (GdkPixbuf *pixbuf,
gint scale)
{
gchar key[32];
GdkPixbuf *hires;
if (scale <= 1)
return NULL;
g_snprintf (key, sizeof key, "gdk-pixbuf-hires-%d", scale);
hires = g_object_get_data (G_OBJECT (pixbuf), key);
if (hires &&
gdk_pixbuf_get_width (hires) == gdk_pixbuf_get_width (pixbuf) * scale &&
gdk_pixbuf_get_height (hires) == gdk_pixbuf_get_height (pixbuf) * scale &&
gdk_pixbuf_get_n_channels (hires) == gdk_pixbuf_get_n_channels (pixbuf) &&
gdk_pixbuf_get_has_alpha (hires) == gdk_pixbuf_get_has_alpha (pixbuf))
return hires;
return NULL;
}
#define __GDK_DRAW_C__
#include "gdkaliasdef.c"

View file

@ -236,7 +236,7 @@ struct _GdkTrapezoid
double y1, x11, x21, y2, x12, x22;
};
GType gdk_drawable_get_type (void) G_GNUC_CONST;
GType gdk_drawable_get_type (void);
/* Manipulation of drawables
*/

View file

@ -17,7 +17,7 @@ G_BEGIN_DECLS
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
GType @enum_name@_get_type (void);
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
/*** END value-header ***/

View file

@ -32,6 +32,10 @@
#include "gdkprivate.h"
#include "gdkalias.h"
/* the touch event of GTK+ 3 fits in the GdkEvent of GTK+ 2, whose size
* is ABI: on LP64 88 bytes, on i386 68, on 32-bit Windows 72 */
G_STATIC_ASSERT (sizeof (GdkEventTouch) <= sizeof (GdkEventCrossing));
/* See gdkprivate.h for why this avoids g_memdup(). */
#if !GLIB_CHECK_VERSION (2, 68, 0)
gpointer
@ -412,6 +416,15 @@ gdk_event_new (GdkEventType type)
new_event->scroll.x_root = 0.;
new_event->scroll.y_root = 0.;
break;
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
new_event->touch.x = 0.;
new_event->touch.y = 0.;
new_event->touch.x_root = 0.;
new_event->touch.y_root = 0.;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
new_event->crossing.x = 0.;
@ -465,6 +478,11 @@ gdk_event_copy (const GdkEvent *event)
GdkEventPrivate *private = (GdkEventPrivate *)event;
new_private->screen = private->screen;
new_private->flags |= private->flags & (GDK_EVENT_POINTER_EMULATED |
GDK_EVENT_TOUCHPAD_EMULATED);
if (event->any.type == GDK_SCROLL &&
event->scroll.direction == GDK_SCROLL_SMOOTH)
new_private->delta = private->delta;
}
switch (event->any.type)
@ -500,6 +518,8 @@ gdk_event_copy (const GdkEvent *event)
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
new_event->button.axes = _gdk_memdup2 (event->button.axes,
@ -559,10 +579,13 @@ gdk_event_free (GdkEvent *event)
case GDK_DRAG_STATUS:
case GDK_DROP_START:
case GDK_DROP_FINISHED:
g_object_unref (event->dnd.context);
if (event->dnd.context != NULL)
g_object_unref (event->dnd.context);
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
g_free (event->button.axes);
break;
@ -615,6 +638,11 @@ gdk_event_get_time (const GdkEvent *event)
return event->button.time;
case GDK_SCROLL:
return event->scroll.time;
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
return event->touch.time;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
return event->key.time;
@ -694,6 +722,12 @@ gdk_event_get_state (const GdkEvent *event,
case GDK_SCROLL:
*state = event->scroll.state;
return TRUE;
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
*state = event->touch.state;
return TRUE;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*state = event->key.state;
@ -703,8 +737,6 @@ gdk_event_get_state (const GdkEvent *event,
*state = event->crossing.state;
return TRUE;
case GDK_PROPERTY_NOTIFY:
*state = event->property.state;
return TRUE;
case GDK_VISIBILITY_NOTIFY:
case GDK_CLIENT_EVENT:
case GDK_NO_EXPOSE:
@ -776,6 +808,13 @@ gdk_event_get_coords (const GdkEvent *event,
x = event->scroll.x;
y = event->scroll.y;
break;
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
x = event->touch.x;
y = event->touch.y;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
@ -830,6 +869,13 @@ gdk_event_get_root_coords (const GdkEvent *event,
x = event->scroll.x_root;
y = event->scroll.y_root;
break;
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
x = event->touch.x_root;
y = event->touch.y_root;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
@ -1034,6 +1080,354 @@ gdk_event_get_screen (const GdkEvent *event)
return NULL;
}
/**
* gdk_event_get_scroll_deltas:
* @event: a #GdkEvent
* @delta_x: (out): return location for the steps to the right
* @delta_y: (out): return location for the steps down
*
* Gets how far a %GDK_SCROLL_SMOOTH event scrolls, in steps of a
* mouse wheel: high resolution wheels and touchpads give fractions.
* On Quartz, trackpads give pixels, as in GTK+ 3.
* The same movement also arrives as ordinary scroll events, one per
* whole step, which gdk_event_get_pointer_emulated() tells apart.
*
* Return value: %TRUE if @event is a smooth scroll event
*
* Since: 2.24
**/
gboolean
gdk_event_get_scroll_deltas (const GdkEvent *event,
gdouble *delta_x,
gdouble *delta_y)
{
const GdkEventPrivate *private = (const GdkEventPrivate *) event;
if (!event || event->type != GDK_SCROLL ||
event->scroll.direction != GDK_SCROLL_SMOOTH ||
!gdk_event_is_allocated (event))
return FALSE;
if (delta_x)
*delta_x = private->delta.x;
if (delta_y)
*delta_y = private->delta.y;
return TRUE;
}
/**
* gdk_event_get_event_sequence:
* @event: a #GdkEvent
*
* If @event is a touch event, returns the #GdkEventSequence to which
* the event belongs, as in GTK+ 3.4. Otherwise, return %NULL.
*
* Returns: (transfer none): the event sequence that the event belongs to
*
* Since: 2.24
**/
GdkEventSequence *
gdk_event_get_event_sequence (const GdkEvent *event)
{
if (!event)
return NULL;
if (event->type == GDK_TOUCH_BEGIN ||
event->type == GDK_TOUCH_UPDATE ||
event->type == GDK_TOUCH_END ||
event->type == GDK_TOUCH_CANCEL)
return event->touch.sequence;
return NULL;
}
/**
* gdk_event_get_pointer_emulated:
* @event: a #GdkEvent
*
* Tells whether a scroll event of a whole wheel step repeats what a
* %GDK_SCROLL_SMOOTH event has already given; whoever handles the
* smooth events ignores these.
*
* Return value: %TRUE if the event is emulated
*
* Since: 2.24
**/
gboolean
gdk_event_get_pointer_emulated (GdkEvent *event)
{
return event && gdk_event_is_allocated (event) &&
(((GdkEventPrivate *) event)->flags & GDK_EVENT_POINTER_EMULATED) != 0;
}
/**
* gdk_event_get_touchpad_emulated:
* @event: a #GdkEvent
*
* Tells whether @event was made of a gesture on a touchpad, for
* programs that know nothing of those: a pinch arrives as scroll
* events up (larger) and down (smaller) with %GDK_CONTROL_MASK, which
* most programs that zoom take for zooming; a swipe sideways arrives
* as a press and release of button 8 (back, swiping to the right) or
* 9 (forward). GTK+'s own widgets do not scroll on such a pinch.
*
* Return value: %TRUE if the event was made of a touchpad gesture
*
* Since: 2.24
**/
gboolean
gdk_event_get_touchpad_emulated (GdkEvent *event)
{
return event && gdk_event_is_allocated (event) &&
(((GdkEventPrivate *) event)->flags & GDK_EVENT_TOUCHPAD_EMULATED) != 0;
}
/* Touchpad gestures, as Windows hands them to its old programs: a
* pinch is the wheel with Ctrl, one step for each 15 % the fingers
* spread or close (up for larger, as browsers and image programs zoom
* in then); a swipe sideways is the back or forward button. Nothing
* is made unless a gesture comes. */
#define TOUCHPAD_PINCH_STEP 0.14 /* ln 1.15 */
static GdkEvent *
touchpad_event (const GdkEvent *template_event,
GdkEventType type)
{
GdkEvent *event = gdk_event_new (type);
GdkEventPrivate *private = (GdkEventPrivate *) event;
if (type == GDK_SCROLL)
{
event->scroll = template_event->scroll;
event->scroll.type = GDK_SCROLL;
event->scroll.state |= GDK_CONTROL_MASK;
}
else
{
event->button.type = type;
event->button.send_event = template_event->scroll.send_event;
event->button.time = template_event->scroll.time;
event->button.x = template_event->scroll.x;
event->button.y = template_event->scroll.y;
event->button.x_root = template_event->scroll.x_root;
event->button.y_root = template_event->scroll.y_root;
event->button.state = template_event->scroll.state;
event->button.device = template_event->scroll.device;
event->button.axes = NULL;
}
event->any.window = template_event->any.window;
if (event->any.window)
g_object_ref (event->any.window);
if (gdk_event_is_allocated (template_event))
gdk_event_set_screen (event, ((GdkEventPrivate *) template_event)->screen);
private->flags |= GDK_EVENT_TOUCHPAD_EMULATED;
return event;
}
/* The scroll steps of a pinch whose scale changed by @log_scale (its
* logarithm) since the last call; @rest keeps what makes no whole step
* yet, 0 when a pinch begins. @template_event is a scroll event with
* window, time, place, state and device. */
GList *
_gdk_event_touchpad_pinch (const GdkEvent *template_event,
gdouble log_scale,
gdouble *rest)
{
GList *events = NULL;
gint n;
/* turning the other way starts afresh */
if (log_scale * *rest < 0)
*rest = 0;
*rest += log_scale;
n = (gint) CLAMP (*rest / TOUCHPAD_PINCH_STEP, -16, 16);
*rest -= n * TOUCHPAD_PINCH_STEP;
for (; n != 0; n += n > 0 ? -1 : 1)
{
GdkEvent *event = touchpad_event (template_event, GDK_SCROLL);
event->scroll.direction = n > 0 ? GDK_SCROLL_UP : GDK_SCROLL_DOWN;
events = g_list_prepend (events, event);
}
return g_list_reverse (events);
}
/* The press and release of the back button (8) for a swipe of @dx > 0
* (to the right) or the forward button (9) for @dx < 0 */
GList *
_gdk_event_touchpad_swipe (const GdkEvent *template_event,
gdouble dx)
{
GdkEvent *press, *release;
guint button = dx > 0 ? 8 : 9;
if (dx == 0)
return NULL;
press = touchpad_event (template_event, GDK_BUTTON_PRESS);
press->button.button = button;
release = touchpad_event (template_event, GDK_BUTTON_RELEASE);
release->button.button = button;
/* buttons past 5 have no bit in the state */
return g_list_append (g_list_append (NULL, press), release);
}
/* GDK makes smooth scroll events only for GTK+'s event handler, which
* knows who can take them; libgtk leaves it here when it sets it. A
* program with a handler of its own sees what it always saw. */
gboolean
_gdk_event_handler_takes_smooth (void)
{
static GQuark quark;
if (!quark)
quark = g_quark_from_static_string ("gdk-smooth-scroll-handler");
return _gdk_event_func != NULL &&
(gpointer) _gdk_event_func == g_object_get_qdata (G_OBJECT (gdk_display_manager_get ()), quark);
}
/* Whether any window has asked for GDK_SMOOTH_SCROLL_MASK: then smooth
* scroll events are made for other event handlers than that of GTK+
* as well, and gdk_window's event routing gives them only to those
* windows (see _gdk_event_scroll_for_window()) */
static gboolean smooth_scroll_wanted;
void
_gdk_event_note_event_mask (GdkEventMask mask)
{
if (mask & GDK_SMOOTH_SCROLL_MASK)
smooth_scroll_wanted = TRUE;
}
/* Whether smooth scroll events are to be made at all */
gboolean
_gdk_event_smooth_scroll_wanted (void)
{
return smooth_scroll_wanted || _gdk_event_handler_takes_smooth ();
}
/* Whether the scroll event @event goes to @window: a window with
* GDK_SMOOTH_SCROLL_MASK takes the smooth events and not the whole
* steps made of them, others the other way round. The event handler
* of GTK+ gets them all and sorts them out per widget (gtkmain.c),
* as GTK+'s own scrolled windows take smooth events too. */
gboolean
_gdk_event_scroll_for_window (GdkEvent *event,
GdkWindow *window)
{
gboolean smooth_window;
if (event->type != GDK_SCROLL || _gdk_event_handler_takes_smooth ())
return TRUE;
smooth_window = (gdk_window_get_events (window) & GDK_SMOOTH_SCROLL_MASK) != 0;
if (event->scroll.direction == GDK_SCROLL_SMOOTH)
return smooth_window;
return !(smooth_window && gdk_event_get_pointer_emulated (event));
}
void
_gdk_event_set_scroll_deltas (GdkEvent *event,
gdouble delta_x,
gdouble delta_y)
{
GdkEventPrivate *private = (GdkEventPrivate *) event;
event->scroll.direction = GDK_SCROLL_SMOOTH;
private->delta.x = delta_x;
private->delta.y = delta_y;
}
static GdkEvent *
scroll_event_from (GdkEvent **first,
const GdkEvent *template_event)
{
GdkEvent *event = *first ? *first : gdk_event_new (GDK_SCROLL);
*first = NULL;
event->scroll = template_event->scroll;
event->scroll.type = GDK_SCROLL;
return event;
}
/* For backends whose system tells how far to scroll: makes of
* @template_event (a scroll event but for the direction) a smooth
* event of @delta_x, @delta_y if asked and GTK+ takes those, and the
* whole steps of the wheel that @steps_x, @steps_y complete in @rest,
* marked as emulated when the smooth event goes out as well. The
* first event made goes into @first if there is one, the others to
* @append, which takes their references. Returns whether any event
* was made. */
gboolean
_gdk_event_emit_scroll (GdkEvent *first,
const GdkEvent *template_event,
gboolean smooth,
gdouble delta_x,
gdouble delta_y,
gdouble steps_x,
gdouble steps_y,
gdouble rest[2],
void (*append) (GdkEvent *event))
{
static const GdkScrollDirection direction[2][2] = {
{ GDK_SCROLL_LEFT, GDK_SCROLL_RIGHT },
{ GDK_SCROLL_UP, GDK_SCROLL_DOWN }
};
gdouble steps[2];
gboolean made = FALSE;
gint a, n;
steps[0] = steps_x;
steps[1] = steps_y;
if (smooth && (delta_x != 0 || delta_y != 0) && _gdk_event_smooth_scroll_wanted ())
{
gboolean into_first = first != NULL;
GdkEvent *event = scroll_event_from (&first, template_event);
_gdk_event_set_scroll_deltas (event, delta_x, delta_y);
if (!into_first)
append (event);
made = TRUE;
}
else
smooth = FALSE;
for (a = 0; a < 2; a++)
{
/* turning the other way starts afresh */
if (steps[a] * rest[a] < 0)
rest[a] = 0;
rest[a] += steps[a];
n = (gint) CLAMP (rest[a] + (rest[a] > 0 ? 1e-9 : -1e-9), -64, 64);
rest[a] -= n;
for (; n != 0; n += n > 0 ? -1 : 1)
{
gboolean into_first = first != NULL;
GdkEvent *event = scroll_event_from (&first, template_event);
event->scroll.direction = direction[a][n > 0];
if (smooth)
((GdkEventPrivate *) event)->flags |= GDK_EVENT_POINTER_EMULATED;
if (!into_first)
append (event);
made = TRUE;
}
}
return made;
}
/**
* gdk_set_show_events:
* @show_events: %TRUE to output event debugging information.

View file

@ -64,6 +64,8 @@ typedef struct _GdkEventDND GdkEventDND;
typedef struct _GdkEventWindowState GdkEventWindowState;
typedef struct _GdkEventSetting GdkEventSetting;
typedef struct _GdkEventGrabBroken GdkEventGrabBroken;
typedef struct _GdkEventTouch GdkEventTouch;
typedef struct _GdkEventSequence GdkEventSequence;
typedef union _GdkEvent GdkEvent;
@ -152,6 +154,11 @@ typedef enum
GDK_OWNER_CHANGE = 34,
GDK_GRAB_BROKEN = 35,
GDK_DAMAGE = 36,
/* as in GTK+ 3.4, for windows with GDK_TOUCH_MASK */
GDK_TOUCH_BEGIN = 37,
GDK_TOUCH_UPDATE = 38,
GDK_TOUCH_END = 39,
GDK_TOUCH_CANCEL = 40,
GDK_EVENT_LAST /* helper variable for decls */
} GdkEventType;
@ -181,9 +188,25 @@ typedef enum
GDK_PROXIMITY_OUT_MASK = 1 << 19,
GDK_SUBSTRUCTURE_MASK = 1 << 20,
GDK_SCROLL_MASK = 1 << 21,
/* as in GTK+ 3.4: the events of the fingers on a touch screen,
* GDK_TOUCH_BEGIN to GDK_TOUCH_CANCEL; GDK makes pointer events of
* the first finger for the windows that did not ask (see
* gdk_event_get_pointer_emulated()). Not in GDK_ALL_EVENTS_MASK: a
* program that does not ask keeps getting a touch as the pointer. */
GDK_TOUCH_MASK = 1 << 22,
/* as in GTK+ 3.4: %GDK_SCROLL_SMOOTH events with the distance (see
* gdk_event_get_scroll_deltas()), and none of the whole wheel steps
* made of them; not part of GDK_ALL_EVENTS_MASK, which old programs
* use and which keeps the steps for them */
GDK_SMOOTH_SCROLL_MASK = 1 << 23,
GDK_ALL_EVENTS_MASK = 0x3FFFFE
} GdkEventMask;
/* so that programs can ask with #ifdef whether GDK has it (GTK+ 2 from
* gtk2-ng; GTK+ 3 has it from 3.4 on) */
#define GDK_SMOOTH_SCROLL_MASK GDK_SMOOTH_SCROLL_MASK
#define GDK_TOUCH_MASK GDK_TOUCH_MASK
typedef enum
{
GDK_VISIBILITY_UNOBSCURED,
@ -196,7 +219,8 @@ typedef enum
GDK_SCROLL_UP,
GDK_SCROLL_DOWN,
GDK_SCROLL_LEFT,
GDK_SCROLL_RIGHT
GDK_SCROLL_RIGHT,
GDK_SCROLL_SMOOTH
} GdkScrollDirection;
/* Types of enter/leave notifications.
@ -488,6 +512,47 @@ struct _GdkEventDND {
gshort x_root, y_root;
};
/**
* GdkEventTouch:
* @type: the type of the event (%GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
* %GDK_TOUCH_END, %GDK_TOUCH_CANCEL)
* @window: the window which received the event
* @send_event: %TRUE if the event was sent explicitly
* @time: the time of the event in milliseconds
* @x: the x coordinate of the touch relative to the window
* @y: the y coordinate of the touch relative to the window
* @axes: %NULL
* @state: the modifier keys
* @emulating_pointer: whether the event is the one of the finger that
* also moves the pointer (the first one)
* @sequence: what tells the touches of the fingers apart; the same
* for all events of one finger, from begin to end
* @device: the device where the event originated
* @x_root: the x coordinate of the touch relative to the root of the screen
* @y_root: the y coordinate of the touch relative to the root of the screen
*
* A touch on a touch screen, as in GTK+ 3.4, with the same fields;
* @emulating_pointer comes before @sequence here, so that the event
* fits in the GdkEvent of GTK+ 2.
*
* Since: 2.24
*/
struct _GdkEventTouch
{
GdkEventType type;
GdkWindow *window;
gint8 send_event;
guint32 time;
gdouble x;
gdouble y;
gdouble *axes;
guint state;
gboolean emulating_pointer;
GdkEventSequence *sequence;
GdkDevice *device;
gdouble x_root, y_root;
};
union _GdkEvent
{
GdkEventType type;
@ -511,9 +576,10 @@ union _GdkEvent
GdkEventWindowState window_state;
GdkEventSetting setting;
GdkEventGrabBroken grab_broken;
GdkEventTouch touch;
};
GType gdk_event_get_type (void) G_GNUC_CONST;
GType gdk_event_get_type (void);
gboolean gdk_events_pending (void);
GdkEvent* gdk_event_get (void);
@ -549,6 +615,13 @@ void gdk_event_set_screen (GdkEvent *event,
GdkScreen *screen);
GdkScreen *gdk_event_get_screen (const GdkEvent *event);
gboolean gdk_event_get_scroll_deltas (const GdkEvent *event,
gdouble *delta_x,
gdouble *delta_y);
gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
gboolean gdk_event_get_touchpad_emulated (GdkEvent *event);
GdkEventSequence *gdk_event_get_event_sequence (const GdkEvent *event);
void gdk_set_show_events (gboolean show_events);
gboolean gdk_get_show_events (void);

View file

@ -53,7 +53,7 @@ struct _GdkFont
gint descent;
};
GType gdk_font_get_type (void) G_GNUC_CONST;
GType gdk_font_get_type (void);
GdkFont* gdk_font_ref (GdkFont *font);
void gdk_font_unref (GdkFont *font);

View file

@ -61,6 +61,9 @@ struct _GdkGCPrivate
guint subwindow_mode : 1;
guint fill : 2;
guint exposures : 2;
/* the clip of a window stays on after a drawing, see
* _gdk_gc_set_draw_origins() */
guint drawable_clip_kept : 1;
};
#define GDK_GC_GET_PRIVATE(o) ((GdkGCPrivate *) gdk_gc_get_instance_private (GDK_GC (o)))
@ -758,11 +761,66 @@ _gdk_gc_add_drawable_clip (GdkGC *gc,
priv->region_tag_offset_y = offset_y;
}
/* For drawing to a window inside the paint of a parent: moves the clip
* and tile origins of @gc there for the drawing, and back after it
* (@drawing_done), without taking off the clip of the window that
* _gdk_gc_add_drawable_clip() puts on, as setting the clip origin does.
* That clip is relative to the clip origin of the caller, which these
* moves keep, so the next drawing to the window finds it still in
* place, instead of making it anew and sending it to the X server.
*
* Where a GC is used for drawing directly by the caller, with
* gdk_x11_gc_get_xgc(), the clip of the window is taken off first, as
* it was before. Other backends set the clip of a GC for each drawing
* themselves, from the same region the raw drawing functions use, so
* the clip of the window is taken off after a drawing there. */
void
_gdk_gc_set_draw_origins (GdkGC *gc,
gint clip_x,
gint clip_y,
gint ts_x,
gint ts_y,
gboolean drawing_done)
{
GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
GdkGCValues values;
#ifndef GDK_WINDOWING_X11
if (drawing_done)
{
gdk_gc_set_clip_origin (gc, clip_x, clip_y);
gdk_gc_set_ts_origin (gc, ts_x, ts_y);
return;
}
#endif
priv->drawable_clip_kept = drawing_done && priv->region_tag_applied != 0;
gc->clip_x_origin = values.clip_x_origin = clip_x;
gc->clip_y_origin = values.clip_y_origin = clip_y;
gc->ts_x_origin = values.ts_x_origin = ts_x;
gc->ts_y_origin = values.ts_y_origin = ts_y;
GDK_GC_GET_CLASS (gc)->set_values (gc, &values,
GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN |
GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
}
/* Takes off a clip of a window that _gdk_gc_set_draw_origins() left on */
void
_gdk_gc_remove_kept_drawable_clip (GdkGC *gc)
{
if (GDK_GC_GET_PRIVATE (gc)->drawable_clip_kept)
_gdk_gc_remove_drawable_clip (gc);
}
void
_gdk_gc_remove_drawable_clip (GdkGC *gc)
{
GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
priv->drawable_clip_kept = FALSE;
if (priv->region_tag_applied)
{
priv->region_tag_applied = 0;
@ -1194,6 +1252,7 @@ gdk_gc_copy (GdkGC *dst_gc,
dst_priv->clip_region = NULL;
dst_priv->region_tag_applied = src_priv->region_tag_applied;
dst_priv->drawable_clip_kept = src_priv->drawable_clip_kept;
if (dst_priv->old_clip_region)
gdk_region_destroy (dst_priv->old_clip_region);
@ -1453,6 +1512,8 @@ gc_get_background (GdkGC *gc,
* last call to this function
* @target_drawable: The drawable you're drawing in. If passed in
* this is used for client side window clip emulation.
* @cr_is_new: %TRUE if @cr comes straight from gdk_cairo_create()
* on @target_drawable, which has set the window clip already
*
* Set the attributes of a cairo context to match those of a #GdkGC
* as far as possible. Some aspects of a #GdkGC, such as clip masks
@ -1464,7 +1525,8 @@ _gdk_gc_update_context (GdkGC *gc,
const GdkColor *override_foreground,
GdkBitmap *override_stipple,
gboolean gc_changed,
GdkDrawable *target_drawable)
GdkDrawable *target_drawable,
gboolean cr_is_new)
{
GdkGCPrivate *priv;
GdkFill fill;
@ -1570,10 +1632,15 @@ _gdk_gc_update_context (GdkGC *gc,
if (!gc_changed)
return;
cairo_reset_clip (cr);
/* The reset above resets the window clip rect, so we want to re-set that */
if (target_drawable && GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip)
GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip (target_drawable, cr);
/* a new context has the window clip and no other: building the
* window clip again from its region is work for nothing */
if (!cr_is_new)
{
cairo_reset_clip (cr);
/* The reset above resets the window clip rect, so we want to re-set that */
if (target_drawable && GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip)
GDK_DRAWABLE_GET_CLASS (target_drawable)->set_cairo_clip (target_drawable, cr);
}
if (priv->clip_region)
{

View file

@ -221,7 +221,7 @@ struct _GdkGCClass
#ifndef GDK_DISABLE_DEPRECATED
GType gdk_gc_get_type (void) G_GNUC_CONST;
GType gdk_gc_get_type (void);
GdkGC *gdk_gc_new (GdkDrawable *drawable);
GdkGC *gdk_gc_new_with_values (GdkDrawable *drawable,
GdkGCValues *values,

View file

@ -655,5 +655,66 @@ gdk_image_new (GdkImageType type,
visual, width, height, -1);
}
/**
* _gdk_image_read_row:
* @image: a #GdkImage
* @x: the first pixel
* @y: the row
* @width: how many pixels
* @pixels: where to put the pixel values
*
* Reads pixel values of any number of bits per pixel and either byte
* order; for less than 8 bits, the byte order is the order of the
* pixels in a byte, too.
*/
void
_gdk_image_read_row (GdkImage *image,
gint x,
gint y,
gint width,
guint32 *pixels)
{
const guchar *in = (const guchar *) image->mem + y * image->bpl;
const gboolean msb = image->byte_order == GDK_MSB_FIRST;
const gint bits = image->bits_per_pixel;
gint i;
if (bits < 8)
{
const guint mask = (1 << bits) - 1;
for (i = 0; i < width; i++)
{
const gint bit = (x + i) * bits;
pixels[i] = (in[bit >> 3] >> (msb ? 8 - bits - (bit & 7) : bit & 7)) & mask;
}
return;
}
in += x * (bits / 8);
switch (bits)
{
case 8:
for (i = 0; i < width; i++)
pixels[i] = in[i];
break;
case 16:
for (i = 0; i < width; i++, in += 2)
pixels[i] = msb ? (in[0] << 8) | in[1] : in[0] | (in[1] << 8);
break;
case 24:
for (i = 0; i < width; i++, in += 3)
pixels[i] = msb ? (in[0] << 16) | (in[1] << 8) | in[2]
: in[0] | (in[1] << 8) | (in[2] << 16);
break;
case 32:
for (i = 0; i < width; i++, in += 4)
pixels[i] = msb ? ((guint32) in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3]
: in[0] | (in[1] << 8) | (in[2] << 16) | ((guint32) in[3] << 24);
break;
}
}
#define __GDK_IMAGE_C__
#include "gdkaliasdef.c"

View file

@ -90,7 +90,7 @@ struct _GdkImageClass
GObjectClass parent_class;
};
GType gdk_image_get_type (void) G_GNUC_CONST;
GType gdk_image_get_type (void);
#ifndef GDK_DISABLE_DEPRECATED
GdkImage* gdk_image_new (GdkImageType type,

View file

@ -123,7 +123,7 @@ struct _GdkTimeCoord
gdouble axes[GDK_MAX_TIMECOORD_AXES];
};
GType gdk_device_get_type (void) G_GNUC_CONST;
GType gdk_device_get_type (void);
#ifndef GDK_MULTIHEAD_SAFE
/* Returns a list of GdkDevice * */

View file

@ -33,9 +33,6 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkwindow.h>
#include <gdk/gdkprivate.h>
#ifdef USE_MEDIALIB
#include <gdk/gdkmedialib.h>
#endif
G_BEGIN_DECLS
@ -166,7 +163,19 @@ typedef enum
/* Following flag is set for events on the event queue during
* translation and cleared afterwards.
*/
GDK_EVENT_PENDING = 1 << 0
GDK_EVENT_PENDING = 1 << 0,
/* A scroll event from a wheel step that a smooth scroll event with
* the same time has already given */
GDK_EVENT_POINTER_EMULATED = 1 << 1,
/* A touch for which the window system sends the pointer events of
* the first finger itself (Windows), so GDK need not make them */
GDK_EVENT_TOUCH_SYSTEM_POINTER = 1 << 2,
/* A scroll or button event made of a touchpad gesture for programs
* that know nothing of those (gdk_event_get_touchpad_emulated()) */
GDK_EVENT_TOUCHPAD_EMULATED = 1 << 3
} GdkEventFlags;
struct _GdkEventPrivate
@ -174,7 +183,16 @@ struct _GdkEventPrivate
GdkEvent event;
guint flags;
GdkScreen *screen;
gpointer windowing_data;
#ifdef GDK_WINDOWING_QUARTZ
gpointer windowing_data; /* the NSEvent */
#endif
/* the steps of a GDK_SCROLL_SMOOTH event, where elsewhere a
* windowing_data pointer nobody used was */
struct
{
gfloat x;
gfloat y;
} delta;
};
/* Tracks information about the pointer grab on this display */
@ -291,6 +309,30 @@ extern GdkEventFunc _gdk_event_func; /* Callback for events */
extern gpointer _gdk_event_data;
extern GDestroyNotify _gdk_event_notify;
gboolean _gdk_event_handler_takes_smooth (void);
gboolean _gdk_event_smooth_scroll_wanted (void);
GList *_gdk_event_touchpad_pinch (const GdkEvent *template_event,
gdouble log_scale,
gdouble *rest);
GList *_gdk_event_touchpad_swipe (const GdkEvent *template_event,
gdouble dx);
void _gdk_event_note_event_mask (GdkEventMask mask);
gboolean _gdk_event_scroll_for_window (GdkEvent *event,
GdkWindow *window);
void _gdk_event_set_scroll_deltas (GdkEvent *event,
gdouble delta_x,
gdouble delta_y);
gboolean _gdk_event_emit_scroll (GdkEvent *first,
const GdkEvent *template_event,
gboolean smooth,
gdouble delta_x,
gdouble delta_y,
gdouble steps_x,
gdouble steps_y,
gdouble rest[2],
void (*append) (GdkEvent *event));
extern GSList *_gdk_displays;
extern gchar *_gdk_display_name;
extern gint _gdk_screen_number;
@ -335,6 +377,11 @@ GdkImage* _gdk_image_new_for_depth (GdkScreen *screen,
gint width,
gint height,
gint depth);
void _gdk_image_read_row (GdkImage *image,
gint x,
gint y,
gint width,
guint32 *pixels);
GdkImage *_gdk_image_get_scratch (GdkScreen *screen,
gint width,
gint height,
@ -361,14 +408,36 @@ cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
/* GC caching */
GdkGC *_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
gboolean graphics_exposures);
GdkGC *_gdk_drawable_get_subwindow_scratch_gc (GdkDrawable *drawable);
/* GdkRGB */
gboolean _gdk_rgb_composite (GdkColormap *colormap,
GdkImage *image,
gint x0,
gint y0,
gint width,
gint height,
const guchar *rgba,
gint rowstride,
GdkRgbDither dither);
gboolean _gdk_rgb_prefers_own_blending (GdkColormap *colormap,
GdkRgbDither dither);
gint _gdk_window_get_cairo_clip_n_rects (GdkWindow *window);
void _gdk_window_set_cairo_clip_in_area (GdkWindow *window,
cairo_t *cr,
const GdkRectangle *area);
cairo_t *_gdk_cairo_create_in_area (GdkDrawable *drawable,
const GdkRectangle *area);
void _gdk_gc_update_context (GdkGC *gc,
cairo_t *cr,
const GdkColor *override_foreground,
GdkBitmap *override_stipple,
gboolean gc_changed,
GdkDrawable *target_drawable);
GdkDrawable *target_drawable,
gboolean cr_is_new);
/*************************************
* Interfaces used by windowing code *
@ -429,6 +498,13 @@ void _gdk_gc_add_drawable_clip (GdkGC *gc,
int offset_x,
int offset_y);
void _gdk_gc_remove_drawable_clip (GdkGC *gc);
void _gdk_gc_set_draw_origins (GdkGC *gc,
gint clip_x,
gint clip_y,
gint ts_x,
gint ts_y,
gboolean drawing_done);
void _gdk_gc_remove_kept_drawable_clip (GdkGC *gc);
void _gdk_gc_set_clip_region_internal (GdkGC *gc,
GdkRegion *region,
gboolean reset_origin);
@ -538,11 +614,11 @@ struct _GdkPaintableIface
void (* end_paint) (GdkPaintable *paintable);
};
GType _gdk_paintable_get_type (void) G_GNUC_CONST;
GType _gdk_paintable_get_type (void);
/* Implementation types */
GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
GType _gdk_window_impl_get_type (void);
GType _gdk_pixmap_impl_get_type (void);
/**
@ -630,6 +706,24 @@ void _gdk_display_enable_motion_hints (GdkDisplay *display);
void _gdk_window_invalidate_for_expose (GdkWindow *window,
GdkRegion *region);
void _gdk_window_reapply_shapes (GdkWindow *window);
/* HiDPI: how many pixels of the window system make one of GDK in each
* direction, for a drawable (window, pixmap or their implementation) and
* for a monitor (-1: the screen's default); 1 where the backend does not
* scale */
gint _gdk_windowing_drawable_get_scale (GdkDrawable *drawable);
GdkPixbuf *_gdk_pixbuf_get_hires (GdkPixbuf *pixbuf,
gint scale);
gint _gdk_windowing_screen_get_monitor_scale (GdkScreen *screen,
gint monitor_num);
void _gdk_cairo_surface_set_device_offset (cairo_surface_t *surface,
gdouble x,
gdouble y);
/* HiDPI: for surfaces whose window system scales by itself, without a
* device scale of cairo (Quartz): its pixels per pixel of GDK */
void _gdk_cairo_surface_set_hidpi_scale (cairo_surface_t *surface,
gint scale);
void _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
int width,

View file

@ -78,7 +78,7 @@ struct _GdkKeymapClass
void (*state_changed) (GdkKeymap *keymap);
};
GType gdk_keymap_get_type (void) G_GNUC_CONST;
GType gdk_keymap_get_type (void);
#ifndef GDK_MULTIHEAD_SAFE
GdkKeymap* gdk_keymap_get_default (void);

View file

@ -1,120 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2001-2007 Sun Microsystems, Inc. All rights reserved.
* (Brian Cameron, Dmitriy Demin, James Cheng, Padraig O'Briain)
*
* 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 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2007. 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"
#include <stdlib.h>
#include <dlfcn.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#if defined(HAVE_SYS_SYSTEMINFO_H)
#include <sys/systeminfo.h>
#elif defined(HAVE_SYS_SYSINFO_H)
#include <sys/sysinfo.h>
#endif
#include "gdkmedialib.h"
typedef char * (*ml_version) (void);
static ml_version medialib_version = mlib_version;
gboolean
_gdk_use_medialib (void)
{
char *mlib_version_string;
char sys_info[257];
long count;
/*
* Sun mediaLib(tm) support.
*
* http://www.sun.com/processors/vis/mlib.html
*
*/
if (getenv ("GDK_DISABLE_MEDIALIB"))
return FALSE;
/*
* The imaging functions we want to use were added in mediaLib version 2.
* So turn off mediaLib support if the user has an older version.
* mlib_version returns a string in this format:
*
* mediaLib:0210:20011101:v8plusa
* ^^^^^^^^ ^^^^ ^^^^^^^^ ^^^^^^^
* libname vers build ISALIST identifier
* date (in this case sparcv8plus+vis)
*
* The first 2 digits of the version are the major version. The 3rd digit
* is the minor version, and the 4th digit is the micro version. So the
* above string corresponds to version 2.1.0.In the following test we only
* care about the major version.
*/
mlib_version_string = medialib_version ();
count = sysinfo (SI_ARCHITECTURE, &sys_info[0], 257);
if (count != -1)
{
if (strcmp (sys_info, "i386") == 0)
{
char *mlib_target_isa = &mlib_version_string[23];
/*
* For x86 processors mediaLib generic C implementation
* does not give any performance advantage so disable it.
*/
if (strncmp (mlib_target_isa, "sse", 3) != 0)
{
return FALSE;
}
/*
* For x86 processors use of libumem conflicts with
* mediaLib, so avoid using it.
*/
if (dlsym (RTLD_PROBE, "umem_alloc") != NULL)
{
return FALSE;
}
}
}
else
{
/* Failed to get system architecture, disable mediaLib */
return FALSE;
}
return TRUE;
}

View file

@ -59,6 +59,12 @@ struct _GdkPangoRendererPrivate
GdkGC *base_gc;
gboolean gc_changed;
/* what gdk_draw_layout[_line]_with_colors() draws, where, for the
* clip (see get_cairo_context()) */
PangoLayout *area_layout;
PangoLayoutLine *area_line;
gint area_x, area_y;
};
static PangoAttrType gdk_pango_attr_stipple_type;
@ -155,18 +161,62 @@ color_equal (const PangoColor *c1, const PangoColor *c2)
return FALSE;
}
/* Where gdk_draw_layout[_line]_with_colors() draws: the ink and the
* logical extents, with room around for the emboss and for pixels of
* glyphs that antialiasing puts a little outside their ink. Only asked
* for when the clip of the window has more than a few rectangles. */
#define DRAW_AREA_MARGIN 4
static gboolean
get_draw_area (GdkPangoRendererPrivate *priv,
GdkRectangle *area)
{
PangoRectangle ink, logical;
if (priv->area_layout)
pango_layout_get_pixel_extents (priv->area_layout, &ink, &logical);
else if (priv->area_line)
pango_layout_line_get_pixel_extents (priv->area_line, &ink, &logical);
else
return FALSE;
if (ink.width <= 0 || ink.height <= 0)
ink = logical;
area->x = MIN (ink.x, logical.x);
area->y = MIN (ink.y, logical.y);
area->width = MAX (ink.x + ink.width, logical.x + logical.width) - area->x;
area->height = MAX (ink.y + ink.height, logical.y + logical.height) - area->y;
area->x += priv->area_x - DRAW_AREA_MARGIN;
area->y += priv->area_y - DRAW_AREA_MARGIN;
area->width += 2 * DRAW_AREA_MARGIN;
area->height += 2 * DRAW_AREA_MARGIN;
return TRUE;
}
static cairo_t *
get_cairo_context (GdkPangoRenderer *gdk_renderer,
PangoRenderPart part)
{
PangoRenderer *renderer = PANGO_RENDERER (gdk_renderer);
GdkPangoRendererPrivate *priv = gdk_renderer->priv;
gboolean cr_is_new = FALSE;
if (!priv->cr)
{
const PangoMatrix *matrix;
GdkRectangle area;
priv->cr = gdk_cairo_create (priv->drawable);
if ((priv->area_layout || priv->area_line) &&
GDK_IS_WINDOW (priv->drawable) &&
_gdk_window_get_cairo_clip_n_rects ((GdkWindow *) priv->drawable) > 2 &&
get_draw_area (priv, &area))
priv->cr = _gdk_cairo_create_in_area (priv->drawable, &area);
else
priv->cr = gdk_cairo_create (priv->drawable);
cr_is_new = TRUE;
matrix = pango_renderer_get_matrix (renderer);
if (matrix)
@ -216,7 +266,8 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
color,
priv->stipple[part],
priv->gc_changed,
priv->drawable);
priv->drawable,
cr_is_new);
}
priv->last_part = part;
@ -839,6 +890,9 @@ release_renderer (PangoRenderer *renderer)
gdk_pango_renderer_set_drawable (gdk_renderer, NULL);
gdk_pango_renderer_set_gc (gdk_renderer, NULL);
gdk_renderer->priv->area_layout = NULL;
gdk_renderer->priv->area_line = NULL;
}
/**
@ -911,7 +965,16 @@ gdk_draw_layout_line_with_colors (GdkDrawable *drawable,
y = 0;
}
else
pango_renderer_set_matrix (renderer, NULL);
{
GdkPangoRendererPrivate *priv = GDK_PANGO_RENDERER (renderer)->priv;
pango_renderer_set_matrix (renderer, NULL);
/* without a matrix, the extents of the line say where it goes */
priv->area_line = line;
priv->area_x = x;
priv->area_y = y;
}
pango_renderer_draw_layout_line (renderer, line, x * PANGO_SCALE, y * PANGO_SCALE);
@ -991,7 +1054,16 @@ gdk_draw_layout_with_colors (GdkDrawable *drawable,
y = 0;
}
else
pango_renderer_set_matrix (renderer, NULL);
{
GdkPangoRendererPrivate *priv = GDK_PANGO_RENDERER (renderer)->priv;
pango_renderer_set_matrix (renderer, NULL);
/* without a matrix, the extents of the layout say where it goes */
priv->area_layout = layout;
priv->area_x = x;
priv->area_y = y;
}
pango_renderer_draw_layout (renderer, layout, x * PANGO_SCALE, y * PANGO_SCALE);

View file

@ -86,7 +86,7 @@ struct _GdkPangoRendererClass
PangoRendererClass parent_class;
};
GType gdk_pango_renderer_get_type (void) G_GNUC_CONST;
GType gdk_pango_renderer_get_type (void);
PangoRenderer *gdk_pango_renderer_new (GdkScreen *screen);
PangoRenderer *gdk_pango_renderer_get_default (GdkScreen *screen);

File diff suppressed because it is too large Load diff

View file

@ -740,6 +740,12 @@ gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,
if (colormap == NULL)
colormap = gdk_drawable_get_colormap (drawable);
/* no mask either if the image cannot be read (gdk-pixbuf may come
* without its XPM loader): callers use it without looking at the
* pixmap first */
if (mask)
*mask = NULL;
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
if (!pixbuf)
return NULL;
@ -823,6 +829,12 @@ gdk_pixmap_colormap_create_from_xpm_d (GdkDrawable *drawable,
if (colormap == NULL)
colormap = gdk_drawable_get_colormap (drawable);
/* no mask either if the image cannot be read (gdk-pixbuf may come
* without its XPM loader): callers use it without looking at the
* pixmap first */
if (mask)
*mask = NULL;
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)data);
if (!pixbuf)
return NULL;

View file

@ -62,7 +62,7 @@ struct _GdkPixmapObjectClass
};
GType gdk_pixmap_get_type (void) G_GNUC_CONST;
GType gdk_pixmap_get_type (void);
/* Pixmaps
*/

View file

@ -42,7 +42,7 @@ typedef enum
GDK_PROP_MODE_APPEND
} GdkPropMode;
GType gdk_atom_get_type (void) G_GNUC_CONST;
GType gdk_atom_get_type (void);
GdkAtom gdk_atom_intern (const gchar *atom_name,
gboolean only_if_exists);
GdkAtom gdk_atom_intern_static_string (const gchar *atom_name);

View file

@ -611,6 +611,36 @@ gdk_region_intersect (GdkRegion *source1,
if ((!(source1->numRects)) || (!(source2->numRects)) ||
(!EXTENTCHECK(&source1->extents, &source2->extents)))
source1->numRects = 0;
/* Mostly one of the two is a rectangle: an expose area, a window,
* a clip rectangle. Then a rectangle around the other is the other,
* and two rectangles meet in one. */
else if (source2->numRects == 1 &&
source2->extents.x1 <= source1->extents.x1 &&
source2->extents.y1 <= source1->extents.y1 &&
source2->extents.x2 >= source1->extents.x2 &&
source2->extents.y2 >= source1->extents.y2)
return;
else if (source1->numRects == 1 &&
source1->extents.x1 <= source2->extents.x1 &&
source1->extents.y1 <= source2->extents.y1 &&
source1->extents.x2 >= source2->extents.x2 &&
source1->extents.y2 >= source2->extents.y2)
{
miRegionCopy (source1, source2);
return;
}
else if (source1->numRects == 1 && source2->numRects == 1)
{
GdkRegionBox box;
box.x1 = MAX (source1->extents.x1, source2->extents.x1);
box.y1 = MAX (source1->extents.y1, source2->extents.y1);
box.x2 = MIN (source1->extents.x2, source2->extents.x2);
box.y2 = MIN (source1->extents.y2, source2->extents.y2);
source1->rects[0] = box;
source1->extents = box;
return;
}
else
miRegionOp (source1, source1, source2,
miIntersectO, (nonOverlapFunc) NULL, (nonOverlapFunc) NULL);

426
gdk/gdkrgb-altivec.c Normal file
View file

@ -0,0 +1,426 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for AltiVec (PowerPC G4 and G5)
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include "gdkrgbsimd.h"
#if defined(__ALTIVEC__) && defined(__BIG_ENDIAN__)
#include <altivec.h>
/* An x888 pixel is the bytes 0xff, R, G, B; a 565 pixel is a big
* endian 16-bit word. Vector loads and stores need 16-byte aligned
* addresses: loads are put together from two, and each loop starts
* with single pixels until the output is aligned. */
typedef vector unsigned char vu8;
typedef vector unsigned short vu16;
typedef vector unsigned int vu32;
#define VU8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
((vu8) { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p })
/* Reads 16 bytes after 16 bytes from any address, one aligned load
* each; never reads a block that holds none of the bytes asked for.
* Set up only when at least 16 bytes will be read. */
typedef struct
{
const guchar *p;
vu8 perm, last;
gboolean aligned;
} Reader;
static inline void
reader_init (Reader *r, const guchar *p)
{
r->p = p;
r->aligned = ((gsize) p & 15) == 0;
r->perm = vec_lvsl (0, p);
r->last = vec_ld (0, p);
}
static inline vu8
reader_next (Reader *r)
{
vu8 v;
if (r->aligned)
v = vec_ld (0, r->p);
else
{
/* the block of the 16th byte follows the block of the first */
vu8 next = vec_ld (15, r->p);
v = vec_perm (r->last, next, r->perm);
r->last = next;
}
r->p += 16;
return v;
}
static inline gboolean
aligned (const void *p)
{
return ((gsize) p & 15) == 0;
}
static inline guint32
x888 (const guchar *p)
{
return 0xff000000 | (p[0] << 16) | (p[1] << 8) | p[2];
}
static inline guint16
rgb565 (const guchar *p)
{
return ((p[0] & 0xf8) << 8) | ((p[1] & 0xfc) << 3) | (p[2] >> 3);
}
/* with the unused bit set, as all of GdkRGB does */
static inline guint16
rgb555 (const guchar *p)
{
return 0x8000 | ((p[0] & 0xf8) << 7) | ((p[1] & 0xf8) << 2) | (p[2] >> 3);
}
static inline guint
blend8 (guint a, guint s, guint d)
{
guint t = a * s + (255 - a) * d + 0x80;
return (t + (t >> 8)) >> 8;
}
static inline void
composite1_x888 (guint32 *pixel, const guchar *s)
{
guint32 d = *pixel;
if (s[3] != 0)
*pixel = 0xff000000 |
(blend8 (s[3], s[0], (d >> 16) & 0xff) << 16) |
(blend8 (s[3], s[1], (d >> 8) & 0xff) << 8) |
blend8 (s[3], s[2], d & 0xff);
}
static inline void
composite1_565 (guint16 *pixel, const guchar *s)
{
guint d = *pixel, r = d >> 11, g = (d >> 5) & 0x3f, b = d & 0x1f;
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
g = blend8 (s[3], s[1], (g << 2) | (g >> 4));
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
*pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
}
static inline void
composite1_555 (guint16 *pixel, const guchar *s)
{
guint d = *pixel, r = (d >> 10) & 0x1f, g = (d >> 5) & 0x1f, b = d & 0x1f;
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
g = blend8 (s[3], s[1], (g << 3) | (g >> 2));
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
*pixel = 0x8000 | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
}
/* 0xff in the first byte of each pixel */
static inline vu8
fill_x888 (void)
{
/* -8 shifts by 24 */
return (vu8) vec_sl (vec_splat_u32 (-1), vec_splat_u32 (-8));
}
static gint
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
{
const vu8 fill = fill_x888 ();
const vu8 p0 = VU8 (0, 0, 1, 2, 0, 3, 4, 5, 0, 6, 7, 8, 0, 9, 10, 11);
const vu8 p1 = VU8 (0, 12, 13, 14, 0, 15, 16, 17, 0, 18, 19, 20, 0, 21, 22, 23);
const vu8 p2 = VU8 (0, 8, 9, 10, 0, 11, 12, 13, 0, 14, 15, 16, 0, 17, 18, 19);
const vu8 p3 = VU8 (0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15);
Reader r;
gint i;
for (i = 0; i < n && !aligned (out + i); i++, rgb += 3)
out[i] = x888 (rgb);
if (i + 16 <= n)
reader_init (&r, rgb);
for (; i + 16 <= n; i += 16)
{
vu8 a = reader_next (&r), b = reader_next (&r), c = reader_next (&r);
vec_st (vec_or (vec_perm (a, a, p0), fill), 0, (guchar *) (out + i));
vec_st (vec_or (vec_perm (a, b, p1), fill), 16, (guchar *) (out + i));
vec_st (vec_or (vec_perm (b, c, p2), fill), 32, (guchar *) (out + i));
vec_st (vec_or (vec_perm (c, c, p3), fill), 48, (guchar *) (out + i));
}
return i;
}
static gint
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
{
const vu8 fill = fill_x888 ();
const vu8 p = VU8 (0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 9, 10, 0, 12, 13, 14);
Reader r;
gint i;
for (i = 0; i < n && !aligned (out + i); i++, rgbx += 4)
out[i] = x888 (rgbx);
if (i + 4 <= n)
reader_init (&r, rgbx);
for (; i + 4 <= n; i += 4)
{
vu8 a = reader_next (&r);
vec_st (vec_or (vec_perm (a, a, p), fill), 0, (guchar *) (out + i));
}
return i;
}
/* Bytes of eight RGB pixels as 16-bit lanes, for one channel */
static inline vu16
channel (vu8 a, vu8 b, vu8 p)
{
return vec_and ((vu16) vec_perm (a, b, p), vec_splats ((unsigned short) 0xff));
}
static inline vu16
pack565 (vu16 r, vu16 g, vu16 b)
{
return vec_or (vec_or (vec_sl (vec_and (r, vec_splats ((unsigned short) 0xf8)), vec_splats ((unsigned short) 8)),
vec_sl (vec_and (g, vec_splats ((unsigned short) 0xfc)), vec_splats ((unsigned short) 3))),
vec_sr (b, vec_splats ((unsigned short) 3)));
}
static inline vu16
pack555 (vu16 r, vu16 g, vu16 b)
{
return vec_or (vec_or (vec_sl (vec_and (r, vec_splats ((unsigned short) 0xf8)), vec_splats ((unsigned short) 7)),
vec_sl (vec_and (g, vec_splats ((unsigned short) 0xf8)), vec_splats ((unsigned short) 2))),
vec_or (vec_sr (b, vec_splats ((unsigned short) 3)), vec_splats ((unsigned short) 0x8000)));
}
static inline vu16
pack16 (vu16 r, vu16 g, vu16 b, const gint green_bits)
{
return green_bits == 6 ? pack565 (r, g, b) : pack555 (r, g, b);
}
static inline gint
rgb_to_16 (guint16 *out, const guchar *rgb, gint n, const gint green_bits)
{
/* the channel byte of pixel k in both bytes of lane k */
const vu8 r0 = VU8 (0, 0, 3, 3, 6, 6, 9, 9, 12, 12, 15, 15, 18, 18, 21, 21);
const vu8 g0 = VU8 (1, 1, 4, 4, 7, 7, 10, 10, 13, 13, 16, 16, 19, 19, 22, 22);
const vu8 b0 = VU8 (2, 2, 5, 5, 8, 8, 11, 11, 14, 14, 17, 17, 20, 20, 23, 23);
const vu8 r1 = VU8 (8, 8, 11, 11, 14, 14, 17, 17, 20, 20, 23, 23, 26, 26, 29, 29);
const vu8 g1 = VU8 (9, 9, 12, 12, 15, 15, 18, 18, 21, 21, 24, 24, 27, 27, 30, 30);
const vu8 b1 = VU8 (10, 10, 13, 13, 16, 16, 19, 19, 22, 22, 25, 25, 28, 28, 31, 31);
Reader r;
gint i;
for (i = 0; i < n && !aligned (out + i); i++, rgb += 3)
out[i] = green_bits == 6 ? rgb565 (rgb) : rgb555 (rgb);
if (i + 16 <= n)
reader_init (&r, rgb);
for (; i + 16 <= n; i += 16)
{
vu8 a = reader_next (&r), b = reader_next (&r), c = reader_next (&r);
vec_st (pack16 (channel (a, b, r0), channel (a, b, g0), channel (a, b, b0), green_bits), 0, out + i);
vec_st (pack16 (channel (b, c, r1), channel (b, c, g1), channel (b, c, b1), green_bits), 0, out + i + 8);
}
return i;
}
static gint
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
{
return rgb_to_16 (out, rgb, n, 6);
}
static gint
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
{
return rgb_to_16 (out, rgb, n, 5);
}
/* (a * s + (255 - a) * d) / 255, rounded, in 16-bit lanes */
static inline vu16
blend (vu16 t)
{
t = vec_add (t, vec_splats ((unsigned short) 0x80));
return vec_sr (vec_add (t, vec_sr (t, vec_splats ((unsigned short) 8))),
vec_splats ((unsigned short) 8));
}
static gint
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
{
const vu8 fill = fill_x888 ();
const vu8 argb = VU8 (3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14);
const vu8 alpha = VU8 (3, 3, 3, 3, 7, 7, 7, 7, 11, 11, 11, 11, 15, 15, 15, 15);
const vu8 merge = VU8 (1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31);
Reader r;
gint i;
for (i = 0; i < n && !aligned (pixels + i); i++, rgba += 4)
composite1_x888 (pixels + i, rgba);
if (i + 4 <= n)
reader_init (&r, rgba);
for (; i + 4 <= n; i += 4)
{
vu8 s = reader_next (&r);
vu8 d = vec_ld (0, (guchar *) (pixels + i));
vu8 a = vec_perm (s, s, alpha);
vu8 inv = vec_nor (a, a);
vu16 even, odd;
vu8 v;
s = vec_perm (s, s, argb);
even = blend (vec_add (vec_mule (s, a), vec_mule (d, inv)));
odd = blend (vec_add (vec_mulo (s, a), vec_mulo (d, inv)));
v = vec_or (vec_perm ((vu8) even, (vu8) odd, merge), fill);
/* fully transparent pixels stay as they are */
vec_st (vec_sel (v, d, vec_cmpeq (a, vec_splat_u8 (0))), 0, (guchar *) (pixels + i));
}
return i;
}
static inline gint
composite_16 (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits)
{
const vu8 pr = VU8 (0, 0, 4, 4, 8, 8, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28);
const vu8 pg = VU8 (1, 1, 5, 5, 9, 9, 13, 13, 17, 17, 21, 21, 25, 25, 29, 29);
const vu8 pb = VU8 (2, 2, 6, 6, 10, 10, 14, 14, 18, 18, 22, 22, 26, 26, 30, 30);
const vu8 pa = VU8 (3, 3, 7, 7, 11, 11, 15, 15, 19, 19, 23, 23, 27, 27, 31, 31);
const vu16 c255 = vec_splats ((unsigned short) 255);
Reader r;
gint i;
for (i = 0; i < n && !aligned (pixels + i); i++, rgba += 4)
if (rgba[3] != 0)
{
if (green_bits == 6)
composite1_565 (pixels + i, rgba);
else
composite1_555 (pixels + i, rgba);
}
if (i + 8 <= n)
reader_init (&r, rgba);
for (; i + 8 <= n; i += 8)
{
vu8 s0 = reader_next (&r), s1 = reader_next (&r);
vu16 d = vec_ld (0, pixels + i);
vu16 a = channel (s0, s1, pa), inv = vec_sub (c255, a);
vu16 dr = vec_and (vec_sr (d, vec_splats ((unsigned short) (5 + green_bits))), vec_splats ((unsigned short) 0x1f));
vu16 dg = vec_and (vec_sr (d, vec_splats ((unsigned short) 5)), vec_splats ((unsigned short) ((1 << green_bits) - 1)));
vu16 db = vec_and (d, vec_splats ((unsigned short) 0x1f));
vu16 v;
/* the bits of the pixel repeated up to 8 */
dr = vec_or (vec_sl (dr, vec_splats ((unsigned short) 3)), vec_sr (dr, vec_splats ((unsigned short) 2)));
if (green_bits == 6)
dg = vec_or (vec_sl (dg, vec_splats ((unsigned short) 2)), vec_sr (dg, vec_splats ((unsigned short) 4)));
else
dg = vec_or (vec_sl (dg, vec_splats ((unsigned short) 3)), vec_sr (dg, vec_splats ((unsigned short) 2)));
db = vec_or (vec_sl (db, vec_splats ((unsigned short) 3)), vec_sr (db, vec_splats ((unsigned short) 2)));
v = pack16 (blend (vec_mladd (channel (s0, s1, pr), a, vec_mladd (dr, inv, vec_splats ((unsigned short) 0)))),
blend (vec_mladd (channel (s0, s1, pg), a, vec_mladd (dg, inv, vec_splats ((unsigned short) 0)))),
blend (vec_mladd (channel (s0, s1, pb), a, vec_mladd (db, inv, vec_splats ((unsigned short) 0)))),
green_bits);
/* where nothing is drawn the unused bit of 555 stays as it was */
if (green_bits == 5)
v = vec_sel (v, d, vec_cmpeq (a, vec_splats ((unsigned short) 0)));
vec_st (v, 0, pixels + i);
}
return i;
}
static gint
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
{
const vu8 argb = VU8 (3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14);
/* a for R, G and B; 255 for the alpha, which a * 255 / 255 keeps */
const vu8 factors = VU8 (16, 3, 3, 3, 16, 7, 7, 7, 16, 11, 11, 11, 16, 15, 15, 15);
const vu8 merge = VU8 (1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31);
const vu8 ones = vec_splat_u8 (-1);
Reader r;
gint i;
for (i = 0; i < n && !aligned (out + i); i++, rgba += 4)
{
guint a = rgba[3];
out[i] = (a << 24) | (blend8 (a, rgba[0], 0) << 16) |
(blend8 (a, rgba[1], 0) << 8) | blend8 (a, rgba[2], 0);
}
if (i + 4 <= n)
reader_init (&r, rgba);
for (; i + 4 <= n; i += 4)
{
vu8 s = reader_next (&r);
vu8 m = vec_perm (s, ones, factors);
s = vec_perm (s, s, argb);
vec_st (vec_perm ((vu8) blend (vec_mule (s, m)), (vu8) blend (vec_mulo (s, m)), merge),
0, (guchar *) (out + i));
}
return i;
}
static gint
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
{
return composite_16 (pixels, rgba, n, 6);
}
static gint
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
{
return composite_16 (pixels, rgba, n, 5);
}
void
_gdk_rgb_simd_init_altivec (GdkRgbSimd *simd)
{
simd->name = "altivec";
simd->rgb_to_x888 = rgb_to_x888;
simd->rgbx_to_x888 = rgbx_to_x888;
simd->rgb_to_565 = rgb_to_565;
simd->rgb_to_555 = rgb_to_555;
simd->composite_x888 = composite_x888;
simd->composite_565 = composite_565;
simd->composite_555 = composite_555;
simd->rgba_to_argb = rgba_to_argb;
}
#endif

311
gdk/gdkrgb-armv6.c Normal file
View file

@ -0,0 +1,311 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for the media instructions of ARMv6 (the ARM11 of the
* Raspberry Pi 1 and Zero), which has no NEON: two channels of a pixel
* 16 bits apart in one register, multiplied at once, with UXTB16 and
* UXTAB16 taking bytes apart and adding them in both halves; REV puts
* the bytes of a pixel in the other order. A pixel goes in and out as
* one word, not byte by byte.
*
* GDK_RGB_ARMV6_C builds the same loops with C for the instructions,
* to check them on other machines.
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include "gdkrgbsimd.h"
/* ARMv6 or later in ARM or Thumb-2 code, little endian */
#if defined(__arm__) && !defined(__ARMEB__) && \
(!defined(__thumb__) || defined(__thumb2__)) && \
(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) || \
(defined(__ARM_ARCH) && __ARM_ARCH >= 6))
#define ARMV6_ASM 1
#endif
#if defined(ARMV6_ASM) || defined(GDK_RGB_ARMV6_C)
#ifdef ARMV6_ASM
/* bytes 0 and 2 in the two halves */
static inline guint32
uxtb16 (guint32 x)
{
guint32 r;
__asm__ ("uxtb16 %0, %1" : "=r" (r) : "r" (x));
return r;
}
/* bytes 1 and 3 */
static inline guint32
uxtb16_ror8 (guint32 x)
{
guint32 r;
__asm__ ("uxtb16 %0, %1, ror #8" : "=r" (r) : "r" (x));
return r;
}
/* @acc plus bytes 1 and 3 of @x, in each half */
static inline guint32
uxtab16_ror8 (guint32 acc, guint32 x)
{
guint32 r;
__asm__ ("uxtab16 %0, %1, %2, ror #8" : "=r" (r) : "r" (acc), "r" (x));
return r;
}
static inline guint32
rev (guint32 x)
{
guint32 r;
__asm__ ("rev %0, %1" : "=r" (r) : "r" (x));
return r;
}
#else
static inline guint32 uxtb16 (guint32 x) { return x & 0x00ff00ff; }
static inline guint32 uxtb16_ror8 (guint32 x) { return (x >> 8 | x << 24) & 0x00ff00ff; }
static inline guint32
uxtab16_ror8 (guint32 acc, guint32 x)
{
guint32 b = uxtb16_ror8 (x);
return ((acc + b) & 0xffff) | ((acc & 0xffff0000) + (b & 0xffff0000));
}
static inline guint32
rev (guint32 x)
{
return x >> 24 | (x >> 8 & 0xff00) | (x << 8 & 0xff0000) | x << 24;
}
#endif
/* A word of pixels, at an address of a whole word: rows of pixbufs
* start there, and the loops take words from the start. Rows that do
* not are left to the C code, as ARMv6 compilers read words byte by
* byte where they are not sure. */
typedef guint32 __attribute__ ((may_alias)) word;
#define ALIGNED(p) (((gsize) (p) & 3) == 0)
static inline guint32
load32 (const guchar *p)
{
return *(const word *) p;
}
/* t / 255 rounded, in both halves, for t = c * a + 0x80 (no carries
* between the halves: t stays below 65536) */
static inline guint32
div255 (guint32 t)
{
return uxtb16_ror8 (uxtab16_ror8 (t, t));
}
/* Of each three RGB pixels: R G B R | G B R G | B R G B in three words */
static gint
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
{
gint i;
if (!ALIGNED (rgb))
return 0;
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
{
guint32 w0 = load32 (rgb), w1 = load32 (rgb + 4), w2 = load32 (rgb + 8);
/* B G R x, reversed and moved down, is R << 16 | G << 8 | B */
out[i] = (rev (w0) >> 8) | 0xff000000;
out[i + 1] = (rev ((w0 >> 24) | (w1 << 8)) >> 8) | 0xff000000;
out[i + 2] = (rev ((w1 >> 16) | (w2 << 16)) >> 8) | 0xff000000;
out[i + 3] = (rev (w2) & 0xffffff) | 0xff000000;
}
return i;
}
/* Lanes R | G << 8 | B << 16 to 565 or 555 */
static inline guint32
rgb16_of (guint32 v, const gint green_bits)
{
if (green_bits == 6)
return ((v & 0xf8) << 8) | ((v >> 5) & 0x7e0) | ((v >> 19) & 0x1f);
else
return ((v & 0xf8) << 7) | ((v >> 6) & 0x3e0) | ((v >> 19) & 0x1f) | 0x8000;
}
static inline gint
rgb_to_16 (guint16 *out, const guchar *rgb, gint n, const gint green_bits)
{
guint32 *out32 = (guint32 *) out;
gint i;
/* two pixels to a word of the output; the words of both at their
* places, or the C code does the row */
if (!ALIGNED (rgb) || !ALIGNED (out))
return 0;
for (i = 0; i + 4 <= n; i += 4, rgb += 12, out32 += 2)
{
guint32 w0 = load32 (rgb), w1 = load32 (rgb + 4), w2 = load32 (rgb + 8);
out32[0] = rgb16_of (w0, green_bits) |
(rgb16_of ((w0 >> 24) | (w1 << 8), green_bits) << 16);
out32[1] = rgb16_of ((w1 >> 16) | (w2 << 16), green_bits) |
(rgb16_of (w2 >> 8, green_bits) << 16);
}
return i;
}
static gint
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
{
return rgb_to_16 (out, rgb, n, 6);
}
static gint
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
{
return rgb_to_16 (out, rgb, n, 5);
}
/* c * a / 255 to the nearest for the channels of the RGBA word @w:
* red and blue together, green and alpha together */
static gint
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
{
gint i;
if (!ALIGNED (rgba))
return 0;
for (i = 0; i < n; i++, rgba += 4)
{
guint32 w = load32 (rgba);
guint32 a = w >> 24;
guint32 rb = div255 (uxtb16 (w) * a + 0x00800080); /* R | B << 16 */
guint32 g = div255 (uxtb16_ror8 (w) * a + 0x80) & 0xff;
/* B | R << 16, which a rotation is */
out[i] = (a << 24) | (g << 8) | (rb >> 16) | (rb << 16);
}
return i;
}
/* a * s + (255 - a) * d, rounded, for two channels at once */
static inline guint32
blend2 (guint32 s, guint32 d, guint32 a)
{
return div255 (s * a + d * (255 - a) + 0x00800080);
}
static gint
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
{
gint i;
if (!ALIGNED (rgba))
return 0;
for (i = 0; i < n; i++, rgba += 4)
{
guint32 w = load32 (rgba);
guint32 a = w >> 24;
guint32 d, rb, g;
if (a == 0)
continue;
if (a == 255)
{
pixels[i] = (rev (w) >> 8) | 0xff000000;
continue;
}
/* the pixel is B | G << 8 | R << 16: blue and red as in @w swapped */
d = pixels[i];
rb = blend2 (uxtb16 (w), ((d >> 16) & 0xff) | ((d & 0xff) << 16), a);
g = blend2 ((w >> 8) & 0xff, (d >> 8) & 0xff, a) & 0xff;
pixels[i] = 0xff000000 | ((rb & 0xff) << 16) | (g << 8) | (rb >> 16);
}
return i;
}
/* The bits of a channel repeated up to 8, as GdkRGB unpacks them */
#define WIDEN5(c) (((c) << 3) | ((c) >> 2))
#define WIDEN6(c) (((c) << 2) | ((c) >> 4))
static inline gint
composite_16 (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits)
{
const gint red_shift = 5 + green_bits;
gint i;
if (!ALIGNED (rgba))
return 0;
for (i = 0; i < n; i++, rgba += 4)
{
guint32 w = load32 (rgba);
guint32 a = w >> 24;
guint32 d, dr, dg, db, rb, g, v;
if (a == 0)
continue;
d = pixels[i];
dr = (d >> red_shift) & 0x1f;
dg = (d >> 5) & ((1 << green_bits) - 1);
db = d & 0x1f;
dr = WIDEN5 (dr);
dg = green_bits == 6 ? WIDEN6 (dg) : WIDEN5 (dg);
db = WIDEN5 (db);
rb = blend2 (uxtb16 (w), dr | (db << 16), a); /* R | B << 16 */
g = blend2 ((w >> 8) & 0xff, dg, a) & 0xff;
v = (((rb & 0xff) >> 3) << red_shift) | ((g >> (8 - green_bits)) << 5) | (rb >> 19);
if (green_bits == 5)
v |= 0x8000;
pixels[i] = v;
}
return i;
}
static gint
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
{
return composite_16 (pixels, rgba, n, 6);
}
static gint
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
{
return composite_16 (pixels, rgba, n, 5);
}
void
_gdk_rgb_simd_init_armv6 (GdkRgbSimd *simd)
{
simd->name = "armv6";
simd->rgb_to_x888 = rgb_to_x888;
simd->rgb_to_565 = rgb_to_565;
simd->rgb_to_555 = rgb_to_555;
simd->composite_x888 = composite_x888;
simd->composite_565 = composite_565;
simd->composite_555 = composite_555;
simd->rgba_to_argb = rgba_to_argb;
}
#endif

129
gdk/gdkrgb-avx2.c Normal file
View file

@ -0,0 +1,129 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for AVX2 (Haswell, Zen and later): the SSSE3 loops eight
* pixels at a time, for the pixels of four bytes, where the lanes of 128
* bits do not mix. Pixels of three bytes would cross the two halves of
* a register and need permutes; those stay with SSSE3.
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include "gdkrgbsimd.h"
#if defined(__AVX2__)
#include <immintrin.h>
/* x86 is little endian: an x888 pixel is the bytes B, G, R, 0xff */
#define SPLAT(v) _mm256_set1_epi32 ((gint) (v))
/* the same order of bytes in both halves */
#define BYTES(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
_mm256_setr_epi8 (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, \
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static gint
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
{
const __m256i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
gint i;
for (i = 0; i + 8 <= n; i += 8, rgbx += 32)
_mm256_storeu_si256 ((__m256i *) (out + i),
_mm256_or_si256 (_mm256_shuffle_epi8 (_mm256_loadu_si256 ((const __m256i *) rgbx), order),
SPLAT (0xff000000)));
return i;
}
/* The alpha of each pixel in its four 16-bit lanes */
static inline __m256i
alpha_of (__m256i v)
{
return _mm256_shuffle_epi8 (v, BYTES (6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15));
}
/* (a * s + (255 - a) * d) / 255, rounded as GdkRGB's C code does */
static inline __m256i
blend (__m256i s, __m256i d, __m256i a)
{
__m256i t = _mm256_add_epi16 (_mm256_add_epi16 (_mm256_mullo_epi16 (s, a),
_mm256_mullo_epi16 (d, _mm256_sub_epi16 (_mm256_set1_epi16 (255), a))),
_mm256_set1_epi16 (0x80));
return _mm256_mulhi_epu16 (t, _mm256_set1_epi16 (257));
}
static gint
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
{
const __m256i zero = _mm256_setzero_si256 ();
const __m256i order = BYTES (2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
__m256i s = _mm256_loadu_si256 ((const __m256i *) rgba);
__m256i d = _mm256_loadu_si256 ((const __m256i *) (pixels + i));
__m256i transparent = _mm256_cmpeq_epi32 (_mm256_srli_epi32 (s, 24), zero);
__m256i lo, hi, v;
/* RGBA to BGRA, the order of the pixels */
s = _mm256_shuffle_epi8 (s, order);
lo = _mm256_unpacklo_epi8 (s, zero);
hi = _mm256_unpackhi_epi8 (s, zero);
lo = blend (lo, _mm256_unpacklo_epi8 (d, zero), alpha_of (lo));
hi = blend (hi, _mm256_unpackhi_epi8 (d, zero), alpha_of (hi));
v = _mm256_or_si256 (_mm256_packus_epi16 (lo, hi), SPLAT (0xff000000));
/* fully transparent pixels stay as they are */
v = _mm256_blendv_epi8 (v, d, transparent);
_mm256_storeu_si256 ((__m256i *) (pixels + i), v);
}
return i;
}
/* c * a / 255 to the nearest, which (c * a + 0x80) * 257 >> 16 is */
static gint
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
{
const __m256i zero = _mm256_setzero_si256 ();
const __m256i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
__m256i s = _mm256_loadu_si256 ((const __m256i *) rgba);
__m256i lo = _mm256_unpacklo_epi8 (s, zero);
__m256i hi = _mm256_unpackhi_epi8 (s, zero);
lo = _mm256_mulhi_epu16 (_mm256_add_epi16 (_mm256_mullo_epi16 (lo, alpha_of (lo)), _mm256_set1_epi16 (0x80)),
_mm256_set1_epi16 (257));
hi = _mm256_mulhi_epu16 (_mm256_add_epi16 (_mm256_mullo_epi16 (hi, alpha_of (hi)), _mm256_set1_epi16 (0x80)),
_mm256_set1_epi16 (257));
/* R, G, B to B, G, R, and the alpha byte as it was */
_mm256_storeu_si256 ((__m256i *) (out + i),
_mm256_or_si256 (_mm256_shuffle_epi8 (_mm256_packus_epi16 (lo, hi), order),
_mm256_and_si256 (s, SPLAT (0xff000000))));
}
return i;
}
void
_gdk_rgb_simd_init_avx2 (GdkRgbSimd *simd)
{
simd->name = "avx2";
simd->rgbx_to_x888 = rgbx_to_x888;
simd->composite_x888 = composite_x888;
simd->rgba_to_argb = rgba_to_argb;
}
#endif

473
gdk/gdkrgb-mmx.c Normal file
View file

@ -0,0 +1,473 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for MMX, and for what came later on the same registers:
* the integer SSE instructions of the Pentium III and Athlon (pshufw,
* pmulhuw), and 3DNow! of the K6-2, Athlon and Geode LX (pmulhrw)
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include <string.h>
#include "gdkrgbsimd.h"
/* x86-64 always has SSE2, which does all of this better */
#if defined(__MMX__) && !defined(__x86_64__)
#include <mmintrin.h>
/* The file is compiled for plain MMX. The later instructions are
* written as assembler, so the compiler uses them nowhere else, and
* the kernels with them are only called on CPUs that have them. */
#if defined(__GNUC__)
#define KERNEL static inline __attribute__ ((always_inline))
#else
#define KERNEL static inline
#endif
/* How a kernel does what MMX has no instruction for */
enum
{
PLAIN, /* MMX only */
EXT, /* pshufw and pmulhuw */
AMD3D, /* pmulhrw */
AMD3D_EXT /* all three */
};
#define SPLAT(v) _mm_set1_pi32 ((gint) (v))
static inline __m64
load8 (const void *p)
{
__m64 v;
memcpy (&v, p, 8);
return v;
}
static inline void
store8 (void *p, __m64 v)
{
memcpy (p, &v, 8);
}
static inline __m64
load4 (const void *p)
{
gint32 v;
memcpy (&v, p, 4);
return _mm_cvtsi32_si64 (v);
}
#if defined(__i386__) && defined(__GNUC__)
#define HAVE_LATER_MMX 1
#define PSHUFW(v, imm) G_STMT_START { \
__asm__ ("pshufw $" #imm ", %0, %0" : "+y" (v)); \
} G_STMT_END
static inline __m64
pmulhuw (__m64 a, __m64 b)
{
__asm__ ("pmulhuw %1, %0" : "+y" (a) : "y" (b));
return a;
}
static inline __m64
pmulhrw (__m64 a, __m64 b)
{
__asm__ ("pmulhrw %1, %0" : "+y" (a) : "y" (b));
return a;
}
#else
/* never used: only plain kernels are made here */
#define PSHUFW(v, imm) G_STMT_START { } G_STMT_END
#define pmulhuw(a, b) ((void) (b), (a))
#define pmulhrw(a, b) ((void) (b), (a))
#endif
/* The 6 bytes of two RGB pixels as lanes R | G << 8 | B << 16 */
static inline __m64
rgb_lanes (__m64 v)
{
return _mm_unpacklo_pi32 (v, _mm_srli_si64 (v, 24));
}
static inline __m64
x888_of (__m64 v)
{
return _mm_or_si64 (_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (v, SPLAT (0xff)), 16),
_mm_and_si64 (v, SPLAT (0xff00))),
_mm_or_si64 (_mm_and_si64 (_mm_srli_pi32 (v, 16), SPLAT (0xff)),
SPLAT (0xff000000)));
}
/* Lanes R | G << 8 | B << 16 to 565 or 555, sign extended for packing.
* The bit 555 has no use for is set, as in all of GdkRGB's pixels. */
static inline __m64
rgb565_of (__m64 v)
{
v = _mm_or_si64 (_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (v, SPLAT (0xf8)), 8),
_mm_srli_pi32 (_mm_and_si64 (v, SPLAT (0xfc00)), 5)),
_mm_and_si64 (_mm_srli_pi32 (v, 19), SPLAT (0x1f)));
return _mm_srai_pi32 (_mm_slli_pi32 (v, 16), 16);
}
static inline __m64
rgb555_of (__m64 v)
{
v = _mm_or_si64 (_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (v, SPLAT (0xf8)), 7),
_mm_srli_pi32 (_mm_and_si64 (v, SPLAT (0xf800)), 6)),
_mm_or_si64 (_mm_and_si64 (_mm_srli_pi32 (v, 19), SPLAT (0x1f)),
SPLAT (0x8000)));
return _mm_srai_pi32 (_mm_slli_pi32 (v, 16), 16);
}
static gint
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
{
__m64 a = load8 (rgb);
__m64 b = _mm_or_si64 (_mm_srli_si64 (a, 48), _mm_slli_si64 (load4 (rgb + 8), 16));
store8 (out + i, x888_of (rgb_lanes (a)));
store8 (out + i + 2, x888_of (rgb_lanes (b)));
}
_mm_empty ();
return i;
}
static gint
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
{
gint i;
for (i = 0; i + 2 <= n; i += 2, rgbx += 8)
store8 (out + i, x888_of (load8 (rgbx)));
_mm_empty ();
return i;
}
static gint
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
{
__m64 a = load8 (rgb);
__m64 b = _mm_or_si64 (_mm_srli_si64 (a, 48), _mm_slli_si64 (load4 (rgb + 8), 16));
store8 (out + i, _mm_packs_pi32 (rgb565_of (rgb_lanes (a)), rgb565_of (rgb_lanes (b))));
}
_mm_empty ();
return i;
}
static gint
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 4 <= n; i += 4, rgb += 12)
{
__m64 a = load8 (rgb);
__m64 b = _mm_or_si64 (_mm_srli_si64 (a, 48), _mm_slli_si64 (load4 (rgb + 8), 16));
store8 (out + i, _mm_packs_pi32 (rgb555_of (rgb_lanes (a)), rgb555_of (rgb_lanes (b))));
}
_mm_empty ();
return i;
}
/* (a * s + (255 - a) * d) / 255, rounded as GdkRGB's C code does, in
* 16-bit lanes. 3DNow! does it as d + (s - d) * a / 255: pmulhrw
* rounds the signed difference times a * 257, a correction makes up
* for a * 257 not fitting a signed lane from a = 128 on. That is the
* same in all 16777216 cases. */
KERNEL __m64
blend (__m64 s, __m64 d, __m64 a, const gint how)
{
if (how == AMD3D || how == AMD3D_EXT)
{
__m64 scaled = _mm_slli_pi16 (a, 8);
__m64 mask = _mm_srai_pi16 (scaled, 15);
__m64 coeff = _mm_sub_pi16 (_mm_add_pi16 (a, scaled), mask);
__m64 delta = _mm_sub_pi16 (s, d);
return _mm_add_pi16 (_mm_add_pi16 (pmulhrw (delta, coeff), _mm_and_si64 (delta, mask)), d);
}
else
{
__m64 t = _mm_add_pi16 (_mm_add_pi16 (_mm_mullo_pi16 (s, a),
_mm_mullo_pi16 (d, _mm_sub_pi16 (_mm_set1_pi16 (255), a))),
_mm_set1_pi16 (0x80));
/* t * 257 >> 16 is (t + (t >> 8)) >> 8 */
if (how == EXT)
return pmulhuw (t, _mm_set1_pi16 (257));
return _mm_srli_pi16 (_mm_add_pi16 (t, _mm_srli_pi16 (t, 8)), 8);
}
}
/* c * a / 255, rounded the same way */
KERNEL __m64
premultiply (__m64 c, __m64 a, const gint how)
{
if (how == AMD3D || how == AMD3D_EXT)
return blend (c, _mm_setzero_si64 (), a, how);
else
{
__m64 t = _mm_add_pi16 (_mm_mullo_pi16 (c, a), _mm_set1_pi16 (0x80));
if (how == EXT)
return pmulhuw (t, _mm_set1_pi16 (257));
return _mm_srli_pi16 (_mm_add_pi16 (t, _mm_srli_pi16 (t, 8)), 8);
}
}
/* The alpha of a pixel in 16-bit lanes in all four lanes */
KERNEL __m64
alpha_of (__m64 v, const gint how)
{
if (how == EXT || how == AMD3D_EXT)
{
PSHUFW (v, 0xff);
return v;
}
v = _mm_srli_si64 (v, 48);
v = _mm_unpacklo_pi16 (v, v);
return _mm_unpacklo_pi32 (v, v);
}
/* Two RGBA pixels as 16-bit lanes B, G, R, A each: the order of the
* bytes of 0xAARRGGBB */
KERNEL void
unpack_bgra (__m64 s, __m64 *lo, __m64 *hi, const gint how)
{
const __m64 zero = _mm_setzero_si64 ();
if (how == EXT || how == AMD3D_EXT)
{
__m64 l = _mm_unpacklo_pi8 (s, zero);
__m64 h = _mm_unpackhi_pi8 (s, zero);
PSHUFW (l, 0xc6);
PSHUFW (h, 0xc6);
*lo = l;
*hi = h;
}
else
{
s = _mm_or_si64 (_mm_and_si64 (s, SPLAT (0xff00ff00)),
_mm_or_si64 (_mm_slli_pi32 (_mm_and_si64 (s, SPLAT (0xff)), 16),
_mm_and_si64 (_mm_srli_pi32 (s, 16), SPLAT (0xff))));
*lo = _mm_unpacklo_pi8 (s, zero);
*hi = _mm_unpackhi_pi8 (s, zero);
}
}
KERNEL gint
composite_x888_k (guint32 *pixels, const guchar *rgba, gint n, const gint how)
{
const __m64 zero = _mm_setzero_si64 ();
gint i;
for (i = 0; i + 2 <= n; i += 2, rgba += 8)
{
__m64 s = load8 (rgba);
__m64 d = load8 (pixels + i);
__m64 transparent = _mm_cmpeq_pi32 (_mm_srli_pi32 (s, 24), zero);
__m64 lo, hi, v;
unpack_bgra (s, &lo, &hi, how);
lo = blend (lo, _mm_unpacklo_pi8 (d, zero), alpha_of (lo, how), how);
hi = blend (hi, _mm_unpackhi_pi8 (d, zero), alpha_of (hi, how), how);
v = _mm_or_si64 (_mm_packs_pu16 (lo, hi), SPLAT (0xff000000));
/* fully transparent pixels stay as they are */
store8 (pixels + i, _mm_or_si64 (_mm_and_si64 (transparent, d),
_mm_andnot_si64 (transparent, v)));
}
_mm_empty ();
return i;
}
/* Four 565 or 555 pixels at a time, each channel in a register */
KERNEL gint
composite_16_k (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits, const gint how)
{
const gint red_shift = 5 + green_bits;
const __m64 zero = _mm_setzero_si64 ();
gint i;
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
{
__m64 s0 = load8 (rgba);
__m64 s1 = load8 (rgba + 8);
__m64 d = load8 (pixels + i);
__m64 r = _mm_packs_pi32 (_mm_and_si64 (s0, SPLAT (0xff)), _mm_and_si64 (s1, SPLAT (0xff)));
__m64 g = _mm_packs_pi32 (_mm_and_si64 (_mm_srli_pi32 (s0, 8), SPLAT (0xff)),
_mm_and_si64 (_mm_srli_pi32 (s1, 8), SPLAT (0xff)));
__m64 b = _mm_packs_pi32 (_mm_and_si64 (_mm_srli_pi32 (s0, 16), SPLAT (0xff)),
_mm_and_si64 (_mm_srli_pi32 (s1, 16), SPLAT (0xff)));
__m64 a = _mm_packs_pi32 (_mm_srli_pi32 (s0, 24), _mm_srli_pi32 (s1, 24));
__m64 dr = _mm_and_si64 (_mm_srli_pi16 (d, red_shift), _mm_set1_pi16 (0x1f));
__m64 dg = _mm_and_si64 (_mm_srli_pi16 (d, 5), _mm_set1_pi16 ((1 << green_bits) - 1));
__m64 db = _mm_and_si64 (d, _mm_set1_pi16 (0x1f));
__m64 v;
/* the bits of the pixel repeated up to 8 */
dr = _mm_or_si64 (_mm_slli_pi16 (dr, 3), _mm_srli_pi16 (dr, 2));
if (green_bits == 6)
dg = _mm_or_si64 (_mm_slli_pi16 (dg, 2), _mm_srli_pi16 (dg, 4));
else
dg = _mm_or_si64 (_mm_slli_pi16 (dg, 3), _mm_srli_pi16 (dg, 2));
db = _mm_or_si64 (_mm_slli_pi16 (db, 3), _mm_srli_pi16 (db, 2));
r = blend (r, dr, a, how);
g = blend (g, dg, a, how);
b = blend (b, db, a, how);
v = _mm_or_si64 (_mm_or_si64 (_mm_slli_pi16 (_mm_srli_pi16 (r, 3), red_shift),
_mm_slli_pi16 (_mm_srli_pi16 (g, 8 - green_bits), 5)),
_mm_srli_pi16 (b, 3));
if (green_bits == 5)
{
/* the unused bit is set, except where nothing is drawn */
__m64 transparent = _mm_cmpeq_pi16 (a, zero);
v = _mm_or_si64 (_mm_and_si64 (transparent, d),
_mm_andnot_si64 (transparent, _mm_or_si64 (v, _mm_set1_pi16 ((gshort) 0x8000))));
}
store8 (pixels + i, v);
}
_mm_empty ();
return i;
}
KERNEL gint
rgba_to_argb_k (guint32 *out, const guchar *rgba, gint n, const gint how)
{
gint i;
for (i = 0; i + 2 <= n; i += 2, rgba += 8)
{
__m64 s = load8 (rgba);
__m64 lo, hi;
unpack_bgra (s, &lo, &hi, how);
lo = premultiply (lo, alpha_of (lo, how), how);
hi = premultiply (hi, alpha_of (hi, how), how);
/* the alpha byte as it was */
store8 (out + i, _mm_or_si64 (_mm_and_si64 (_mm_packs_pu16 (lo, hi), SPLAT (0x00ffffff)),
_mm_and_si64 (s, SPLAT (0xff000000))));
}
_mm_empty ();
return i;
}
#define DEFINE_KERNELS(suffix, how) \
static gint \
composite_x888_##suffix (guint32 *pixels, const guchar *rgba, gint n) \
{ \
return composite_x888_k (pixels, rgba, n, how); \
} \
\
static gint \
composite_565_##suffix (guint16 *pixels, const guchar *rgba, gint n) \
{ \
return composite_16_k (pixels, rgba, n, 6, how); \
} \
\
static gint \
composite_555_##suffix (guint16 *pixels, const guchar *rgba, gint n) \
{ \
return composite_16_k (pixels, rgba, n, 5, how); \
} \
\
static gint \
rgba_to_argb_##suffix (guint32 *out, const guchar *rgba, gint n) \
{ \
return rgba_to_argb_k (out, rgba, n, how); \
} \
\
static void \
init_##suffix (GdkRgbSimd *simd, const gchar *name) \
{ \
simd->name = name; \
simd->rgb_to_x888 = rgb_to_x888; \
simd->rgbx_to_x888 = rgbx_to_x888; \
simd->rgb_to_565 = rgb_to_565; \
simd->rgb_to_555 = rgb_to_555; \
simd->composite_x888 = composite_x888_##suffix; \
simd->composite_565 = composite_565_##suffix; \
simd->composite_555 = composite_555_##suffix; \
simd->rgba_to_argb = rgba_to_argb_##suffix; \
}
DEFINE_KERNELS (mmx, PLAIN)
void
_gdk_rgb_simd_init_mmx (GdkRgbSimd *simd)
{
init_mmx (simd, "mmx");
}
#if defined(HAVE_LATER_MMX)
DEFINE_KERNELS (ext, EXT)
DEFINE_KERNELS (3dnow, AMD3D)
DEFINE_KERNELS (3dnowext, AMD3D_EXT)
void
_gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd)
{
init_ext (simd, "mmxext");
}
void
_gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd)
{
init_3dnow (simd, "3dnow");
}
void
_gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd)
{
init_3dnowext (simd, "3dnowext");
}
#else
void _gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd) { }
void _gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd) { }
void _gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd) { }
#endif
#endif

244
gdk/gdkrgb-neon.c Normal file
View file

@ -0,0 +1,244 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for NEON (ARMv7 with NEON, AArch64)
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include "gdkrgbsimd.h"
#if (defined(__ARM_NEON) || defined(__ARM_NEON__)) && !defined(__ARM_BIG_ENDIAN)
#include <arm_neon.h>
/* An x888 pixel is the bytes B, G, R, 0xff. The structure loads and
* stores take the channels apart and put them together. */
/* (a * s + (255 - a) * d) / 255, rounded */
static inline uint8x8_t
blend (uint8x8_t s, uint8x8_t d, uint8x8_t a, uint8x8_t inv)
{
uint16x8_t t = vmlal_u8 (vmull_u8 (s, a), d, inv);
return vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
}
static inline uint16x8_t
pack565 (uint8x8_t r, uint8x8_t g, uint8x8_t b)
{
uint16x8_t v = vshll_n_u8 (r, 8);
v = vsriq_n_u16 (v, vshll_n_u8 (g, 8), 5);
return vsriq_n_u16 (v, vshll_n_u8 (b, 8), 11);
}
/* with the unused bit set, as all of GdkRGB does */
static inline uint16x8_t
pack555 (uint8x8_t r, uint8x8_t g, uint8x8_t b)
{
uint16x8_t v = vshll_n_u8 (r, 7);
v = vsriq_n_u16 (v, vshll_n_u8 (g, 8), 6);
v = vsriq_n_u16 (v, vshll_n_u8 (b, 8), 11);
return vorrq_u16 (v, vdupq_n_u16 (0x8000));
}
static gint
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 16 <= n; i += 16, rgb += 48)
{
uint8x16x3_t s = vld3q_u8 (rgb);
uint8x16x4_t d;
d.val[0] = s.val[2];
d.val[1] = s.val[1];
d.val[2] = s.val[0];
d.val[3] = vdupq_n_u8 (0xff);
vst4q_u8 ((guchar *) (out + i), d);
}
return i;
}
static gint
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
{
gint i;
for (i = 0; i + 16 <= n; i += 16, rgbx += 64)
{
uint8x16x4_t s = vld4q_u8 (rgbx);
uint8x16x4_t d;
d.val[0] = s.val[2];
d.val[1] = s.val[1];
d.val[2] = s.val[0];
d.val[3] = vdupq_n_u8 (0xff);
vst4q_u8 ((guchar *) (out + i), d);
}
return i;
}
static gint
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
{
uint8x8x3_t s = vld3_u8 (rgb);
vst1q_u16 (out + i, pack565 (s.val[0], s.val[1], s.val[2]));
}
return i;
}
static gint
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
{
uint8x8x3_t s = vld3_u8 (rgb);
vst1q_u16 (out + i, pack555 (s.val[0], s.val[1], s.val[2]));
}
return i;
}
static gint
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
uint8x8x4_t s = vld4_u8 (rgba);
uint8x8x4_t d = vld4_u8 ((const guchar *) (pixels + i));
uint8x8_t a = s.val[3], inv = vmvn_u8 (a);
uint8x8_t transparent = vceq_u8 (a, vdup_n_u8 (0));
uint8x8x4_t v;
v.val[0] = vbsl_u8 (transparent, d.val[0], blend (s.val[2], d.val[0], a, inv));
v.val[1] = vbsl_u8 (transparent, d.val[1], blend (s.val[1], d.val[1], a, inv));
v.val[2] = vbsl_u8 (transparent, d.val[2], blend (s.val[0], d.val[2], a, inv));
v.val[3] = vbsl_u8 (transparent, d.val[3], vdup_n_u8 (0xff));
vst4_u8 ((guchar *) (pixels + i), v);
}
return i;
}
static gint
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
uint8x8x4_t s = vld4_u8 (rgba);
uint16x8_t d = vld1q_u16 (pixels + i);
uint8x8_t a = s.val[3], inv = vmvn_u8 (a);
uint8x8_t r = vmovn_u16 (vshrq_n_u16 (d, 8));
uint8x8_t g = vmovn_u16 (vshrq_n_u16 (d, 3));
uint8x8_t b = vmovn_u16 (vshlq_n_u16 (d, 3));
/* the bits of the pixel repeated up to 8 */
r = vsri_n_u8 (r, r, 5);
g = vsri_n_u8 (vand_u8 (g, vdup_n_u8 (0xfc)), g, 6);
b = vsri_n_u8 (b, b, 5);
vst1q_u16 (pixels + i, pack565 (blend (s.val[0], r, a, inv),
blend (s.val[1], g, a, inv),
blend (s.val[2], b, a, inv)));
}
return i;
}
/* c * a / 255 to the nearest */
static gint
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
uint8x8x4_t s = vld4_u8 (rgba);
uint8x8x4_t v;
uint16x8_t t;
t = vmull_u8 (s.val[2], s.val[3]);
v.val[0] = vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
t = vmull_u8 (s.val[1], s.val[3]);
v.val[1] = vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
t = vmull_u8 (s.val[0], s.val[3]);
v.val[2] = vrshrn_n_u16 (vrsraq_n_u16 (t, t, 8), 8);
v.val[3] = s.val[3];
vst4_u8 ((guchar *) (out + i), v);
}
return i;
}
static gint
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
uint8x8x4_t s = vld4_u8 (rgba);
uint16x8_t d = vld1q_u16 (pixels + i);
uint8x8_t a = s.val[3], inv = vmvn_u8 (a);
uint8x8_t r = vmovn_u16 (vshrq_n_u16 (d, 7));
uint8x8_t g = vmovn_u16 (vshrq_n_u16 (d, 2));
uint8x8_t b = vmovn_u16 (vshlq_n_u16 (d, 3));
uint16x8_t v;
/* the bits of the pixel repeated up to 8 */
r = vsri_n_u8 (r, r, 5);
g = vsri_n_u8 (g, g, 5);
b = vsri_n_u8 (b, b, 5);
v = pack555 (blend (s.val[0], r, a, inv),
blend (s.val[1], g, a, inv),
blend (s.val[2], b, a, inv));
/* where nothing is drawn the unused bit stays as it was */
vst1q_u16 (pixels + i,
vbslq_u16 (vreinterpretq_u16_s16 (vmovl_s8 (vreinterpret_s8_u8 (vceq_u8 (a, vdup_n_u8 (0))))),
d, v));
}
return i;
}
void
_gdk_rgb_simd_init_neon (GdkRgbSimd *simd)
{
simd->name = "neon";
simd->rgb_to_x888 = rgb_to_x888;
simd->rgbx_to_x888 = rgbx_to_x888;
simd->rgb_to_565 = rgb_to_565;
simd->rgb_to_555 = rgb_to_555;
simd->composite_x888 = composite_x888;
simd->composite_565 = composite_565;
simd->composite_555 = composite_555;
simd->rgba_to_argb = rgba_to_argb;
}
#endif

293
gdk/gdkrgb-sse2.c Normal file
View file

@ -0,0 +1,293 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for SSE2
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include "gdkrgbsimd.h"
#if defined(__SSE2__)
#include <emmintrin.h>
/* x86 is little endian: an x888 pixel is the bytes B, G, R, 0xff */
#define SPLAT(v) _mm_set1_epi32 ((gint) (v))
/* The 12 bytes of four RGB pixels as lanes R | G << 8 | B << 16 */
static inline __m128i
rgb_lanes (__m128i v)
{
__m128i lo = _mm_unpacklo_epi32 (v, _mm_srli_si128 (v, 3));
__m128i hi = _mm_unpacklo_epi32 (_mm_srli_si128 (v, 6), _mm_srli_si128 (v, 9));
return _mm_unpacklo_epi64 (lo, hi);
}
/* Lanes R | G << 8 | B << 16 to x888 */
static inline __m128i
x888_of (__m128i v)
{
return _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xff)), 16),
_mm_and_si128 (v, SPLAT (0xff00))),
_mm_or_si128 (_mm_and_si128 (_mm_srli_epi32 (v, 16), SPLAT (0xff)),
SPLAT (0xff000000)));
}
/* Lanes R | G << 8 | B << 16 to 565, sign extended for packing */
static inline __m128i
rgb565_of (__m128i v)
{
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 8),
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xfc00)), 5)),
_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)));
return _mm_srai_epi32 (_mm_slli_epi32 (v, 16), 16);
}
/* The same to 555, with the unused bit set as all of GdkRGB does */
static inline __m128i
rgb555_of (__m128i v)
{
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 7),
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xf800)), 6)),
_mm_or_si128 (_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)),
SPLAT (0x8000)));
return _mm_srai_epi32 (_mm_slli_epi32 (v, 16), 16);
}
static gint
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
{
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
__m128i b = _mm_loadl_epi64 ((const __m128i *) (rgb + 16));
__m128i c = _mm_or_si128 (_mm_srli_si128 (a, 12), _mm_slli_si128 (b, 4));
_mm_storeu_si128 ((__m128i *) (out + i), x888_of (rgb_lanes (a)));
_mm_storeu_si128 ((__m128i *) (out + i + 4), x888_of (rgb_lanes (c)));
}
return i;
}
static gint
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
{
gint i;
for (i = 0; i + 4 <= n; i += 4, rgbx += 16)
_mm_storeu_si128 ((__m128i *) (out + i),
x888_of (_mm_loadu_si128 ((const __m128i *) rgbx)));
return i;
}
static gint
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
{
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
__m128i b = _mm_loadl_epi64 ((const __m128i *) (rgb + 16));
__m128i c = _mm_or_si128 (_mm_srli_si128 (a, 12), _mm_slli_si128 (b, 4));
_mm_storeu_si128 ((__m128i *) (out + i),
_mm_packs_epi32 (rgb565_of (rgb_lanes (a)),
rgb565_of (rgb_lanes (c))));
}
return i;
}
static gint
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
{
gint i;
for (i = 0; i + 8 <= n; i += 8, rgb += 24)
{
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
__m128i b = _mm_loadl_epi64 ((const __m128i *) (rgb + 16));
__m128i c = _mm_or_si128 (_mm_srli_si128 (a, 12), _mm_slli_si128 (b, 4));
_mm_storeu_si128 ((__m128i *) (out + i),
_mm_packs_epi32 (rgb555_of (rgb_lanes (a)),
rgb555_of (rgb_lanes (c))));
}
return i;
}
/* (a * s + (255 - a) * d) / 255, rounded, in 16-bit lanes */
static inline __m128i
blend (__m128i s, __m128i d, __m128i a)
{
__m128i t = _mm_add_epi16 (_mm_add_epi16 (_mm_mullo_epi16 (s, a),
_mm_mullo_epi16 (d, _mm_sub_epi16 (_mm_set1_epi16 (255), a))),
_mm_set1_epi16 (0x80));
return _mm_srli_epi16 (_mm_add_epi16 (t, _mm_srli_epi16 (t, 8)), 8);
}
/* Alpha of each pixel in all four 16-bit lanes of the pixel */
static inline __m128i
alpha_of (__m128i v)
{
return _mm_shufflehi_epi16 (_mm_shufflelo_epi16 (v, 0xff), 0xff);
}
static gint
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
{
const __m128i zero = _mm_setzero_si128 ();
gint i;
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
{
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
__m128i d = _mm_loadu_si128 ((const __m128i *) (pixels + i));
__m128i transparent = _mm_cmpeq_epi32 (_mm_srli_epi32 (s, 24), zero);
__m128i lo, hi, v;
/* RGBA to BGRA, the order of the pixels */
s = _mm_or_si128 (_mm_and_si128 (s, SPLAT (0xff00ff00)),
_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (s, SPLAT (0xff)), 16),
_mm_and_si128 (_mm_srli_epi32 (s, 16), SPLAT (0xff))));
lo = _mm_unpacklo_epi8 (s, zero);
hi = _mm_unpackhi_epi8 (s, zero);
lo = blend (lo, _mm_unpacklo_epi8 (d, zero), alpha_of (lo));
hi = blend (hi, _mm_unpackhi_epi8 (d, zero), alpha_of (hi));
v = _mm_or_si128 (_mm_packus_epi16 (lo, hi), SPLAT (0xff000000));
/* fully transparent pixels stay as they are */
v = _mm_or_si128 (_mm_and_si128 (transparent, d), _mm_andnot_si128 (transparent, v));
_mm_storeu_si128 ((__m128i *) (pixels + i), v);
}
return i;
}
/* Eight 565 or 555 pixels at a time, each channel in a register */
static inline gint
composite_16 (guint16 *pixels, const guchar *rgba, gint n, const gint green_bits)
{
const gint red_shift = 5 + green_bits;
gint i;
for (i = 0; i + 8 <= n; i += 8, rgba += 32)
{
__m128i s0 = _mm_loadu_si128 ((const __m128i *) rgba);
__m128i s1 = _mm_loadu_si128 ((const __m128i *) (rgba + 16));
__m128i d = _mm_loadu_si128 ((const __m128i *) (pixels + i));
__m128i r = _mm_packs_epi32 (_mm_and_si128 (s0, SPLAT (0xff)),
_mm_and_si128 (s1, SPLAT (0xff)));
__m128i g = _mm_packs_epi32 (_mm_and_si128 (_mm_srli_epi32 (s0, 8), SPLAT (0xff)),
_mm_and_si128 (_mm_srli_epi32 (s1, 8), SPLAT (0xff)));
__m128i b = _mm_packs_epi32 (_mm_and_si128 (_mm_srli_epi32 (s0, 16), SPLAT (0xff)),
_mm_and_si128 (_mm_srli_epi32 (s1, 16), SPLAT (0xff)));
__m128i a = _mm_packs_epi32 (_mm_srli_epi32 (s0, 24), _mm_srli_epi32 (s1, 24));
__m128i dr = _mm_and_si128 (_mm_srli_epi16 (d, red_shift), _mm_set1_epi16 (0x1f));
__m128i dg = _mm_and_si128 (_mm_srli_epi16 (d, 5), _mm_set1_epi16 ((1 << green_bits) - 1));
__m128i db = _mm_and_si128 (d, _mm_set1_epi16 (0x1f));
__m128i v;
/* the bits of the pixel repeated up to 8 */
dr = _mm_or_si128 (_mm_slli_epi16 (dr, 3), _mm_srli_epi16 (dr, 2));
if (green_bits == 6)
dg = _mm_or_si128 (_mm_slli_epi16 (dg, 2), _mm_srli_epi16 (dg, 4));
else
dg = _mm_or_si128 (_mm_slli_epi16 (dg, 3), _mm_srli_epi16 (dg, 2));
db = _mm_or_si128 (_mm_slli_epi16 (db, 3), _mm_srli_epi16 (db, 2));
r = blend (r, dr, a);
g = blend (g, dg, a);
b = blend (b, db, a);
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi16 (_mm_srli_epi16 (r, 3), red_shift),
_mm_slli_epi16 (_mm_srli_epi16 (g, 8 - green_bits), 5)),
_mm_srli_epi16 (b, 3));
if (green_bits == 5)
{
/* the unused bit is set, except where nothing is drawn */
__m128i transparent = _mm_cmpeq_epi16 (a, _mm_setzero_si128 ());
v = _mm_or_si128 (_mm_and_si128 (transparent, d),
_mm_andnot_si128 (transparent, _mm_or_si128 (v, _mm_set1_epi16 ((gshort) 0x8000))));
}
_mm_storeu_si128 ((__m128i *) (pixels + i), v);
}
return i;
}
static gint
composite_565 (guint16 *pixels, const guchar *rgba, gint n)
{
return composite_16 (pixels, rgba, n, 6);
}
static gint
composite_555 (guint16 *pixels, const guchar *rgba, gint n)
{
return composite_16 (pixels, rgba, n, 5);
}
/* c * a / 255 to the nearest, which (c * a + 0x80) * 257 >> 16 is */
static gint
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
{
const __m128i zero = _mm_setzero_si128 ();
gint i;
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
{
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
__m128i lo = _mm_unpacklo_epi8 (s, zero);
__m128i hi = _mm_unpackhi_epi8 (s, zero);
lo = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (lo, alpha_of (lo)), _mm_set1_epi16 (0x80)),
_mm_set1_epi16 (257));
hi = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (hi, alpha_of (hi)), _mm_set1_epi16 (0x80)),
_mm_set1_epi16 (257));
/* R, G, B to B, G, R: the bytes of 0xAARRGGBB */
lo = _mm_shufflehi_epi16 (_mm_shufflelo_epi16 (lo, 0xc6), 0xc6);
hi = _mm_shufflehi_epi16 (_mm_shufflelo_epi16 (hi, 0xc6), 0xc6);
/* the alpha byte as it was */
_mm_storeu_si128 ((__m128i *) (out + i),
_mm_or_si128 (_mm_and_si128 (_mm_packus_epi16 (lo, hi), SPLAT (0x00ffffff)),
_mm_and_si128 (s, SPLAT (0xff000000))));
}
return i;
}
void
_gdk_rgb_simd_init_sse2 (GdkRgbSimd *simd)
{
simd->name = "sse2";
simd->rgb_to_x888 = rgb_to_x888;
simd->rgbx_to_x888 = rgbx_to_x888;
simd->rgb_to_565 = rgb_to_565;
simd->rgb_to_555 = rgb_to_555;
simd->composite_x888 = composite_x888;
simd->composite_565 = composite_565;
simd->composite_555 = composite_555;
simd->rgba_to_argb = rgba_to_argb;
}
#endif

217
gdk/gdkrgb-ssse3.c Normal file
View file

@ -0,0 +1,217 @@
/* GDK - The GIMP Drawing Kit
* GdkRGB loops for SSSE3 (Atom, Core 2 and later): pshufb moves the
* bytes of pixels where SSE2 takes a row of shifts and masks
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include "gdkrgbsimd.h"
#if defined(__SSSE3__)
#include <tmmintrin.h>
/* x86 is little endian: an x888 pixel is the bytes B, G, R, 0xff */
#define SPLAT(v) _mm_set1_epi32 ((gint) (v))
#define BYTES(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
_mm_setr_epi8 (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
/* The first 12 bytes of four RGB pixels to B, G, R, 0 each */
static inline __m128i
bgr0_of_rgb (__m128i v)
{
return _mm_shuffle_epi8 (v, BYTES (2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1));
}
/* ... and to lanes R | G << 8 | B << 16, which SSE2 calls them */
static inline __m128i
rgb0_of_rgb (__m128i v)
{
return _mm_shuffle_epi8 (v, BYTES (0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1));
}
static gint
rgb_to_x888 (guint32 *out, const guchar *rgb, gint n)
{
const __m128i fill = SPLAT (0xff000000);
gint i;
for (i = 0; i + 16 <= n; i += 16, rgb += 48)
{
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
__m128i b = _mm_loadu_si128 ((const __m128i *) (rgb + 16));
__m128i c = _mm_loadu_si128 ((const __m128i *) (rgb + 32));
_mm_storeu_si128 ((__m128i *) (out + i), _mm_or_si128 (bgr0_of_rgb (a), fill));
_mm_storeu_si128 ((__m128i *) (out + i + 4),
_mm_or_si128 (bgr0_of_rgb (_mm_alignr_epi8 (b, a, 12)), fill));
_mm_storeu_si128 ((__m128i *) (out + i + 8),
_mm_or_si128 (bgr0_of_rgb (_mm_alignr_epi8 (c, b, 8)), fill));
_mm_storeu_si128 ((__m128i *) (out + i + 12),
_mm_or_si128 (bgr0_of_rgb (_mm_srli_si128 (c, 4)), fill));
}
return i;
}
static gint
rgbx_to_x888 (guint32 *out, const guchar *rgbx, gint n)
{
const __m128i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
gint i;
for (i = 0; i + 4 <= n; i += 4, rgbx += 16)
_mm_storeu_si128 ((__m128i *) (out + i),
_mm_or_si128 (_mm_shuffle_epi8 (_mm_loadu_si128 ((const __m128i *) rgbx), order),
SPLAT (0xff000000)));
return i;
}
/* Lanes R | G << 8 | B << 16 to 565 or 555, sign extended for packing.
* The bit 555 has no use for is set, as in all of GdkRGB's pixels. */
static inline __m128i
rgb16_of (__m128i v, const gint green_bits)
{
if (green_bits == 6)
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 8),
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xfc00)), 5)),
_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)));
else
v = _mm_or_si128 (_mm_or_si128 (_mm_slli_epi32 (_mm_and_si128 (v, SPLAT (0xf8)), 7),
_mm_srli_epi32 (_mm_and_si128 (v, SPLAT (0xf800)), 6)),
_mm_or_si128 (_mm_and_si128 (_mm_srli_epi32 (v, 19), SPLAT (0x1f)),
SPLAT (0x8000)));
return _mm_srai_epi32 (_mm_slli_epi32 (v, 16), 16);
}
static inline gint
rgb_to_16 (guint16 *out, const guchar *rgb, gint n, const gint green_bits)
{
gint i;
for (i = 0; i + 16 <= n; i += 16, rgb += 48)
{
__m128i a = _mm_loadu_si128 ((const __m128i *) rgb);
__m128i b = _mm_loadu_si128 ((const __m128i *) (rgb + 16));
__m128i c = _mm_loadu_si128 ((const __m128i *) (rgb + 32));
_mm_storeu_si128 ((__m128i *) (out + i),
_mm_packs_epi32 (rgb16_of (rgb0_of_rgb (a), green_bits),
rgb16_of (rgb0_of_rgb (_mm_alignr_epi8 (b, a, 12)), green_bits)));
_mm_storeu_si128 ((__m128i *) (out + i + 8),
_mm_packs_epi32 (rgb16_of (rgb0_of_rgb (_mm_alignr_epi8 (c, b, 8)), green_bits),
rgb16_of (rgb0_of_rgb (_mm_srli_si128 (c, 4)), green_bits)));
}
return i;
}
static gint
rgb_to_565 (guint16 *out, const guchar *rgb, gint n)
{
return rgb_to_16 (out, rgb, n, 6);
}
static gint
rgb_to_555 (guint16 *out, const guchar *rgb, gint n)
{
return rgb_to_16 (out, rgb, n, 5);
}
/* The alpha of each pixel in its four 16-bit lanes */
static inline __m128i
alpha_of (__m128i v)
{
return _mm_shuffle_epi8 (v, BYTES (6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15));
}
/* (a * s + (255 - a) * d) / 255, rounded as GdkRGB's C code does */
static inline __m128i
blend (__m128i s, __m128i d, __m128i a)
{
__m128i t = _mm_add_epi16 (_mm_add_epi16 (_mm_mullo_epi16 (s, a),
_mm_mullo_epi16 (d, _mm_sub_epi16 (_mm_set1_epi16 (255), a))),
_mm_set1_epi16 (0x80));
return _mm_mulhi_epu16 (t, _mm_set1_epi16 (257));
}
static gint
composite_x888 (guint32 *pixels, const guchar *rgba, gint n)
{
const __m128i zero = _mm_setzero_si128 ();
const __m128i order = BYTES (2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
gint i;
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
{
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
__m128i d = _mm_loadu_si128 ((const __m128i *) (pixels + i));
__m128i transparent = _mm_cmpeq_epi32 (_mm_srli_epi32 (s, 24), zero);
__m128i lo, hi, v;
/* RGBA to BGRA, the order of the pixels */
s = _mm_shuffle_epi8 (s, order);
lo = _mm_unpacklo_epi8 (s, zero);
hi = _mm_unpackhi_epi8 (s, zero);
lo = blend (lo, _mm_unpacklo_epi8 (d, zero), alpha_of (lo));
hi = blend (hi, _mm_unpackhi_epi8 (d, zero), alpha_of (hi));
v = _mm_or_si128 (_mm_packus_epi16 (lo, hi), SPLAT (0xff000000));
/* fully transparent pixels stay as they are */
v = _mm_or_si128 (_mm_and_si128 (transparent, d), _mm_andnot_si128 (transparent, v));
_mm_storeu_si128 ((__m128i *) (pixels + i), v);
}
return i;
}
/* c * a / 255 to the nearest, which (c * a + 0x80) * 257 >> 16 is */
static gint
rgba_to_argb (guint32 *out, const guchar *rgba, gint n)
{
const __m128i zero = _mm_setzero_si128 ();
const __m128i order = BYTES (2, 1, 0, -1, 6, 5, 4, -1, 10, 9, 8, -1, 14, 13, 12, -1);
gint i;
for (i = 0; i + 4 <= n; i += 4, rgba += 16)
{
__m128i s = _mm_loadu_si128 ((const __m128i *) rgba);
__m128i lo = _mm_unpacklo_epi8 (s, zero);
__m128i hi = _mm_unpackhi_epi8 (s, zero);
lo = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (lo, alpha_of (lo)), _mm_set1_epi16 (0x80)),
_mm_set1_epi16 (257));
hi = _mm_mulhi_epu16 (_mm_add_epi16 (_mm_mullo_epi16 (hi, alpha_of (hi)), _mm_set1_epi16 (0x80)),
_mm_set1_epi16 (257));
/* R, G, B to B, G, R, and the alpha byte as it was */
_mm_storeu_si128 ((__m128i *) (out + i),
_mm_or_si128 (_mm_shuffle_epi8 (_mm_packus_epi16 (lo, hi), order),
_mm_and_si128 (s, SPLAT (0xff000000))));
}
return i;
}
void
_gdk_rgb_simd_init_ssse3 (GdkRgbSimd *simd)
{
simd->name = "ssse3";
simd->rgb_to_x888 = rgb_to_x888;
simd->rgbx_to_x888 = rgbx_to_x888;
simd->rgb_to_565 = rgb_to_565;
simd->rgb_to_555 = rgb_to_555;
simd->composite_x888 = composite_x888;
simd->rgba_to_argb = rgba_to_argb;
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -127,7 +127,7 @@ void gdk_draw_indexed_image (GdkDrawable *drawable,
const guchar *buf,
gint rowstride,
GdkRgbCmap *cmap);
GType gdk_rgb_cmap_get_type (void) G_GNUC_CONST;
GType gdk_rgb_cmap_get_type (void);
GdkRgbCmap *gdk_rgb_cmap_copy (const GdkRgbCmap *cmap);
GdkRgbCmap *gdk_rgb_cmap_new (guint32 *colors,
gint n_colors);
@ -147,6 +147,48 @@ gboolean gdk_rgb_colormap_ditherable (GdkColormap *cmap);
#endif
#endif /* GDK_DISABLE_DEPRECATED */
void gdk_draw_rgb_48_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guint16 *rgb_buf,
gint rowstride);
void gdk_draw_rgb_48_image_dithalign (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guint16 *rgb_buf,
gint rowstride,
gint xdith,
gint ydith);
void gdk_draw_rgbx_64_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guint16 *rgbx_buf,
gint rowstride);
void gdk_draw_rgbx_64_image_dithalign
(GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guint16 *rgbx_buf,
gint rowstride,
gint xdith,
gint ydith);
G_END_DECLS

319
gdk/gdkrgbsimd.c Normal file
View file

@ -0,0 +1,319 @@
/* GDK - The GIMP Drawing Kit
* Choosing the vector versions of GdkRGB loops for this CPU
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "gdkrgbsimd.h"
#if defined(__i386__) || defined(__x86_64__)
#if defined(__GNUC__)
#include <cpuid.h>
#endif
#elif defined(__powerpc__) || defined(__ppc__) || defined(__arm__)
#if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)
#include <sys/auxv.h>
#elif defined(__APPLE__)
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#endif
/* All instruction sets, from the least to the most preferred: each
* kernel comes from the last set that has it and the CPU can run */
static const GdkRgbSimdSet all_sets[] =
{
#ifdef GDK_RGB_SIMD_MMX
{ "mmx", _gdk_rgb_simd_init_mmx },
{ "mmxext", _gdk_rgb_simd_init_mmxext },
{ "3dnow", _gdk_rgb_simd_init_3dnow },
{ "3dnowext", _gdk_rgb_simd_init_3dnowext },
#endif
#ifdef GDK_RGB_SIMD_SSE2
{ "sse2", _gdk_rgb_simd_init_sse2 },
#endif
#ifdef GDK_RGB_SIMD_SSSE3
{ "ssse3", _gdk_rgb_simd_init_ssse3 },
#endif
#ifdef GDK_RGB_SIMD_AVX2
{ "avx2", _gdk_rgb_simd_init_avx2 },
#endif
#ifdef GDK_RGB_SIMD_ALTIVEC
{ "altivec", _gdk_rgb_simd_init_altivec },
#endif
#ifdef GDK_RGB_SIMD_ARMV6
{ "armv6", _gdk_rgb_simd_init_armv6 },
#endif
#ifdef GDK_RGB_SIMD_NEON
{ "neon", _gdk_rgb_simd_init_neon },
#endif
{ NULL, NULL } /* not every build has any */
};
static const GdkRgbSimdOp all_ops[] =
{
{ "rgb_to_x888", G_STRUCT_OFFSET (GdkRgbSimd, rgb_to_x888) },
{ "rgbx_to_x888", G_STRUCT_OFFSET (GdkRgbSimd, rgbx_to_x888) },
{ "rgb_to_565", G_STRUCT_OFFSET (GdkRgbSimd, rgb_to_565) },
{ "rgb_to_555", G_STRUCT_OFFSET (GdkRgbSimd, rgb_to_555) },
{ "composite_x888", G_STRUCT_OFFSET (GdkRgbSimd, composite_x888) },
{ "composite_565", G_STRUCT_OFFSET (GdkRgbSimd, composite_565) },
{ "composite_555", G_STRUCT_OFFSET (GdkRgbSimd, composite_555) },
{ "rgba_to_argb", G_STRUCT_OFFSET (GdkRgbSimd, rgba_to_argb) },
};
#define OP(simd, i) G_STRUCT_MEMBER (gpointer, (simd), all_ops[i].offset)
/* The CPU's hardware capabilities word, as the kernel tells them */
#if (defined(__powerpc__) || defined(__arm__)) && \
(defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
static unsigned long
hwcap (void)
{
#if defined(HAVE_GETAUXVAL)
return getauxval (AT_HWCAP);
#else
unsigned long caps = 0;
if (elf_aux_info (AT_HWCAP, &caps, sizeof (caps)) != 0)
return 0;
return caps;
#endif
}
#endif
#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
/* AVX2: the CPU has it, and the system saves the wide registers
* (OSXSAVE, then XCR0 says SSE and AVX state) */
static gboolean
cpu_has_avx2 (unsigned int ecx)
{
unsigned int eax, ebx, ecx7, edx, xcr0_low, xcr0_high;
if ((ecx & (1 << 27)) == 0 || (ecx & (1 << 28)) == 0 ||
__get_cpuid_max (0, NULL) < 7)
return FALSE;
__cpuid_count (7, 0, eax, ebx, ecx7, edx);
if ((ebx & (1 << 5)) == 0)
return FALSE;
__asm__ (".byte 0x0f, 0x01, 0xd0" /* xgetbv, which old assemblers do not know */
: "=a" (xcr0_low), "=d" (xcr0_high) : "c" (0));
return (xcr0_low & 6) == 6;
}
#endif
/* Whether this CPU can run the set */
static gboolean
cpu_has (const gchar *set)
{
#if defined(__x86_64__)
unsigned int eax, ebx, ecx, edx;
/* every x86-64 CPU has SSE2, which beats the older sets */
if (strcmp (set, "sse2") == 0)
return TRUE;
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
return FALSE;
if (strcmp (set, "ssse3") == 0)
return (ecx & (1 << 9)) != 0;
if (strcmp (set, "avx2") == 0)
return cpu_has_avx2 (ecx);
return FALSE;
#elif defined(__i386__) && defined(__GNUC__)
unsigned int eax, ebx, ecx, edx, ext = 0, max_ext;
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
return FALSE;
/* CPUs without the extended leaves answer with something else */
max_ext = __get_cpuid_max (0x80000000, NULL);
if ((max_ext & 0xffff0000) == 0x80000000 && max_ext >= 0x80000001)
{
unsigned int a, b, c;
__cpuid (0x80000001, a, b, c, ext);
}
if (strcmp (set, "mmx") == 0)
return (edx & (1 << 23)) != 0;
/* the integer part of SSE, or AMD's extensions to MMX */
if (strcmp (set, "mmxext") == 0)
return (edx & (1 << 25)) != 0 || (ext & (1 << 22)) != 0;
if (strcmp (set, "3dnow") == 0)
return (ext & (1u << 31)) != 0;
if (strcmp (set, "3dnowext") == 0)
return (ext & (1 << 30)) != 0 && (ext & (1u << 31)) != 0 && (ext & (1 << 22)) != 0;
if (strcmp (set, "sse2") == 0)
return (edx & (1 << 26)) != 0;
if (strcmp (set, "ssse3") == 0)
return (ecx & (1 << 9)) != 0;
if (strcmp (set, "avx2") == 0)
return cpu_has_avx2 (ecx);
return FALSE;
#elif defined(__aarch64__)
return strcmp (set, "neon") == 0;
#elif defined(__arm__) && (defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
if (strcmp (set, "armv6") == 0)
{
#if defined(__ARM_ARCH) && __ARM_ARCH >= 6
return TRUE; /* what all of this is built for */
#elif defined(HAVE_GETAUXVAL)
/* "v6l", "v7l", "v8l" */
const gchar *platform = (const gchar *) getauxval (AT_PLATFORM);
return platform && platform[0] == 'v' && atoi (platform + 1) >= 6;
#else
return FALSE;
#endif
}
return strcmp (set, "neon") == 0 && (hwcap () & (1 << 12)) != 0; /* HWCAP_NEON */
#elif defined(__powerpc__) && (defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
return strcmp (set, "altivec") == 0 && (hwcap () & 0x10000000) != 0; /* PPC_FEATURE_HAS_ALTIVEC */
#elif defined(__ppc__) && defined(__APPLE__)
int vector_unit = 0;
size_t size = sizeof (vector_unit);
return strcmp (set, "altivec") == 0 &&
sysctlbyname ("hw.vectorunit", &vector_unit, &size, NULL, 0) == 0 && vector_unit;
#else
return FALSE;
#endif
}
/**
* _gdk_rgb_simd_sets:
* @n_sets: the number of sets
*
* The instruction sets this CPU can run, least preferred first. The
* init function of a set fills in only what is in it.
*/
const GdkRgbSimdSet *
_gdk_rgb_simd_sets (gint *n_sets)
{
static GdkRgbSimdSet sets[G_N_ELEMENTS (all_sets)];
static gint n = -1;
guint i;
if (n < 0)
{
n = 0;
for (i = 0; all_sets[i].name; i++)
if (cpu_has (all_sets[i].name))
{
GdkRgbSimd probe = { NULL, };
/* a set the compiler couldn't build fills in nothing */
all_sets[i].init (&probe);
if (probe.name)
sets[n++] = all_sets[i];
}
}
*n_sets = n;
return sets;
}
/**
* _gdk_rgb_simd_ops:
* @n_ops: the number of operations
*
* The names of the kernels and where they are in a #GdkRgbSimd.
*/
const GdkRgbSimdOp *
_gdk_rgb_simd_ops (gint *n_ops)
{
*n_ops = G_N_ELEMENTS (all_ops);
return all_ops;
}
/* GDK_RGB_SIMD picks sets by hand, to try them: "c" for none, a set
* for that one wherever it has a kernel, "op=set" or "op=c" for one
* kernel; several of these separated by commas, applied in order. */
static void
choose_by_hand (GdkRgbSimd *simd,
const gchar *spec,
const GdkRgbSimdSet *sets,
gint n_sets)
{
gchar **items = g_strsplit (spec, ",", -1);
gint i, k, s;
for (i = 0; items[i]; i++)
{
gchar *item = g_strstrip (items[i]);
gchar *eq = strchr (item, '=');
const gchar *set = eq ? eq + 1 : item;
GdkRgbSimd from = { NULL, };
if (eq)
*eq = '\0';
for (s = 0; s < n_sets; s++)
if (strcmp (sets[s].name, set) == 0)
{
sets[s].init (&from);
break;
}
if (s == n_sets && strcmp (set, "c") != 0)
{
g_warning ("GDK_RGB_SIMD: %s is not an instruction set this CPU has", set);
continue;
}
for (k = 0; k < (gint) G_N_ELEMENTS (all_ops); k++)
if (!eq || strcmp (item, all_ops[k].name) == 0)
OP (simd, k) = OP (&from, k);
}
simd->name = "by hand";
g_strfreev (items);
}
const GdkRgbSimd *
_gdk_rgb_simd_get (void)
{
static GdkRgbSimd simd = { "none", };
static gboolean done = FALSE;
if (!done)
{
const gchar *disable = g_getenv ("GDK_DISABLE_SIMD");
const gchar *spec = g_getenv ("GDK_RGB_SIMD");
const GdkRgbSimdSet *sets;
gint n_sets, s, k;
done = TRUE;
if (disable && *disable && *disable != '0')
return &simd;
sets = _gdk_rgb_simd_sets (&n_sets);
for (s = 0; s < n_sets; s++)
{
GdkRgbSimd set = { NULL, };
sets[s].init (&set);
for (k = 0; k < (gint) G_N_ELEMENTS (all_ops); k++)
if (OP (&set, k))
OP (&simd, k) = OP (&set, k);
simd.name = set.name;
}
if (spec && *spec)
choose_by_hand (&simd, spec, sets, n_sets);
}
return &simd;
}

84
gdk/gdkrgbsimd.h Normal file
View file

@ -0,0 +1,84 @@
/* GDK - The GIMP Drawing Kit
* Vector versions of GdkRGB loops
*
* 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 of the License, or (at your option) any later version.
*/
/* Vector versions of the busiest GdkRGB loops.
*
* Each converts pixels from the start of a row, as many as it likes, and
* returns how many; the C code does the rest. Pixels are words in the
* byte order of the machine:
*
* x888 0xffRRGGBB, 32 bits
* 565 RRRRRGGG GGGBBBBB, 16 bits
* 555 1RRRRRGG GGGBBBBB, 16 bits, with the unused bit set
* argb 0xAARRGGBB, 32 bits, R, G and B multiplied by A / 255,
* rounded to the nearest: cairo's ARGB32
*
* RGB and RGBA are bytes in that order; RGBA is not premultiplied.
* Blending rounds as GdkRGB's C code does, so the results are the same.
* No alignment is required of any pointer.
*/
#ifndef __GDK_RGB_SIMD_H__
#define __GDK_RGB_SIMD_H__
#include <glib.h>
G_BEGIN_DECLS
typedef struct _GdkRgbSimd GdkRgbSimd;
struct _GdkRgbSimd
{
const gchar *name;
gint (*rgb_to_x888) (guint32 *out, const guchar *rgb, gint n);
gint (*rgbx_to_x888) (guint32 *out, const guchar *rgbx, gint n);
gint (*rgb_to_565) (guint16 *out, const guchar *rgb, gint n);
gint (*rgb_to_555) (guint16 *out, const guchar *rgb, gint n);
gint (*composite_x888) (guint32 *pixels, const guchar *rgba, gint n);
gint (*composite_565) (guint16 *pixels, const guchar *rgba, gint n);
gint (*composite_555) (guint16 *pixels, const guchar *rgba, gint n);
gint (*rgba_to_argb) (guint32 *out, const guchar *rgba, gint n);
};
typedef struct
{
const gchar *name;
void (*init) (GdkRgbSimd *simd);
} GdkRgbSimdSet;
typedef struct
{
const gchar *name;
glong offset;
} GdkRgbSimdOp;
/* Each fills in what its instruction set does better than C; they are
* only called when the CPU has it. */
void _gdk_rgb_simd_init_mmx (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_sse2 (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_ssse3 (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_avx2 (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_altivec (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_armv6 (GdkRgbSimd *simd);
void _gdk_rgb_simd_init_neon (GdkRgbSimd *simd);
/* The kernels for this CPU, or none with GDK_DISABLE_SIMD set */
const GdkRgbSimd *_gdk_rgb_simd_get (void);
/* For trying them: the sets this CPU has and the kernels by name */
const GdkRgbSimdSet *_gdk_rgb_simd_sets (gint *n_sets);
const GdkRgbSimdOp *_gdk_rgb_simd_ops (gint *n_ops);
G_END_DECLS
#endif /* __GDK_RGB_SIMD_H__ */

View file

@ -27,6 +27,7 @@
#include "gdkwindow.h"
#include "gdkscreen.h"
#include "gdkintl.h"
#include "gdkinternals.h"
#include "gdkalias.h"
static void gdk_screen_dispose (GObject *object);
@ -541,5 +542,30 @@ gdk_screen_set_property (GObject *object,
}
}
/**
* gdk_screen_get_monitor_scale_factor:
* @screen: a #GdkScreen
* @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen)
*
* Returns the internal scale factor that maps from monitor coordinates
* to the actual device pixels, as in GTK+ 3: on traditional systems
* this is 1, on high density outputs it can be higher (typically 2).
* The coordinates of GDK and GTK+ stay in units of the scale 1.
*
* Returns: the scale factor
*
* Since: 2.24
*/
gint
gdk_screen_get_monitor_scale_factor (GdkScreen *screen,
gint monitor_num)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 1);
g_return_val_if_fail (monitor_num >= 0, 1);
g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), 1);
return _gdk_windowing_screen_get_monitor_scale (screen, monitor_num);
}
#define __GDK_SCREEN_C__
#include "gdkaliasdef.c"

View file

@ -66,7 +66,7 @@ struct _GdkScreenClass
void (*monitors_changed) (GdkScreen *screen);
};
GType gdk_screen_get_type (void) G_GNUC_CONST;
GType gdk_screen_get_type (void);
GdkColormap *gdk_screen_get_default_colormap (GdkScreen *screen);
void gdk_screen_set_default_colormap (GdkScreen *screen,
GdkColormap *colormap);
@ -106,6 +106,8 @@ gint gdk_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num);
gchar * gdk_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num);
gint gdk_screen_get_monitor_scale_factor (GdkScreen *screen,
gint monitor_num);
void gdk_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event);

View file

@ -97,7 +97,7 @@ struct _GdkVisual
gint GSEAL (blue_prec);
};
GType gdk_visual_get_type (void) G_GNUC_CONST;
GType gdk_visual_get_type (void);
#ifndef GDK_MULTIHEAD_SAFE
gint gdk_visual_get_best_depth (void);

File diff suppressed because it is too large Load diff

View file

@ -328,7 +328,7 @@ struct _GdkWindowObjectClass
/* Windows
*/
GType gdk_window_object_get_type (void) G_GNUC_CONST;
GType gdk_window_object_get_type (void);
GdkWindow* gdk_window_new (GdkWindow *parent,
GdkWindowAttr *attributes,
gint attributes_mask);
@ -341,6 +341,7 @@ GdkDisplay* gdk_window_get_display (GdkWindow *window);
GdkVisual* gdk_window_get_visual (GdkWindow *window);
int gdk_window_get_width (GdkWindow *window);
int gdk_window_get_height (GdkWindow *window);
gint gdk_window_get_scale_factor (GdkWindow *window);
GdkWindow* gdk_window_at_pointer (gint *win_x,
gint *win_y);
@ -679,6 +680,7 @@ void gdk_window_thaw_updates (GdkWindow *window);
void gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window);
void gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window);
void gdk_window_set_touch_emulation_libgtk_only (GdkWindow *window);
void gdk_window_process_all_updates (void);
void gdk_window_process_updates (GdkWindow *window,

View file

@ -150,7 +150,7 @@ struct _GdkWindowImplIface
};
/* Interface Functions */
GType gdk_window_impl_get_type (void) G_GNUC_CONST;
GType gdk_window_impl_get_type (void);
/* private definitions from gdkwindow.h */

View file

@ -92,6 +92,7 @@ gdk_OBJECTS = \
gdkrectangle.obj \
gdkregion-generic.obj \
gdkrgb.obj \
gdkrgbsimd.obj \
gdkscreen.obj \
gdkselection.obj \
gdkvisual.obj \

View file

@ -14,26 +14,27 @@ print <<EOF;
#include <glib.h>
#ifdef G_HAVE_GNUC_VISIBILITY
#if defined(G_HAVE_GNUC_VISIBILITY) && !defined(__APPLE__) && !defined(G_OS_WIN32)
EOF
if ($do_def) {
print <<EOF
#undef IN_FILE
#define IN_FILE defined
# The sections of the .symbols file become plain tests here: a macro
# that expands to "defined" is undefined behaviour, which clang warns of.
# Aliases (the -def file) are made for the file being compiled, the
# renaming (the header) for the headers it included.
sub section_test {
my ($line) = @_;
#undef IN_HEADER
#define IN_HEADER(x) 1
if ($do_def) {
$line =~ s/IN_FILE\(([^)]*)\)/defined($1)/g;
$line =~ s/IN_HEADER\([^)]*\)/1/g;
}
else {
$line =~ s/IN_FILE\([^)]*\)/1/g;
$line =~ s/IN_HEADER\(([^)]*)\)/defined($1)/g;
}
EOF
}
else {
print <<EOF
#define IN_FILE(x) 1
#define IN_HEADER defined
EOF
return $line;
}
my $in_comment = 0;
@ -92,7 +93,7 @@ while (<>) {
if ($_ =~ /^\#if.*(IN_FILE|IN_HEADER)/)
{
print $_;
print section_test ($_);
next;
}

View file

@ -32,7 +32,9 @@
if ((self = [super initWithFrame: frameRect]))
{
markedRange = NSMakeRange (NSNotFound, 0);
selectedRange = NSMakeRange (NSNotFound, 0);
/* the caret, not NSNotFound: without a location, macOS shows no
* window of accented characters when a key is held down */
selectedRange = NSMakeRange (0, 0);
}
return self;
@ -59,6 +61,14 @@
-(void) keyDown: (NSEvent *) theEvent
{
GDK_NOTE (EVENTS, g_print ("keyDown\n"));
/* A key held down for the window of accented characters (10.7 and
* later) calls none of the methods below while it repeats: the key is
* the input method's then. Any text, marked text or command clears
* or replaces this. */
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
GUINT_TO_POINTER (GIC_FILTER_FILTERED));
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
}
@ -126,7 +136,8 @@
{
GDK_NOTE (EVENTS, g_print ("unmarkText\n"));
gchar *prev_str;
markedRange = selectedRange = NSMakeRange (NSNotFound, 0);
selectedRange = NSMakeRange (0, 0);
markedRange = NSMakeRange (NSNotFound, 0);
prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_MARKED_TEXT);
if (prev_str)
@ -184,11 +195,21 @@
GDK_NOTE (EVENTS, g_print ("doCommandBySelector\n"));
if ([self respondsToSelector: aSelector])
[self performSelector: aSelector];
/* whatever the command, GTK+ handles the key itself (as in GTK+ 3.24) */
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
}
/* This gets called on OS X 10.6 and upwards from interpretKeyEvents */
-(void)insertText: (id)aString replacementRange: (NSRange)replacementRange
{
/* the window of accented characters replaces the character typed
* before it: the input method deletes it around the cursor */
if (replacementRange.location != NSNotFound && replacementRange.length > 0)
g_object_set_data (G_OBJECT (gdk_window), TIC_INSERT_TEXT_REPLACE_LEN,
GINT_TO_POINTER (replacementRange.length));
[self insertText:aString];
}
@ -223,6 +244,7 @@
else
{
str = [string UTF8String];
selectedRange = NSMakeRange ([string length], 0);
}
prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_INSERT_TEXT);
@ -530,6 +552,20 @@
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
}
-(void)scrollPageDown: (id)sender
{
GDK_NOTE (EVENTS, g_message ("scrollPageDown"));
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
}
-(void)scrollPageUp: (id)sender
{
GDK_NOTE (EVENTS, g_message ("scrollPageUp"));
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
}
-(void)selectAll: (id)sender
{
GDK_NOTE (EVENTS, g_print ("selectAll\n"));
@ -599,6 +635,64 @@
gdk_screen_get_rgba_colormap (_gdk_screen);
}
-(void)viewWillDraw
{
/* macOS 11 (Big Sur) and newer may use a higher precision backing
* format for layer contents. For GTK2's 8-bit drawing this can add
* avoidable conversion overhead. Use a dynamic Objective-C call here
* instead of a hard QuartzCore/CALayer dependency, so old SDKs and old
* macOS targets keep building and keep their old behaviour.
*/
if (gdk_quartz_osx_version () >= GDK_OSX_BIG_SUR)
{
id layer = [self layer];
if (layer && [layer respondsToSelector: @selector(setContentsFormat:)])
[layer setValue: @"RGBA8Uint" forKey: @"contentsFormat"];
}
[super viewWillDraw];
}
/* What AppKit invalidates goes into GDK's bookkeeping too, so that
* drawRect: knows all of it (see _gdk_quartz_use_gdk_invalidation()) */
-(void)noteNeedsDisplayInRect: (NSRect)rect
{
GdkWindowImplQuartz *impl;
GdkRectangle gdk_rect;
NSRect bounds = [self bounds];
if (!gdk_window || GDK_WINDOW_DESTROYED (gdk_window) ||
!_gdk_quartz_use_gdk_invalidation ())
return;
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (gdk_window)->impl);
rect = NSIntersectionRect (rect, bounds);
if (NSIsEmptyRect (rect))
return;
gdk_rect.x = floor (rect.origin.x);
gdk_rect.y = floor (rect.origin.y);
gdk_rect.width = ceil (rect.origin.x + rect.size.width) - gdk_rect.x;
gdk_rect.height = ceil (rect.origin.y + rect.size.height) - gdk_rect.y;
if (!impl->needs_display_region)
impl->needs_display_region = gdk_region_new ();
gdk_region_union_with_rect (impl->needs_display_region, &gdk_rect);
}
-(void)setNeedsDisplayInRect: (NSRect)rect
{
[self noteNeedsDisplayInRect: rect];
[super setNeedsDisplayInRect: rect];
}
-(void)setNeedsDisplay: (BOOL)flag
{
if (flag)
[self noteNeedsDisplayInRect: [self bounds]];
[super setNeedsDisplay: flag];
}
-(void)drawRect: (NSRect)rect
{
GdkRectangle gdk_rect;
@ -607,7 +701,7 @@
const NSRect *drawn_rects;
NSInteger count;
int i;
GdkRegion *region;
GdkRegion *region, *needs;
if (GDK_WINDOW_DESTROYED (gdk_window))
return;
@ -629,7 +723,13 @@
*/
[NSGraphicsContext saveGraphicsState];
[[NSColor windowBackgroundColor] setFill];
if (impl->background_color_set)
[[NSColor colorWithCalibratedRed: impl->background_color.red / 65535.0
green: impl->background_color.green / 65535.0
blue: impl->background_color.blue / 65535.0
alpha: 1.0] setFill];
else
[[NSColor windowBackgroundColor] setFill];
[NSBezierPath fillRect: rect];
[NSGraphicsContext restoreGraphicsState];
@ -637,25 +737,49 @@
return;
}
/* Clear our own bookkeeping of regions that need display */
if (impl->needs_display_region)
/* Our own bookkeeping of what needs display; taken here, as an
* expose may invalidate again */
needs = impl->needs_display_region;
impl->needs_display_region = NULL;
if (needs && _gdk_quartz_use_gdk_invalidation () &&
!NSContainsRect (rect, [self bounds]))
{
gdk_region_destroy (impl->needs_display_region);
impl->needs_display_region = NULL;
/* Layer-backed views (10.14 and newer) merge the invalidated
* rects into one, or give the whole view: the windows of two
* small meters in opposite corners would expose all between.
* What GDK and AppKit invalidated is known here exactly (from
* Ardour's YTK). */
GdkRegion *drawing;
gdk_rect.x = rect.origin.x;
gdk_rect.y = rect.origin.y;
gdk_rect.width = rect.size.width;
gdk_rect.height = rect.size.height;
drawing = gdk_region_rectangle (&gdk_rect);
region = needs;
needs = NULL;
gdk_region_intersect (region, drawing);
gdk_region_destroy (drawing);
}
else
{
[self getRectsBeingDrawn: &drawn_rects count: &count];
region = gdk_region_new ();
for (i = 0; i < count; i++)
{
gdk_rect.x = drawn_rects[i].origin.x;
gdk_rect.y = drawn_rects[i].origin.y;
gdk_rect.width = drawn_rects[i].size.width;
gdk_rect.height = drawn_rects[i].size.height;
gdk_region_union_with_rect (region, &gdk_rect);
}
}
[self getRectsBeingDrawn: &drawn_rects count: &count];
region = gdk_region_new ();
for (i = 0; i < count; i++)
{
gdk_rect.x = drawn_rects[i].origin.x;
gdk_rect.y = drawn_rects[i].origin.y;
gdk_rect.width = drawn_rects[i].size.width;
gdk_rect.height = drawn_rects[i].size.height;
gdk_region_union_with_rect (region, &gdk_rect);
}
if (needs)
gdk_region_destroy (needs);
impl->in_paint_rect_count++;
_gdk_window_process_updates_recurse (gdk_window, region);

View file

@ -26,6 +26,7 @@
#define TIC_SELECTED_POS "tic-selected-pos"
#define TIC_SELECTED_LEN "tic-selected-len"
#define TIC_INSERT_TEXT "tic-insert-text"
#define TIC_INSERT_TEXT_REPLACE_LEN "tic-insert-text-replace-len"
#define TIC_IN_KEY_DOWN "tic-in-key-down"
/* GtkIMContext */

View file

@ -69,6 +69,9 @@
_gdk_quartz_window_attach_to_parent (window);
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0);
/* newer systems may come back with stale contents (Ardour) */
[[self contentView] setNeedsDisplay:YES];
}
-(void)windowDidBecomeKey:(NSNotification *)aNotification
@ -429,9 +432,13 @@
return YES;
}
-(BOOL)isInManualResize
/* Used by gdkevents-quartz.c to decide if our sendEvent() handler above
* will see the event or if it will be subjected to standard processing
* by GDK.
*/
-(BOOL)isInManualResizeOrMove
{
return inManualResize;
return inManualResize || inManualMove;
}
-(void)beginManualResize

View file

@ -39,7 +39,7 @@
-(BOOL)isInMove;
-(void)beginManualMove;
-(BOOL)trackManualMove;
-(BOOL)isInManualResize;
-(BOOL)isInManualResizeOrMove;
-(void)beginManualResize;
-(BOOL)trackManualResize;
-(void)showAndMakeKey:(BOOL)makeKey;

View file

@ -79,6 +79,11 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
surface_data,
gdk_quartz_cairo_surface_destroy);
/* HiDPI: AppKit puts the points on the pixels of a Retina screen;
* pixbufs with a picture of those pixels use it */
if (cg_context && GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
_gdk_cairo_surface_set_hidpi_scale (surface, _gdk_windowing_drawable_get_scale (drawable));
return surface;
}
@ -100,7 +105,13 @@ gdk_quartz_ref_cairo_surface (GdkDrawable *drawable)
width, height);
}
else
cairo_surface_reference (impl->cairo_surface);
{
cairo_surface_reference (impl->cairo_surface);
/* HiDPI: the window may be on a screen of another scale by now */
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
_gdk_cairo_surface_set_hidpi_scale (impl->cairo_surface,
_gdk_windowing_drawable_get_scale (drawable));
}
return impl->cairo_surface;
}
@ -652,21 +663,34 @@ gdk_quartz_draw_pixbuf (GdkDrawable *drawable,
void *data;
int rowstride, pixbuf_width, pixbuf_height;
gboolean has_alpha;
GdkPixbuf *picture = pixbuf;
if (!context)
return;
pixbuf_width = gdk_pixbuf_get_width (pixbuf);
pixbuf_height = gdk_pixbuf_get_height (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
data = gdk_pixbuf_get_pixels (pixbuf);
/* HiDPI: on a Retina screen the picture made for it, drawn into the
* same points */
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
{
GdkPixbuf *hires = _gdk_pixbuf_get_hires (pixbuf, _gdk_windowing_drawable_get_scale (drawable));
if (hires)
picture = hires;
}
rowstride = gdk_pixbuf_get_rowstride (picture);
has_alpha = gdk_pixbuf_get_has_alpha (picture);
data = gdk_pixbuf_get_pixels (picture);
colorspace = CGColorSpaceCreateDeviceRGB ();
data_provider = CGDataProviderCreateWithData (NULL, data, pixbuf_height * rowstride, NULL);
data_provider = CGDataProviderCreateWithData (NULL, data,
gdk_pixbuf_get_height (picture) * rowstride, NULL);
image = CGImageCreate (pixbuf_width, pixbuf_height, 8,
image = CGImageCreate (gdk_pixbuf_get_width (picture), gdk_pixbuf_get_height (picture), 8,
has_alpha ? 32 : 24, rowstride,
colorspace,
has_alpha ? kCGImageAlphaLast : 0,
@ -844,14 +868,16 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable,
void
_gdk_quartz_drawable_flush (GdkDrawable *drawable)
{
static struct timeval prev_tv;
/* intervals on the monotonic clock: setting the clock, or a 32-bit
* time_t after 2038, does not stop the flushing */
static gint64 prev_time;
static gint intervals[4];
static gint index;
struct timeval tv;
gint64 now;
gint ms;
gettimeofday (&tv, NULL);
ms = (tv.tv_sec - prev_tv.tv_sec) * 1000 + (tv.tv_usec - prev_tv.tv_usec) / 1000;
now = g_get_monotonic_time ();
ms = (gint) MIN ((now - prev_time) / 1000, G_MAXINT / 8);
intervals[index++ % 4] = ms;
if (drawable)
@ -868,11 +894,11 @@ _gdk_quartz_drawable_flush (GdkDrawable *drawable)
[window_impl->toplevel flushWindow];
}
prev_tv = tv;
prev_time = now;
}
}
else
prev_tv = tv;
prev_time = now;
}
void
@ -893,7 +919,8 @@ gdk_quartz_drawable_release_context (GdkDrawable *drawable,
if (window_impl->in_paint_rect_count == 0)
{
_gdk_quartz_drawable_flush (drawable);
[window_impl->view unlockFocus];
if (gdk_quartz_osx_version () < GDK_OSX_MOJAVE)
[window_impl->view unlockFocus];
}
}
else if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))

View file

@ -25,6 +25,7 @@
#include <sys/sysctl.h>
#include <pthread.h>
#include <unistd.h>
#include <math.h>
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
@ -225,6 +226,19 @@ _gdk_quartz_events_break_all_grabs (guint32 time)
_gdk_display_pointer_grab_update (_gdk_display, 0);
}
/* The touchpad gestures of Mac OS X 10.5.2 and later: a pinch
* (magnify) and a swipe with three fingers. Older SDKs do not know
* them; Mac OS X before 10.5.2 never sends them. */
#define GDK_QUARTZ_EVENT_MAGNIFY 30
#define GDK_QUARTZ_EVENT_SWIPE 31
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
@interface NSEvent (GdkTouchpadGestures)
- (CGFloat)magnification;
@end
#endif
static void
fixup_event (GdkEvent *event)
{
@ -250,6 +264,12 @@ append_event (GdkEvent *event,
_gdk_windowing_got_event (_gdk_display, node, event, 0);
}
static void
append_scroll_event (GdkEvent *event)
{
append_event (event, TRUE);
}
static gint
gdk_event_apply_filters (NSEvent *nsevent,
GdkEvent *event,
@ -400,11 +420,14 @@ get_event_mask_from_ns_event (NSEvent *nsevent)
case NSMouseMoved:
return GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
case NSScrollWheel:
case GDK_QUARTZ_EVENT_MAGNIFY: /* scroll steps with Ctrl */
/* Since applications that want button press events can get
* scroll events on X11 (since scroll wheel events are really
* button press events there), we need to use GDK_BUTTON_PRESS_MASK too.
*/
return GDK_SCROLL_MASK | GDK_BUTTON_PRESS_MASK;
case GDK_QUARTZ_EVENT_SWIPE: /* the back and forward buttons */
return GDK_BUTTON_PRESS_MASK;
case NSLeftMouseDragged:
return (GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK |
@ -545,6 +568,29 @@ get_toplevel_from_ns_event (NSEvent *nsevent,
* here, not very nice.
*/
_gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent));
/* Check if the event occurred on the titlebar. If it did,
* explicitly return NULL to prevent going through the
* fallback path, which could match the window that is
* directly under the titlebar.
*/
if (view_point.y < 0 &&
view_point.x >= view_frame.origin.x &&
view_point.x < view_frame.origin.x + view_frame.size.width)
{
NSView *superview = [view superview];
if (superview)
{
NSRect superview_frame = [superview frame];
int titlebar_height = superview_frame.size.height -
view_frame.size.height;
if (titlebar_height > 0 && view_point.y >= -titlebar_height)
{
return NULL;
}
}
}
}
else
{
@ -714,6 +760,48 @@ find_toplevel_under_pointer (GdkDisplay *display,
/* This function finds the correct window to send an event to, taking
* into account grabs, event propagation, and event masks.
*/
/* A native view of the program inside a GDK window (a plugin's interface,
* video, a web view) that took a mouse button; the pointer events stay
* with Cocoa until the button is up (from Ardour's YTK) */
static NSView *foreign_mouse_down_view;
/* whether the pointer is over a view of the program's own, not GDK's,
* inside @toplevel; a press there keeps the following events for it */
static gboolean
pointer_on_foreign_view (NSEvent *nsevent,
GdkWindow *toplevel)
{
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
NSView *content, *hit;
NSPoint point;
if (!impl || !impl->view || [nsevent window] != impl->toplevel)
return FALSE;
content = impl->view;
if ([[content subviews] count] == 0)
return FALSE;
point = [nsevent locationInWindow];
if ([content superview])
point = [[content superview] convertPoint:point fromView:nil];
hit = [content hitTest:point];
if (hit == nil || [hit isKindOfClass:[GdkQuartzView class]])
return FALSE;
switch ([nsevent type])
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
foreign_mouse_down_view = hit;
break;
default:
break;
}
return TRUE;
}
static GdkWindow *
find_window_for_ns_event (NSEvent *nsevent,
gint *x,
@ -745,6 +833,8 @@ find_window_for_ns_event (NSEvent *nsevent,
case NSOtherMouseUp:
case NSMouseMoved:
case NSScrollWheel:
case GDK_QUARTZ_EVENT_MAGNIFY:
case GDK_QUARTZ_EVENT_SWIPE:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
@ -752,6 +842,14 @@ find_window_for_ns_event (NSEvent *nsevent,
GdkDisplay *display;
GdkPointerGrabInfo *grab;
if (foreign_mouse_down_view)
{
if (event_type == NSLeftMouseUp || event_type == NSRightMouseUp ||
event_type == NSOtherMouseUp)
foreign_mouse_down_view = nil;
return NULL;
}
display = gdk_drawable_get_display (toplevel);
/* From the docs for XGrabPointer:
@ -845,6 +943,9 @@ find_window_for_ns_event (NSEvent *nsevent,
*y = y_tmp;
}
if (pointer_on_foreign_view (nsevent, toplevel))
return NULL;
return toplevel;
}
}
@ -857,8 +958,36 @@ find_window_for_ns_event (NSEvent *nsevent,
*/
if ([view trackingRect] == [nsevent trackingNumber])
return toplevel;
else
return NULL;
/* macOS 13 no longer sends the events of the tracking rect, but
* those of the cursor rects, which earlier ones were left out:
* they come 4 pixels outside the frame of the window (the same
* fix as GTK+ 3 and Ardour's YTK) */
if (gdk_quartz_osx_version () >= GDK_OSX_VENTURA &&
(![nsevent respondsToSelector:@selector(trackingArea)] ||
[(id) nsevent trackingArea] == nil))
{
const CGFloat border_width = 4;
NSRect frame = [[nsevent window] frame];
gboolean inside, at_edge;
frame.origin.x -= border_width;
frame.origin.y -= border_width;
frame.size.width += 2 * border_width;
frame.size.height += 2 * border_width;
inside = (screen_point.x >= frame.origin.x &&
screen_point.x <= frame.origin.x + frame.size.width &&
screen_point.y >= frame.origin.y &&
screen_point.y <= frame.origin.y + frame.size.height);
at_edge = (screen_point.x >= frame.origin.x - 1 &&
screen_point.x <= frame.origin.x + frame.size.width + 1 &&
screen_point.y >= frame.origin.y - 1 &&
screen_point.y <= frame.origin.y + frame.size.height + 1);
if ((event_type == NSMouseEntered && inside) || at_edge)
return toplevel;
}
return NULL;
case NSKeyDown:
case NSKeyUp:
@ -1004,6 +1133,72 @@ fill_scroll_event (GdkWindow *window,
event->scroll.device = _gdk_display->core_pointer;
}
/* A pinch becomes scroll steps with Ctrl and a swipe the back or
* forward button, for programs that know nothing of gestures
* (gdkevents.c); the first event goes into @event */
static gboolean
touchpad_gesture_event (GdkWindow *window,
GdkEvent *event,
NSEvent *nsevent,
gint x,
gint y,
gint x_root,
gint y_root)
{
static gdouble pinch_rest;
static NSTimeInterval pinch_time;
GdkEvent template_event;
GList *events, *l;
memset (&template_event, 0, sizeof template_event);
fill_scroll_event (window, &template_event, nsevent, x, y, x_root, y_root, GDK_SCROLL_UP);
if ([nsevent type] == GDK_QUARTZ_EVENT_MAGNIFY)
{
CGFloat magnification;
if (![nsevent respondsToSelector:@selector(magnification)])
return FALSE;
magnification = [nsevent magnification];
if (magnification <= -1)
return FALSE;
/* a pause starts a new pinch */
if ([nsevent timestamp] - pinch_time > 0.3)
pinch_rest = 0;
pinch_time = [nsevent timestamp];
events = _gdk_event_touchpad_pinch (&template_event, log1p (magnification), &pinch_rest);
}
else
{
/* deltaX is 1 for a swipe to the left: forward, as on X11 */
events = _gdk_event_touchpad_swipe (&template_event, - [nsevent deltaX]);
}
if (!events)
return FALSE;
/* the first one is @event, the window of which gets its reference
* from the caller */
*event = *(GdkEvent *) events->data;
((GdkEventPrivate *) event)->flags |= GDK_EVENT_TOUCHPAD_EMULATED;
gdk_event_free (events->data);
for (l = events->next; l; l = l->next)
{
GdkEvent *other = l->data;
/* append_event() takes a reference of its own */
g_object_unref (other->any.window);
append_event (other, TRUE);
}
g_list_free (events);
return TRUE;
}
static void
fill_key_event (GdkWindow *window,
GdkEvent *event,
@ -1387,10 +1582,10 @@ gdk_event_translate (GdkEvent *event,
return FALSE;
}
/* Also when in a manual resize, we ignore events so that these are
* pushed to GdkQuartzWindow's sendEvent handler.
/* Also when in a manual resize or move, we ignore events so that
* these are pushed to GdkQuartzWindow's sendEvent handler.
*/
if ([(GdkQuartzWindow *)nswindow isInManualResize])
if ([(GdkQuartzWindow *)nswindow isInManualResizeOrMove])
return FALSE;
/* Find the right GDK window to send the event to, taking grabs and
@ -1489,32 +1684,46 @@ gdk_event_translate (GdkEvent *event,
case NSScrollWheel:
{
float dx = [nsevent deltaX];
float dy = [nsevent deltaY];
GdkScrollDirection direction;
/* Trackpads and the Magic Mouse tell how far to scroll in
* pixels, as GTK+ 3 takes them, and in lines, which make up
* whole steps of the wheel; a plain wheel just turns, a step
* each time, as before */
static gdouble rest[2];
GdkEvent scroll;
gdouble dx = [nsevent deltaX];
gdouble dy = [nsevent deltaY];
gdouble px = 0, py = 0;
gboolean precise = FALSE;
if (dy != 0)
/* from 10.7; older SDKs do not know these */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
precise = [nsevent respondsToSelector:@selector(hasPreciseScrollingDeltas)] &&
[nsevent hasPreciseScrollingDeltas];
if (precise)
{
if (dy < 0.0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
fill_scroll_event (window, event, nsevent, x, y, x_root, y_root, direction);
px = - [nsevent scrollingDeltaX];
py = - [nsevent scrollingDeltaY];
}
else
#endif
{
dx = dx > 0 ? 1 : dx < 0 ? -1 : 0;
dy = dy > 0 ? 1 : dy < 0 ? -1 : 0;
rest[0] = rest[1] = 0;
}
if (dx != 0)
{
if (dx < 0.0)
direction = GDK_SCROLL_RIGHT;
else
direction = GDK_SCROLL_LEFT;
fill_scroll_event (window, event, nsevent, x, y, x_root, y_root, direction);
}
memset (&scroll, 0, sizeof scroll);
fill_scroll_event (window, &scroll, nsevent, x, y, x_root, y_root, GDK_SCROLL_SMOOTH);
_gdk_event_emit_scroll (event, &scroll, precise, px, py, - dx, - dy, rest,
append_scroll_event);
}
break;
case GDK_QUARTZ_EVENT_MAGNIFY:
case GDK_QUARTZ_EVENT_SWIPE:
return_val = touchpad_gesture_event (window, event, nsevent, x, y, x_root, y_root);
break;
case NSMouseExited:
if (WINDOW_IS_TOPLEVEL (window))
[[NSCursor arrowCursor] set];

View file

@ -22,6 +22,8 @@
#include "gdktypes.h"
#include "gdkprivate.h"
#include "gdkquartz.h"
#include "gdkprivate-quartz.h"
#include <stdlib.h>
GdkDisplay *_gdk_display = NULL;
GdkScreen *_gdk_screen = NULL;
@ -34,9 +36,20 @@ gdk_quartz_osx_version (void)
if (minor == GDK_OSX_UNSUPPORTED)
{
OSErr err = Gestalt (gestaltSystemVersionMinor, (SInt32*)&minor);
gint32 major = GDK_OSX_UNSUPPORTED;
OSErr err = Gestalt (gestaltSystemVersionMajor, (SInt32*)&major);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
err = Gestalt (gestaltSystemVersionMinor, (SInt32*)&minor);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
/* GTK2 encodes macOS 10.x releases by their minor version.
* Map macOS 11+ into the same sequence:
* 11 -> 16, 12 -> 17, 13 -> 18, ...
*/
if (major > 10)
minor = major + 5;
}
if (minor < GDK_OSX_MIN)
@ -46,3 +59,43 @@ gdk_quartz_osx_version (void)
else
return minor;
}
/* -1: not set, GDK_QUARTZ_COCOA_INVALIDATION or the version decide */
static gint use_cocoa_invalidation = -1;
/**
* gdk_quartz_set_use_cocoa_invalidation:
* @use: %TRUE to expose what AppKit says is being drawn
*
* From macOS 10.14 GDK exposes exactly what it and AppKit invalidated,
* not the merged rectangles of the layer-backed views; %TRUE goes back
* to those (as in Ardour's YTK). The environment variable
* GDK_QUARTZ_COCOA_INVALIDATION=1 does the same.
*/
void
gdk_quartz_set_use_cocoa_invalidation (gboolean use)
{
use_cocoa_invalidation = use != FALSE;
}
gboolean
gdk_quartz_get_use_cocoa_invalidation (void)
{
return !_gdk_quartz_use_gdk_invalidation ();
}
gboolean
_gdk_quartz_use_gdk_invalidation (void)
{
if (use_cocoa_invalidation < 0)
{
const gchar *env = g_getenv ("GDK_QUARTZ_COCOA_INVALIDATION");
if (env && *env)
use_cocoa_invalidation = atoi (env) != 0;
else
use_cocoa_invalidation = gdk_quartz_osx_version () < GDK_OSX_MOJAVE;
}
return !use_cocoa_invalidation;
}

View file

@ -145,9 +145,19 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
if (GDK_WINDOW_IMPL_QUARTZ (drawable) == GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl))
{
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
/* the screen cannot be read before 10.5 (CGWindowListCreateImage) */
return image;
#else
/* Special case for the root window. */
CGRect rect = CGRectMake (src_x, src_y, width, height);
CGImageRef root_image_ref = CGWindowListCreateImage (rect,
CGImageRef root_image_ref;
/* weakly linked where 10.4 is the oldest system */
if (CGWindowListCreateImage == NULL)
return image;
root_image_ref = CGWindowListCreateImage (rect,
kCGWindowListOptionOnScreenOnly,
kCGNullWindowID,
kCGWindowImageDefault);
@ -170,6 +180,7 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
rep = [[NSBitmapImageRep alloc] initWithCGImage: root_image_ref];
CGImageRelease (root_image_ref);
#endif
}
else
{

View file

@ -470,7 +470,8 @@ update_keymap (void)
p[0] = known_numeric_keys[i].keypad_keyval;
}
g_signal_emit_by_name (default_keymap, "keys-changed");
if (default_keymap != NULL)
g_signal_emit_by_name (default_keymap, "keys-changed");
}
static void
@ -696,7 +697,6 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
{
guint tmp_keyval;
GdkModifierType bit;
guint tmp_modifiers = 0;
g_return_val_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap), FALSE);
g_return_val_if_fail (group >= 0 && group <= 1, FALSE);
@ -716,24 +716,23 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
if (hardware_keycode < 0 || hardware_keycode >= NUM_KEYCODES)
return FALSE;
/* Check if modifiers modify the keyval */
for (bit = GDK_SHIFT_MASK; bit < GDK_BUTTON1_MASK; bit <<= 1)
{
if (translate_keysym (hardware_keycode,
(bit == GDK_MOD1_MASK) ? 0 : group,
state & ~bit,
NULL, NULL) !=
translate_keysym (hardware_keycode,
(bit == GDK_MOD1_MASK) ? 1 : group,
state | bit,
NULL, NULL))
tmp_modifiers |= bit;
}
tmp_keyval = translate_keysym (hardware_keycode, group, state, level, effective_group);
/* Check if modifiers modify the keyval */
if (consumed_modifiers)
*consumed_modifiers = tmp_modifiers;
{
guint tmp_modifiers = (state & GDK_MODIFIER_MASK);
for (bit = 1; bit <= tmp_modifiers; bit <<= 1)
{
if ((bit & tmp_modifiers) &&
translate_keysym (hardware_keycode, group, state & ~bit,
NULL, NULL) == tmp_keyval)
tmp_modifiers &= ~bit;
}
*consumed_modifiers = tmp_modifiers;
}
if (keyval)
*keyval = tmp_keyval;

View file

@ -219,4 +219,6 @@ gboolean _gdk_quartz_window_queue_antiexpose (GdkWindow *window,
/* Pixmap */
CGImageRef _gdk_pixmap_get_cgimage (GdkPixmap *pixmap);
gboolean _gdk_quartz_use_gdk_invalidation (void);
#endif /* __GDK_PRIVATE_QUARTZ_H__ */

View file

@ -54,7 +54,13 @@ typedef enum
GDK_OSX_SIERRA = 12,
GDK_OSX_HIGH_SIERRA = 13,
GDK_OSX_MOJAVE = 14,
GDK_OSX_CURRENT = 14,
GDK_OSX_CATALINA = 15,
GDK_OSX_BIG_SUR = 16,
GDK_OSX_MONTEREY = 17,
GDK_OSX_VENTURA = 18,
GDK_OSX_SONOMA = 19,
GDK_OSX_SEQUOIA = 20,
GDK_OSX_CURRENT = 20,
GDK_OSX_NEW = 99
} GdkOSXVersion;
@ -65,6 +71,8 @@ NSImage *gdk_quartz_pixbuf_to_ns_image_libgtk_only (GdkPixbuf
id gdk_quartz_drag_context_get_dragging_info_libgtk_only (GdkDragContext *context);
NSEvent *gdk_quartz_event_get_nsevent (GdkEvent *event);
GdkOSXVersion gdk_quartz_osx_version (void);
void gdk_quartz_set_use_cocoa_invalidation (gboolean use);
gboolean gdk_quartz_get_use_cocoa_invalidation (void);
GdkAtom gdk_quartz_pasteboard_type_to_atom_libgtk_only (NSString *type);
NSString *gdk_quartz_target_to_pasteboard_type_libgtk_only (const gchar *target);

View file

@ -62,6 +62,7 @@
static void gdk_screen_quartz_dispose (GObject *object);
static void gdk_screen_quartz_finalize (GObject *object);
static void gdk_screen_quartz_calculate_layout (GdkScreenQuartz *screen);
static CGFloat gdk_quartz_screen_user_space_scale (NSScreen *screen);
static void display_reconfiguration_callback (CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags,
@ -89,7 +90,7 @@ _gdk_screen_quartz_init (GdkScreenQuartz *screen_quartz)
nsscreen = [[NSScreen screens] objectAtIndex:0];
gdk_screen_set_resolution (screen,
72.0 * [nsscreen userSpaceScaleFactor]);
72.0 * gdk_quartz_screen_user_space_scale (nsscreen));
gdk_screen_quartz_calculate_layout (screen_quartz);
@ -354,6 +355,17 @@ gdk_screen_get_height (GdkScreen *screen)
return GDK_SCREEN_QUARTZ (screen)->height;
}
/* -userSpaceScaleFactor is the scale of the resolution independence of
* 10.4 to 10.6; newer systems no longer have the message, and sending
* it there throws (as Ardour found) */
static CGFloat
gdk_quartz_screen_user_space_scale (NSScreen *screen)
{
if ([screen respondsToSelector:@selector(userSpaceScaleFactor)])
return (CGFloat) [(id) screen userSpaceScaleFactor];
return 1.0;
}
static gint
get_mm_from_pixels (NSScreen *screen, int pixels)
{
@ -362,7 +374,7 @@ get_mm_from_pixels (NSScreen *screen, int pixels)
* and 25.4 is the number of millimeters per inch.
*/
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_3
float dpi = [screen userSpaceScaleFactor] * 72.0;
float dpi = gdk_quartz_screen_user_space_scale (screen) * 72.0;
#else
float dpi = 96.0 / 72.0;
#endif
@ -493,3 +505,58 @@ gdk_screen_is_composited (GdkScreen *screen)
return TRUE;
}
/* HiDPI: AppKit already draws GDK's points in the pixels of Retina
* screens (10.7 and later), sharp for paths and text; GDK coordinates
* stay the points. These scales only let pictures of more pixels be
* used (icons, see gdk_quartz_draw_pixbuf () and
* gdk_cairo_set_source_pixbuf ()); pixmaps stay at one pixel per point. */
static gint
gdk_quartz_nsscreen_get_scale (NSScreen *nsscreen)
{
CGFloat scale = 1.0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (nsscreen && [nsscreen respondsToSelector:@selector(backingScaleFactor)])
scale = [nsscreen backingScaleFactor];
#endif
return MAX ((gint) (scale + 0.5), 1);
}
gint
_gdk_windowing_drawable_get_scale (GdkDrawable *drawable)
{
CGFloat scale = 1.0;
if (GDK_IS_WINDOW (drawable))
drawable = GDK_WINDOW_OBJECT (drawable)->impl;
if (!GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
return 1;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
{
GdkWindow *toplevel = gdk_window_get_toplevel (GDK_DRAWABLE_IMPL_QUARTZ (drawable)->wrapper);
NSWindow *nswindow = toplevel ? GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl)->toplevel : nil;
if (nswindow && [nswindow respondsToSelector:@selector(backingScaleFactor)])
scale = [nswindow backingScaleFactor];
}
#endif
return MAX ((gint) (scale + 0.5), 1);
}
gint
_gdk_windowing_screen_get_monitor_scale (GdkScreen *screen,
gint monitor_num)
{
gint scale;
GDK_QUARTZ_ALLOC_POOL;
scale = gdk_quartz_nsscreen_get_scale (get_nsscreen_for_monitor (monitor_num));
GDK_QUARTZ_RELEASE_POOL;
return scale;
}

View file

@ -104,7 +104,8 @@ gdk_window_impl_quartz_get_context (GdkDrawable *drawable,
* and for widgets that send fake expose events like the arrow
* buttons in spinbuttons or the position marker in rulers.
*/
if (window_impl->in_paint_rect_count == 0)
if (window_impl->in_paint_rect_count == 0 &&
gdk_quartz_osx_version () < GDK_OSX_MOJAVE)
{
if (![window_impl->view lockFocusIfCanDraw])
return NULL;
@ -206,6 +207,7 @@ gdk_window_impl_quartz_finalize (GObject *object)
if (impl->transient_for)
g_object_unref (impl->transient_for);
impl->transient_for = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -468,7 +470,8 @@ _gdk_windowing_before_process_all_updates (void)
{
in_process_all_updates = TRUE;
NSDisableScreenUpdates ();
if (gdk_quartz_osx_version () < GDK_OSX_MOJAVE)
NSDisableScreenUpdates ();
}
void
@ -489,8 +492,9 @@ _gdk_windowing_after_process_all_updates (void)
/* 10.14 needs to be told that the view needs to be redrawn, see
* https://gitlab.gnome.org/GNOME/gtk/issues/1479 */
if (gdk_quartz_osx_version() >= GDK_OSX_MOJAVE)
[[nswindow contentView] setNeedsDisplay:YES];
if (gdk_quartz_osx_version () >= GDK_OSX_MOJAVE &&
gdk_quartz_osx_version () < GDK_OSX_BIG_SUR)
[[nswindow contentView] setNeedsDisplay:YES];
[nswindow enableFlushWindow];
[nswindow flushWindow];
[nswindow release];
@ -502,7 +506,8 @@ _gdk_windowing_after_process_all_updates (void)
in_process_all_updates = FALSE;
NSEnableScreenUpdates ();
if (gdk_quartz_osx_version () < GDK_OSX_MOJAVE)
NSEnableScreenUpdates ();
}
static void
@ -1126,7 +1131,13 @@ _gdk_windowing_update_window_sizes (GdkScreen *screen)
windows = gdk_screen_get_toplevel_windows (screen);
for (list = windows; list; list = list->next)
_gdk_quartz_window_update_position (list->data);
{
/* Offscreen windows have no NSWindow to take the position from */
if (GDK_WINDOW_TYPE (list->data) == GDK_WINDOW_OFFSCREEN)
continue;
_gdk_quartz_window_update_position (list->data);
}
g_list_free (windows);
}
@ -1198,6 +1209,12 @@ _gdk_quartz_window_destroy (GdkWindow *window,
else if (impl->view)
[impl->view removeFromSuperview];
/* The window is released when closed (and with it its view), a
* view removed from its superview is released; don't keep
* dangling pointers to them. */
impl->view = NULL;
impl->toplevel = NULL;
GDK_QUARTZ_RELEASE_POOL;
}
}
@ -1745,9 +1762,16 @@ static void
gdk_window_quartz_set_background (GdkWindow *window,
const GdkColor *color)
{
/* FIXME: We could theoretically set the background color for toplevels
* here. (Currently we draw the background before emitting expose events)
*/
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
/* The background is drawn before the expose events; this colour is
* only for a view that is drawn before its window is mapped, so that
* a dark theme does not flash light first */
if (color)
{
impl->background_color = *color;
impl->background_color_set = TRUE;
}
}
static void
@ -1937,11 +1961,29 @@ gdk_window_get_root_origin (GdkWindow *window,
gint *y)
{
GdkRectangle rect;
GdkWindow *toplevel;
GdkWindowImplQuartz *impl;
rect.x = 0;
rect.y = 0;
gdk_window_get_frame_extents (window, &rect);
/* Where gdk_window_move() puts a toplevel is the top left of its
* content (Quartz places the content rect), so that is what this
* gives, for gtk_window_get_position(): with the frame, a window
* that a program puts back where it was went up by the height of
* the title bar each time (as Ardour found) */
toplevel = gdk_window_get_effective_toplevel (window);
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl);
if (impl->toplevel)
{
NSRect ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x,
ns_rect.origin.y + ns_rect.size.height,
&rect.x, &rect.y);
}
else
gdk_window_get_frame_extents (window, &rect);
if (x)
*x = rect.x;
@ -2267,8 +2309,11 @@ gdk_window_set_transient_for (GdkWindow *window,
GdkWindowImplQuartz *window_impl;
GdkWindowImplQuartz *parent_impl;
/* an offscreen window, or a child of one, has no NSWindow to be
* transient for */
if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent) ||
!WINDOW_IS_TOPLEVEL (window))
!WINDOW_IS_TOPLEVEL (window) ||
!GDK_IS_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (parent)->impl))
return;
window_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
@ -2555,7 +2600,8 @@ gdk_window_set_modal_hint (GdkWindow *window,
!WINDOW_IS_TOPLEVEL (window))
return;
/* FIXME: Implement */
/* kept, so that gdk_window_get_modal_hint() is right (Ardour) */
((GdkWindowObject *) window)->modal_hint = modal;
}
void
@ -2838,9 +2884,45 @@ void
gdk_window_set_functions (GdkWindow *window,
GdkWMFunction functions)
{
GdkWindowImplQuartz *impl;
gboolean close, minimize, maximize;
g_return_if_fail (GDK_IS_WINDOW (window));
/* FIXME: Implement */
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL (window))
return;
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
if (!impl->toplevel)
return;
/* GDK_FUNC_ALL turns the meaning of the other bits around, as on X11 */
if (functions & GDK_FUNC_ALL)
{
close = !(functions & GDK_FUNC_CLOSE);
minimize = !(functions & GDK_FUNC_MINIMIZE);
maximize = !(functions & GDK_FUNC_MAXIMIZE);
}
else
{
close = (functions & GDK_FUNC_CLOSE) != 0;
minimize = (functions & GDK_FUNC_MINIMIZE) != 0;
maximize = (functions & GDK_FUNC_MAXIMIZE) != 0;
}
/* The buttons of the title bar, so that gtk_window_set_deletable()
* works. Enabling and disabling them works from Mac OS X 10.2 on and
* leaves the style of the window (and whether it can be resized, which
* the geometry hints decide) alone; a window without a title bar has
* no buttons, so nothing happens there. */
GDK_QUARTZ_ALLOC_POOL;
[[impl->toplevel standardWindowButton:NSWindowCloseButton] setEnabled:close];
[[impl->toplevel standardWindowButton:NSWindowMiniaturizeButton] setEnabled:minimize];
[[impl->toplevel standardWindowButton:NSWindowZoomButton] setEnabled:maximize];
GDK_QUARTZ_RELEASE_POOL;
}
gboolean
@ -2996,6 +3078,12 @@ gdk_window_fullscreen (GdkWindow *window)
!WINDOW_IS_TOPLEVEL (window))
return;
/* In the full screen of the system already (the green button, 10.7
* and newer): changing the decorations there throws (as Ardour
* found). The bit of NSFullScreenWindowMask, for older SDKs. */
if ([impl->toplevel styleMask] & (1 << 14))
return;
geometry = get_fullscreen_geometry (window);
if (!geometry)
{

View file

@ -60,6 +60,10 @@ struct _GdkWindowImplQuartz
GList *sorted_children;
GdkRegion *needs_display_region;
/* drawn before the first expose (from Ardour's YTK) */
GdkColor background_color;
gboolean background_color_set;
};
struct _GdkWindowImplQuartzClass

310
gdk/rgbsimdbench.c Normal file
View file

@ -0,0 +1,310 @@
/* rgbsimdbench: checks and times GdkRGB's vector kernels on this machine
*
* Every kernel of every instruction set the CPU has is run against the
* C code it stands in for: first on random data, which must come out
* the same, then for speed. The table at the end shows millions of
* pixels per second; the fastest of each row is marked.
*
* make -C gdk rgbsimdbench && gdk/rgbsimdbench
*
* GDK_RGB_SIMD="op=set,..." tries a choice in a running program.
*
* 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 of the License, or (at your option) any later version.
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "gdkrgbsimd.h"
#define WIDTH 256
#define ROWS 64
typedef gint (*Kernel) (gpointer out, gconstpointer in, gint n);
static guint32 seed = 1;
static guint
rnd (void)
{
seed = seed * 1103515245 + 12345;
return seed >> 8;
}
static inline guint
blend8 (guint a, guint s, guint d)
{
guint t = a * s + (255 - a) * d + 0x80;
return (t + (t >> 8)) >> 8;
}
/* The C code of GdkRGB and gdk_cairo_set_source_pixbuf(), as plain as
* there, for one pixel at position i */
static void
c_pixel (gint op, gpointer out, const guchar *s, gint i)
{
guint32 *o32 = (guint32 *) out + i;
guint16 *o16 = (guint16 *) out + i;
guint r, g, b;
switch (op)
{
case 0: /* rgb_to_x888 */
case 1: /* rgbx_to_x888 */
*o32 = 0xff000000 | (s[0] << 16) | (s[1] << 8) | s[2];
break;
case 2: /* rgb_to_565 */
*o16 = ((s[0] & 0xf8) << 8) | ((s[1] & 0xfc) << 3) | (s[2] >> 3);
break;
case 3: /* rgb_to_555 */
*o16 = 0x8000 | ((s[0] & 0xf8) << 7) | ((s[1] & 0xf8) << 2) | (s[2] >> 3);
break;
case 4: /* composite_x888 */
if (s[3] == 0)
break;
if (s[3] == 255)
*o32 = 0xff000000 | (s[0] << 16) | (s[1] << 8) | s[2];
else
*o32 = 0xff000000 | (blend8 (s[3], s[0], (*o32 >> 16) & 0xff) << 16) |
(blend8 (s[3], s[1], (*o32 >> 8) & 0xff) << 8) | blend8 (s[3], s[2], *o32 & 0xff);
break;
case 5: /* composite_565 */
if (s[3] == 0)
break;
r = *o16 >> 11, g = (*o16 >> 5) & 0x3f, b = *o16 & 0x1f;
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
g = blend8 (s[3], s[1], (g << 2) | (g >> 4));
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
*o16 = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
break;
case 6: /* composite_555 */
if (s[3] == 0)
break;
r = (*o16 >> 10) & 0x1f, g = (*o16 >> 5) & 0x1f, b = *o16 & 0x1f;
r = blend8 (s[3], s[0], (r << 3) | (r >> 2));
g = blend8 (s[3], s[1], (g << 3) | (g >> 2));
b = blend8 (s[3], s[2], (b << 3) | (b >> 2));
*o16 = 0x8000 | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
break;
case 7: /* rgba_to_argb */
*o32 = ((guint32) s[3] << 24) | (blend8 (s[3], s[0], 0) << 16) |
(blend8 (s[3], s[1], 0) << 8) | blend8 (s[3], s[2], 0);
break;
}
}
static gint
in_bytes (gint op)
{
return op == 0 || op == 2 || op == 3 ? 3 : 4;
}
static gint
out_bytes (gint op)
{
return op == 2 || op == 3 || op == 5 || op == 6 ? 2 : 4;
}
static void
run_c (gint op, gpointer out, const guchar *in, gint n)
{
gint i, step = in_bytes (op);
for (i = 0; i < n; i++)
c_pixel (op, out, in + i * step, i);
}
static void
run (gint op, Kernel kernel, gpointer out, const guchar *in, gint n)
{
gint done = kernel ? kernel (out, in, n) : 0, i, step = in_bytes (op);
/* the C code does the rest of the row */
for (i = done; i < n; i++)
c_pixel (op, out, in + i * step, i);
}
/* Source rows: for the alpha either like icons, mostly nothing or
* everything, or like soft shadows, everything in between */
static void
fill_source (guchar *in, gint op, gboolean icons)
{
gint i, n = ROWS * WIDTH * in_bytes (op);
for (i = 0; i < n; i++)
in[i] = rnd ();
if (in_bytes (op) == 4)
for (i = 3; i < n; i += 4)
{
guint k = rnd () % 10;
if (icons && k < 4)
in[i] = 0;
else if (icons && k < 8)
in[i] = 255;
}
}
static gboolean
check (gint op, Kernel kernel)
{
static guchar in[WIDTH * 4 + 16], a[WIDTH * 4 + 16], b[WIDTH * 4 + 16];
gint t, i;
for (t = 0; t < 2000; t++)
{
gint n = rnd () % WIDTH, ia = rnd () % 16, oa = (rnd () % 8) * 2;
for (i = 0; i < (gint) sizeof in; i++)
in[i] = rnd ();
for (i = 3; i < (gint) sizeof in; i += 4)
if (rnd () % 3 == 0)
in[i] = rnd () % 2 ? 0 : 255;
for (i = 0; i < (gint) sizeof a; i++)
a[i] = b[i] = rnd ();
run_c (op, a + oa, in + ia, n);
run (op, kernel, b + oa, in + ia, n);
if (memcmp (a, b, sizeof a) != 0)
return FALSE;
}
return TRUE;
}
/* Millions of pixels per second */
static gdouble
measure (gint op, Kernel kernel, gboolean c_only, gboolean icons)
{
static guchar in[ROWS * WIDTH * 4], out[ROWS * WIDTH * 4];
gint64 start, elapsed;
gint rounds = 0, y;
seed = 7;
fill_source (in, op, icons);
for (y = 0; y < (gint) sizeof out; y++)
out[y] = rnd ();
start = g_get_monotonic_time ();
do
{
for (y = 0; y < ROWS; y++)
{
const guchar *src = in + y * WIDTH * in_bytes (op);
guchar *dst = out + y * WIDTH * out_bytes (op);
if (c_only)
run_c (op, dst, src, WIDTH);
else
run (op, kernel, dst, src, WIDTH);
}
rounds++;
elapsed = g_get_monotonic_time () - start;
}
while (elapsed < 300000);
return (gdouble) rounds * ROWS * WIDTH / elapsed;
}
static void
print_cpu (void)
{
gchar *info = NULL, **lines;
gint i, shown = 0;
if (!g_file_get_contents ("/proc/cpuinfo", &info, NULL, NULL))
return;
lines = g_strsplit (info, "\n", -1);
for (i = 0; lines[i] && shown < 4; i++)
if (g_str_has_prefix (lines[i], "model name") || g_str_has_prefix (lines[i], "cpu\t") ||
g_str_has_prefix (lines[i], "vendor_id") || g_str_has_prefix (lines[i], "flags") ||
g_str_has_prefix (lines[i], "Features") || g_str_has_prefix (lines[i], "CPU part") ||
g_str_has_prefix (lines[i], "Hardware"))
{
printf ("%.150s\n", lines[i]);
shown++;
}
g_strfreev (lines);
g_free (info);
}
int
main (int argc, char **argv)
{
const GdkRgbSimdSet *sets;
const GdkRgbSimdOp *ops;
const GdkRgbSimd *chosen;
gint n_sets, n_ops, s, k, pass;
gboolean all_good = TRUE;
print_cpu ();
sets = _gdk_rgb_simd_sets (&n_sets);
ops = _gdk_rgb_simd_ops (&n_ops);
chosen = _gdk_rgb_simd_get ();
printf ("\nMillions of pixels per second, * the fastest, < what GDK takes now\n\n");
printf ("%-22s %8s", "", "c");
for (s = 0; s < n_sets; s++)
printf (" %9s", sets[s].name);
printf ("\n");
for (k = 0; k < n_ops; k++)
for (pass = 0; pass < (in_bytes (k) == 4 && k != 1 ? 2 : 1); pass++)
{
gdouble speed[16], best = 0;
const gchar *mark[16];
gchar label[64];
Kernel now = G_STRUCT_MEMBER (Kernel, chosen, ops[k].offset);
g_snprintf (label, sizeof label, "%s%s", ops[k].name,
in_bytes (k) == 4 && k != 1 ? (pass ? " soft" : " icons") : "");
speed[0] = measure (k, NULL, TRUE, !pass);
best = speed[0];
for (s = 0; s < n_sets; s++)
{
GdkRgbSimd set;
Kernel kernel;
memset (&set, 0, sizeof set);
sets[s].init (&set);
kernel = G_STRUCT_MEMBER (Kernel, &set, ops[k].offset);
speed[s + 1] = -1;
mark[s + 1] = " ";
if (!kernel)
continue;
if (!check (k, kernel))
{
printf ("%s of %s does not give what the C code does!\n", ops[k].name, sets[s].name);
all_good = FALSE;
continue;
}
speed[s + 1] = measure (k, kernel, FALSE, !pass);
if (speed[s + 1] > best)
best = speed[s + 1];
if (kernel == now)
mark[s + 1] = "<";
}
printf ("%-22s %7.1f%s", label, speed[0], speed[0] == best ? "*" : (now ? " " : "<"));
for (s = 0; s < n_sets; s++)
{
if (speed[s + 1] < 0)
printf (" %9s", "-");
else
printf (" %8.1f%s", speed[s + 1], speed[s + 1] == best ? "*" : mark[s + 1]);
}
printf ("\n");
}
if (!all_good)
printf ("\nSome kernels are wrong on this machine; please send this output.\n");
return all_good ? 0 : 1;
}

View file

@ -1137,7 +1137,6 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivateWin32 *private;
GdkVisual *visual;
gint i;
gint nremaining = 0;
@ -1147,8 +1146,6 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
g_return_val_if_fail (colors != NULL, FALSE);
g_return_val_if_fail (success != NULL, ncolors);
private = GDK_WIN32_COLORMAP_DATA (colormap);
for (i = 0; i < ncolors; i++)
success[i] = FALSE;

View file

@ -66,6 +66,7 @@ hcursor_from_type (GdkCursorType cursor_type)
gint i, j, x, y, ofs;
HCURSOR rv;
gint w, h;
gint s = _gdk_win32_scale;
guchar *and_plane, *xor_plane;
if (cursor_type != GDK_BLANK_CURSOR)
@ -84,6 +85,12 @@ hcursor_from_type (GdkCursorType cursor_type)
w = GetSystemMetrics (SM_CXCURSOR);
h = GetSystemMetrics (SM_CYCURSOR);
/* HiDPI: each pixel of the X cursor as s x s pixels of Windows */
if (cursor_type != GDK_BLANK_CURSOR && s > 1)
{
w = MAX (w, (cursors[i].width * s + 31) / 32 * 32);
h = MAX (h, cursors[i].height * s);
}
and_plane = g_malloc ((w/8) * h);
memset (and_plane, 0xff, (w/8) * h);
@ -96,16 +103,18 @@ hcursor_from_type (GdkCursorType cursor_type)
#define SET_BIT(v,b) (v |= (1 << b))
#define RESET_BIT(v,b) (v &= ~(1 << b))
for (j = 0, y = 0; y < cursors[i].height && y < h ; y++)
for (y = 0; y < cursors[i].height * s && y < h ; y++)
{
ofs = (y * w) / 8;
j = y * cursors[i].width;
for (x = 0; x < cursors[i].width && x < w ; x++, j++)
for (x = 0; x < cursors[i].width * s && x < w ; x++)
{
gint pofs = ofs + x / 8;
guchar data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
gint bit = 7 - (j % cursors[i].width) % 8;
guchar data;
gint bit = 7 - x % 8;
j = (y / s) * cursors[i].width + x / s;
data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
if (data)
{
@ -119,7 +128,9 @@ hcursor_from_type (GdkCursorType cursor_type)
#undef SET_BIT
#undef RESET_BIT
rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
rv = CreateCursor (_gdk_app_hmodule,
cursors[i].hotx * s + s / 2,
cursors[i].hoty * s + s / 2,
w, h, and_plane, xor_plane);
}
else
@ -210,14 +221,24 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
g_return_val_if_fail (source_impl->width == mask_impl->width
&& source_impl->height == mask_impl->height,
NULL);
width = source_impl->width;
height = source_impl->height;
g_return_val_if_fail (source_impl->scale == mask_impl->scale, NULL);
/* HiDPI: the bits are in pixels of Windows, and so is the cursor */
width = source_impl->width * MAX (source_impl->scale, 1);
height = source_impl->height * MAX (source_impl->scale, 1);
x = x * MAX (source_impl->scale, 1) + MAX (source_impl->scale, 1) / 2;
y = y * MAX (source_impl->scale, 1) + MAX (source_impl->scale, 1) / 2;
cursor_width = GetSystemMetrics (SM_CXCURSOR);
cursor_height = GetSystemMetrics (SM_CYCURSOR);
g_return_val_if_fail (width <= cursor_width && height <= cursor_height,
g_return_val_if_fail (source_impl->width <= cursor_width / _gdk_win32_scale &&
source_impl->height <= cursor_height / _gdk_win32_scale,
NULL);
/* a cursor as large as the scaled bits when Windows' size is not */
cursor_width = MAX (cursor_width, (width + 31) / 32 * 32);
cursor_height = MAX (cursor_height, height);
residue = (1 << ((8-(width%8))%8)) - 1;
source_bits = source_impl->bits;
@ -228,7 +249,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
NULL);
source_bpl = ((width - 1)/32 + 1)*4;
mask_bpl = ((mask_impl->width - 1)/32 + 1)*4;
mask_bpl = source_bpl;
GDK_NOTE (CURSOR, {
g_print ("gdk_cursor_new_from_pixmap: source=%p:\n",
@ -626,7 +647,27 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
g_return_val_if_fail (0 <= x && x < gdk_pixbuf_get_width (pixbuf), NULL);
g_return_val_if_fail (0 <= y && y < gdk_pixbuf_get_height (pixbuf), NULL);
hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
if (_gdk_win32_scale > 1)
{
/* HiDPI: the cursor in pixels of Windows, from the picture made
* for it if there is one */
GdkPixbuf *hires = _gdk_pixbuf_get_hires (pixbuf, _gdk_win32_scale);
gint s = _gdk_win32_scale;
if (hires)
g_object_ref (hires);
else
hires = gdk_pixbuf_scale_simple (pixbuf,
gdk_pixbuf_get_width (pixbuf) * s,
gdk_pixbuf_get_height (pixbuf) * s,
GDK_INTERP_NEAREST);
if (!hires)
return NULL;
hcursor = _gdk_win32_pixbuf_to_hcursor (hires, x * s + s / 2, y * s + s / 2);
g_object_unref (hires);
}
else
hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
if (!hcursor)
return NULL;
return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
@ -653,7 +694,8 @@ gdk_display_get_default_cursor_size (GdkDisplay *display)
{
g_return_val_if_fail (display == _gdk_display, 0);
return MIN (GetSystemMetrics (SM_CXCURSOR), GetSystemMetrics (SM_CYCURSOR));
/* in pixels of GDK (HiDPI) */
return MAX (MIN (GetSystemMetrics (SM_CXCURSOR), GetSystemMetrics (SM_CYCURSOR)) / _gdk_win32_scale, 1);
}
void
@ -663,10 +705,11 @@ gdk_display_get_maximal_cursor_size (GdkDisplay *display,
{
g_return_if_fail (display == _gdk_display);
/* in pixels of GDK (HiDPI) */
if (width)
*width = GetSystemMetrics (SM_CXCURSOR);
*width = MAX (GetSystemMetrics (SM_CXCURSOR) / _gdk_win32_scale, 1);
if (height)
*height = GetSystemMetrics (SM_CYCURSOR);
*height = MAX (GetSystemMetrics (SM_CYCURSOR) / _gdk_win32_scale, 1);
}

View file

@ -91,7 +91,7 @@ enum_monitor (HMONITOR hmonitor,
monitor = _gdk_monitors + *index;
monitor_info.cbSize = sizeof (MONITORINFOEX);
monitor_info.cbSize = sizeof (MONITORINFOEXA2);
GetMonitorInfoA (hmonitor, (MONITORINFO *) &monitor_info);
#ifndef MONITORINFOF_PRIMARY
@ -159,11 +159,17 @@ _gdk_monitor_init (void)
GDK_NOTE (MISC, g_print ("Multi-monitor offset: (%d,%d)\n",
_gdk_offset_x, _gdk_offset_y));
/* Translate monitor coords into GDK coordinate space */
/* Translate monitor coords into GDK coordinate space, also in its
* pixels (HiDPI) */
for (i = 0; i < _gdk_num_monitors; i++)
{
_gdk_monitors[i].rect.x += _gdk_offset_x;
_gdk_monitors[i].rect.y += _gdk_offset_y;
GdkRectangle *r = &_gdk_monitors[i].rect;
gint x2 = r->x + r->width + _gdk_offset_x, y2 = r->y + r->height + _gdk_offset_y;
r->x = _gdk_win32_unscale (r->x + _gdk_offset_x);
r->y = _gdk_win32_unscale (r->y + _gdk_offset_y);
r->width = _gdk_win32_unscale (x2) - r->x;
r->height = _gdk_win32_unscale (y2) - r->y;
GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d@%+d%+d\n",
i, _gdk_monitors[i].rect.width,
_gdk_monitors[i].rect.height,
@ -183,8 +189,8 @@ _gdk_monitor_init (void)
ReleaseDC (NULL, hDC);
_gdk_monitors[0].rect.x = 0;
_gdk_monitors[0].rect.y = 0;
_gdk_monitors[0].rect.width = GetSystemMetrics (SM_CXSCREEN);
_gdk_monitors[0].rect.height = GetSystemMetrics (SM_CYSCREEN);
_gdk_monitors[0].rect.width = _gdk_win32_unscale (GetSystemMetrics (SM_CXSCREEN));
_gdk_monitors[0].rect.height = _gdk_win32_unscale (GetSystemMetrics (SM_CYSCREEN));
_gdk_offset_x = 0;
_gdk_offset_y = 0;
#endif
@ -216,6 +222,24 @@ gdk_display_open (const gchar *display_name)
_gdk_monitor_init ();
_gdk_visual_init ();
/* HiDPI: fonts are laid out in pixels of GDK and drawn in those of
* Windows; widths rounded to GDK's pixels would space the letters
* unevenly */
if (_gdk_win32_scale > 1)
{
cairo_font_options_t *options = cairo_font_options_create ();
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
gdk_screen_set_font_options (_gdk_screen, options);
cairo_font_options_destroy (options);
}
/* HiDPI: the resolution of fonts in pixels of GDK; Pango would take
* that of Windows, in its pixels (GTK+ sets it from gtk-xft-dpi only
* on X11) */
if (_gdk_win32_font_dpi () > 0)
gdk_screen_set_resolution (_gdk_screen, _gdk_win32_font_dpi ());
gdk_screen_set_default_colormap (_gdk_screen,
gdk_screen_get_system_colormap (_gdk_screen));
_gdk_windowing_window_init (_gdk_screen);
@ -505,10 +529,11 @@ gdk_display_request_selection_notification (GdkDisplay *display,
{
static HWND hwndViewer = NULL;
gboolean ret = FALSE;
gchar *selection_name = gdk_atom_name (selection);
GDK_NOTE (DND,
g_print ("gdk_display_request_selection_notification (..., %s)",
gdk_atom_name (selection)));
selection_name));
if (selection == GDK_SELECTION_CLIPBOARD ||
selection == GDK_SELECTION_PRIMARY)
@ -526,6 +551,8 @@ gdk_display_request_selection_notification (GdkDisplay *display,
ret = FALSE;
}
g_free (selection_name);
GDK_NOTE (DND, g_print (" -> %s\n", ret ? "TRUE" : "FALSE"));
return ret;
}

View file

@ -124,16 +124,17 @@ static gpointer parent_class = NULL;
static gboolean use_ole2_dnd = FALSE;
G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
/* the name G_DEFINE_TYPE_WITH_PRIVATE looks for */
typedef GdkDragContextPrivateWin32 GdkDragContextPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
static void
gdk_drag_context_init (GdkDragContext *dragcontext)
{
GdkDragContextPrivateWin32 *private;
private = G_TYPE_INSTANCE_GET_PRIVATE (dragcontext,
GDK_TYPE_DRAG_CONTEXT,
GdkDragContextPrivateWin32);
private = gdk_drag_context_get_instance_private (dragcontext);
dragcontext->windowing_data = private;
@ -159,8 +160,6 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_drag_context_finalize;
g_type_class_add_private (object_class, sizeof (GdkDragContextPrivateWin32));
}
static void
@ -230,12 +229,10 @@ gdk_drag_context_find (gboolean is_source,
{
GList *tmp_list = contexts;
GdkDragContext *context;
GdkDragContextPrivateWin32 *private;
while (tmp_list)
{
context = (GdkDragContext *)tmp_list->data;
private = PRIVATE_DATA (context);
if ((!context->is_source == !is_source) &&
((source == NULL) || (context->source_window && (context->source_window == source))) &&
@ -454,8 +451,8 @@ dnd_event_put (GdkEventType type,
e.dnd.send_event = FALSE;
e.dnd.context = context;
e.dnd.time = GDK_CURRENT_TIME;
e.dnd.x_root = pt.x + _gdk_offset_x;
e.dnd.y_root = pt.x + _gdk_offset_y;
e.dnd.x_root = GDK_WIN32_SCREEN_TO_ROOT_X (pt.x);
e.dnd.y_root = GDK_WIN32_SCREEN_TO_ROOT_Y (pt.y);
g_object_ref (e.dnd.context);
if (e.dnd.window != NULL)
@ -856,7 +853,6 @@ idataobject_getdata (LPDATAOBJECT This,
LPSTGMEDIUM pMedium)
{
data_object *ctx = (data_object *) This;
GdkAtom target;
HRESULT hr;
GdkEvent e;
@ -875,7 +871,6 @@ idataobject_getdata (LPDATAOBJECT This,
active_pFormatEtc = pFormatEtc;
active_pMedium = pMedium;
target = GDK_TARGET_STRING;
e.type = GDK_SELECTION_REQUEST;
e.selection.window = ctx->context->source_window;
@ -1477,8 +1472,8 @@ gdk_dropfiles_filter (GdkXEvent *xev,
DragQueryPoint (hdrop, &pt);
ClientToScreen (msg->hwnd, &pt);
event->dnd.x_root = pt.x + _gdk_offset_x;
event->dnd.y_root = pt.y + _gdk_offset_y;
event->dnd.x_root = GDK_WIN32_SCREEN_TO_ROOT_X (pt.x);
event->dnd.y_root = GDK_WIN32_SCREEN_TO_ROOT_Y (pt.y);
event->dnd.time = _gdk_win32_get_next_tick (msg->time);
nfiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
@ -1551,8 +1546,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
g_free (fileName);
g_string_append (result, "\015\012");
}
_gdk_dropfiles_store (result->str);
g_string_free (result, FALSE);
_gdk_dropfiles_store (g_string_free (result, FALSE));
DragFinish (hdrop);
@ -1664,14 +1658,12 @@ local_send_enter (GdkDragContext *context,
guint32 time)
{
GdkEvent tmp_event;
GdkDragContextPrivateWin32 *private;
GdkDragContext *new_context;
GDK_NOTE (DND, g_print ("local_send_enter: context=%p current_dest_drag=%p\n",
context,
current_dest_drag));
private = PRIVATE_DATA (context);
if (current_dest_drag != NULL)
{
@ -1736,8 +1728,8 @@ local_send_motion (GdkDragContext *context,
tmp_event.dnd.x_root = x_root;
tmp_event.dnd.y_root = y_root;
PRIVATE_DATA (current_dest_drag)->last_pt.x = x_root - _gdk_offset_x;
PRIVATE_DATA (current_dest_drag)->last_pt.y = y_root - _gdk_offset_y;
PRIVATE_DATA (current_dest_drag)->last_pt.x = GDK_WIN32_ROOT_TO_SCREEN_X (x_root);
PRIVATE_DATA (current_dest_drag)->last_pt.y = GDK_WIN32_ROOT_TO_SCREEN_Y (y_root);
PRIVATE_DATA (context)->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
@ -1770,8 +1762,8 @@ local_send_drop (GdkDragContext *context,
tmp_event.dnd.context = current_dest_drag;
tmp_event.dnd.time = GDK_CURRENT_TIME;
tmp_event.dnd.x_root = private->last_pt.x + _gdk_offset_x;
tmp_event.dnd.y_root = private->last_pt.y + _gdk_offset_y;
tmp_event.dnd.x_root = GDK_WIN32_SCREEN_TO_ROOT_X (private->last_pt.x);
tmp_event.dnd.y_root = GDK_WIN32_SCREEN_TO_ROOT_Y (private->last_pt.y);
current_dest_drag = NULL;
@ -2023,8 +2015,8 @@ gdk_drag_find_window_for_screen (GdkDragContext *context,
GdkWindow *dw;
find_window_enum_arg a;
a.x = x_root - _gdk_offset_x;
a.y = y_root - _gdk_offset_y;
a.x = GDK_WIN32_ROOT_TO_SCREEN_X (x_root);
a.y = GDK_WIN32_ROOT_TO_SCREEN_Y (y_root);
a.ignore = drag_window ? GDK_WINDOW_HWND (drag_window) : NULL;
a.result = NULL;
@ -2154,8 +2146,8 @@ gdk_drag_motion (GdkDragContext *context,
/* Send a drag-motion event */
private->last_pt.x = x_root - _gdk_offset_x;
private->last_pt.y = y_root - _gdk_offset_y;
private->last_pt.x = GDK_WIN32_ROOT_TO_SCREEN_X (x_root);
private->last_pt.y = GDK_WIN32_ROOT_TO_SCREEN_Y (y_root);
if (context->dest_window)
{
@ -2236,13 +2228,11 @@ gdk_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time)
{
GdkDragContextPrivateWin32 *private;
GdkDragContext *src_context;
GdkEvent tmp_event;
g_return_if_fail (context != NULL);
private = PRIVATE_DATA (context);
GDK_NOTE (DND, g_print ("gdk_drag_status: %s\n"
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
@ -2306,7 +2296,6 @@ gdk_drop_finish (GdkDragContext *context,
gboolean success,
guint32 time)
{
GdkDragContextPrivateWin32 *private;
GdkDragContext *src_context;
GdkEvent tmp_event;
@ -2314,7 +2303,6 @@ gdk_drop_finish (GdkDragContext *context,
GDK_NOTE (DND, g_print ("gdk_drop_finish\n"));
private = PRIVATE_DATA (context);
if (!use_ole2_dnd)
{

View file

@ -689,11 +689,20 @@ generic_draw (GdkDrawable *drawable,
* the areas where mask is one. (It is filled with said pattern.)
*/
GDI_CALL (MaskBlt, (hdc, region->extents.x1, region->extents.y1,
width, height,
tile_hdc, 0, 0,
GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0,
MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D)));
/* the mask's bits are in pixels of Windows, so all is (HiDPI) */
{
gint s = _gdk_win32_scale;
_gdk_win32_dc_set_scale (hdc, 1);
_gdk_win32_dc_set_scale (tile_hdc, 1);
GDI_CALL (MaskBlt, (hdc, region->extents.x1 * s, region->extents.y1 * s,
width * s, height * s,
tile_hdc, 0, 0,
GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0,
MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D)));
_gdk_win32_dc_set_scale (tile_hdc, s);
_gdk_win32_dc_set_scale (hdc, _gdk_win32_drawable_scale (drawable));
}
/* Cleanup */
gdk_win32_hdc_release (mask_pixmap, mask_gc, blitting_mask);
@ -1386,6 +1395,63 @@ gdk_win32_draw_lines (GdkDrawable *drawable,
g_free (pts);
}
/* HiDPI: the scale of a drawable, pixels of its bitmap or window for
* one of GDK */
gint
_gdk_win32_drawable_scale (GdkDrawable *drawable)
{
if (GDK_IS_PIXMAP (drawable))
drawable = GDK_PIXMAP_OBJECT (drawable)->impl;
if (GDK_IS_PIXMAP_IMPL_WIN32 (drawable))
return MAX (GDK_PIXMAP_IMPL_WIN32 (drawable)->scale, 1);
return _gdk_win32_scale;
}
/* HiDPI: a BitBlt () in pixels of GDK from a DC of @ss pixels per pixel
* of GDK to one with @ds, done in the pixels themselves; the DCs keep
* the mapping they had */
static BOOL
blit_scaled (HDC hdc,
gint ds,
gint xdest,
gint ydest,
gint width,
gint height,
HDC srcdc,
gint ss,
gint xsrc,
gint ysrc,
DWORD rop)
{
BOOL ok;
if (_gdk_win32_scale <= 1)
return BitBlt (hdc, xdest, ydest, width, height, srcdc, xsrc, ysrc, rop);
_gdk_win32_dc_set_scale (hdc, 1);
if (srcdc != hdc)
_gdk_win32_dc_set_scale (srcdc, 1);
if (ds == ss)
ok = BitBlt (hdc, xdest * ds, ydest * ds, width * ds, height * ds,
srcdc, xsrc * ss, ysrc * ss, rop);
else
{
/* a GdkImage, which has GDK's pixels: the nearest pixel, as
* everywhere else in GDK */
int old_mode = SetStretchBltMode (hdc, COLORONCOLOR);
ok = StretchBlt (hdc, xdest * ds, ydest * ds, width * ds, height * ds,
srcdc, xsrc * ss, ysrc * ss, width * ss, height * ss, rop);
SetStretchBltMode (hdc, old_mode);
}
_gdk_win32_dc_set_scale (hdc, ds);
return ok;
}
static void
blit_from_pixmap (gboolean use_fg_bg,
GdkDrawableImplWin32 *dest,
@ -1503,8 +1569,10 @@ blit_from_pixmap (gboolean use_fg_bg,
}
if (ok)
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)) &&
if (!blit_scaled (hdc, _gdk_win32_drawable_scale (GDK_DRAWABLE (dest)),
xdest, ydest, width, height,
srcdc, MAX (src->scale, 1), xsrc, ysrc,
rop2_to_rop3 (gcwin32->rop2)) &&
GetLastError () != ERROR_INVALID_HANDLE)
WIN32_GDI_FAILED ("BitBlt");
@ -1549,15 +1617,23 @@ blit_inside_drawable (HDC hdc,
HRGN updateRgn;
GdkRegion *update_region;
clipRect.left = xdest;
clipRect.top = ydest;
clipRect.right = xdest + width;
clipRect.bottom = ydest + height;
BOOL scrolled;
/* in pixels of Windows (HiDPI) */
clipRect.left = GDK_WIN32_SC (xdest);
clipRect.top = GDK_WIN32_SC (ydest);
clipRect.right = GDK_WIN32_SC (xdest + width);
clipRect.bottom = GDK_WIN32_SC (ydest + height);
SetRectEmpty (&emptyRect);
updateRgn = CreateRectRgnIndirect (&emptyRect);
if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc, NULL, &clipRect, updateRgn, NULL))
_gdk_win32_dc_set_scale (hdc, 1);
scrolled = ScrollDC (hdc, GDK_WIN32_SC (xdest - xsrc), GDK_WIN32_SC (ydest - ysrc),
NULL, &clipRect, updateRgn, NULL);
_gdk_win32_dc_set_scale (hdc, _gdk_win32_scale);
if (!scrolled)
WIN32_GDI_FAILED ("ScrollDC");
else
{
@ -1573,13 +1649,17 @@ blit_inside_drawable (HDC hdc,
}
else
{
GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
hdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
gint s = _gdk_win32_drawable_scale (GDK_DRAWABLE (src));
if (!blit_scaled (hdc, s, xdest, ydest, width, height,
hdc, s, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)))
WIN32_GDI_FAILED ("BitBlt");
}
}
static void
blit_from_window (HDC hdc,
GdkDrawableImplWin32 *dest,
GdkGCWin32 *gcwin32,
GdkDrawableImplWin32 *src,
gint xsrc,
@ -1615,8 +1695,11 @@ blit_from_window (HDC hdc,
g_print ("blit_from_window: realized %d\n", k));
}
GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
if (!blit_scaled (hdc, _gdk_win32_drawable_scale (GDK_DRAWABLE (dest)),
xdest, ydest, width, height,
srcdc, _gdk_win32_scale, xsrc, ysrc,
rop2_to_rop3 (gcwin32->rop2)))
WIN32_GDI_FAILED ("BitBlt");
if (holdpal != NULL)
GDI_CALL (SelectPalette, (srcdc, holdpal, FALSE));
@ -1656,8 +1739,9 @@ _gdk_win32_blit (gboolean use_fg_bg,
if (src == ((GdkWindowObject *)_gdk_root)->impl)
{
GDK_NOTE (DRAW, g_print ("... offsetting src coords\n"));
xsrc -= _gdk_offset_x;
ysrc -= _gdk_offset_y;
/* in pixels of GDK (HiDPI) */
xsrc -= _gdk_win32_unscale (_gdk_offset_x);
ysrc -= _gdk_win32_unscale (_gdk_offset_y);
}
if (GDK_IS_DRAWABLE_IMPL_WIN32 (src))
@ -1728,6 +1812,7 @@ _gdk_win32_blit (gboolean use_fg_bg,
else if (comb != NULLREGION)
{
OffsetRgn (outside_rgn, xdest, ydest);
outside_rgn = _gdk_win32_hrgn_scale (outside_rgn);
GDK_NOTE (DRAW, (GetRgnBox (outside_rgn, &r),
g_print ("... InvalidateRgn "
"bbox: %ldx%ld@%+ld%+ld\n",
@ -1772,7 +1857,7 @@ _gdk_win32_blit (gboolean use_fg_bg,
(GdkPixmapImplWin32 *) src_impl, gc,
xsrc, ysrc, xdest, ydest, width, height);
else
blit_from_window (hdc, GDK_GC_WIN32 (gc), src_impl,
blit_from_window (hdc, draw_impl, GDK_GC_WIN32 (gc), src_impl,
xsrc, ysrc, xdest, ydest, width, height);
gdk_win32_hdc_release (&draw_impl->parent_instance, gc, GDK_GC_FOREGROUND);
@ -1931,6 +2016,16 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
surface = cairo_win32_surface_create (hdc);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 14, 0)
/* HiDPI: drawn on in pixels of GDK */
{
gint s = _gdk_win32_drawable_scale (drawable);
if (s > 1)
cairo_surface_set_device_scale (surface, s, s);
}
#endif
/* Whenever the cairo surface is destroyed, we need to release the
* HDC that was acquired */
cairo_surface_set_user_data (surface, &gdk_win32_cairo_hdc_key,

View file

@ -87,6 +87,13 @@
#define SYNAPSIS_ICON_WINDOW_CLASS "SynTrackCursorWindowClass"
/* The input GDK waits for. Headers for Windows 8 and later add touch
* and pointer messages to QS_ALLINPUT: with those GDK keeps waking up
* for messages it does not take from the queue, and Windows 7 and
* earlier refuse the unknown flags and report nothing at all. */
#define GDK_QS_INPUT (QS_KEY | QS_MOUSEMOVE | QS_MOUSEBUTTON | QS_POSTMESSAGE | \
QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE | 0x0400 /* QS_RAWINPUT */)
static gboolean gdk_event_translate (MSG *msg,
gint *ret_valp);
static void handle_wm_paint (MSG *msg,
@ -176,7 +183,9 @@ _gdk_win32_get_next_tick (gulong suggested_tick)
if (suggested_tick == 0)
suggested_tick = GetTickCount ();
if (suggested_tick <= cur_tick)
/* Ticks eventually wrap around.
* This works as long as the interval between ticks is < 2147483648ms */
if (suggested_tick <= cur_tick && ((cur_tick - suggested_tick) < 0x7FFFFFFF))
return cur_tick;
else
return cur_tick = suggested_tick;
@ -383,7 +392,7 @@ gdk_events_pending (void)
{
return (_gdk_event_queue_find_first (_gdk_display) ||
(modal_win32_dialog == NULL &&
GetQueueStatus (QS_ALLINPUT) != 0));
GetQueueStatus (GDK_QS_INPUT) != 0));
}
GdkEvent*
@ -1261,10 +1270,10 @@ send_crossing_event (GdkDisplay *display,
event->crossing.window = (GdkWindow *)window;
event->crossing.subwindow = subwindow;
event->crossing.time = _gdk_win32_get_next_tick (time_);
event->crossing.x = pt.x;
event->crossing.y = pt.y;
event->crossing.x_root = screen_pt->x + _gdk_offset_x;
event->crossing.y_root = screen_pt->y + _gdk_offset_y;
event->crossing.x = GDK_WIN32_UNSCALE_D (pt.x);
event->crossing.y = GDK_WIN32_UNSCALE_D (pt.y);
event->crossing.x_root = GDK_WIN32_SCREEN_TO_ROOT_D (screen_pt->x, _gdk_offset_x);
event->crossing.y_root = GDK_WIN32_SCREEN_TO_ROOT_D (screen_pt->y, _gdk_offset_y);
event->crossing.mode = mode;
event->crossing.detail = notify_type;
event->crossing.mode = mode;
@ -1482,10 +1491,11 @@ synthesize_expose_events (GdkWindow *window)
{
event = gdk_event_new (GDK_EXPOSE);
event->expose.window = window;
event->expose.area.x = r.left;
event->expose.area.y = r.top;
event->expose.area.width = r.right - r.left;
event->expose.area.height = r.bottom - r.top;
/* HiDPI: in pixels of GDK, all that is touched */
event->expose.area.x = _gdk_win32_unscale (r.left);
event->expose.area.y = _gdk_win32_unscale (r.top);
event->expose.area.width = _gdk_win32_unscale_up (r.right) - event->expose.area.x;
event->expose.area.height = _gdk_win32_unscale_up (r.bottom) - event->expose.area.y;
event->expose.region = gdk_region_rectangle (&(event->expose.area));
event->expose.count = 0;
@ -1669,9 +1679,18 @@ _gdk_win32_emit_configure_event (GdkWindow *window)
if (gdk_window_get_parent (window) == _gdk_root)
{
ClientToScreen (hwnd, &point);
point.x += _gdk_offset_x;
point.y += _gdk_offset_y;
point.x = GDK_WIN32_SCREEN_TO_ROOT_X (point.x);
point.y = GDK_WIN32_SCREEN_TO_ROOT_Y (point.y);
}
else
{
point.x = _gdk_win32_unscale (point.x);
point.y = _gdk_win32_unscale (point.y);
}
/* HiDPI: a size of Windows not divisible by the scale is covered */
client_rect.right = client_rect.left + _gdk_win32_unscale_up (client_rect.right - client_rect.left);
client_rect.bottom = client_rect.top + _gdk_win32_unscale_up (client_rect.bottom - client_rect.top);
window_object->width = client_rect.right - client_rect.left;
window_object->height = client_rect.bottom - client_rect.top;
@ -1727,10 +1746,11 @@ _gdk_win32_hrgn_to_region (HRGN hrgn)
{
GdkRectangle r;
r.x = rects[i].left;
r.y = rects[i].top;
r.width = rects[i].right - r.x;
r.height = rects[i].bottom - r.y;
/* in pixels of GDK, all that is partly in it */
r.x = _gdk_win32_unscale (rects[i].left);
r.y = _gdk_win32_unscale (rects[i].top);
r.width = _gdk_win32_unscale_up (rects[i].right) - r.x;
r.height = _gdk_win32_unscale_up (rects[i].bottom) - r.y;
gdk_region_union_with_rect (result, &r);
}
@ -1758,7 +1778,6 @@ handle_wm_paint (MSG *msg,
GdkEvent **event)
{
HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
HDC hdc;
PAINTSTRUCT paintstruct;
GdkRegion *update_region;
@ -1769,12 +1788,12 @@ handle_wm_paint (MSG *msg,
return;
}
hdc = BeginPaint (msg->hwnd, &paintstruct);
BeginPaint (msg->hwnd, &paintstruct);
GDK_NOTE (EVENTS, g_print (" %s %s dc %p%s",
_gdk_win32_rect_to_string (&paintstruct.rcPaint),
(paintstruct.fErase ? "erase" : ""),
hdc,
paintstruct.hdc,
(return_exposes ? " return_exposes" : "")));
EndPaint (msg->hwnd, &paintstruct);
@ -1795,11 +1814,9 @@ handle_wm_paint (MSG *msg,
*event = gdk_event_new (GDK_EXPOSE);
(*event)->expose.window = window;
(*event)->expose.area.x = paintstruct.rcPaint.left;
(*event)->expose.area.y = paintstruct.rcPaint.top;
(*event)->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left;
(*event)->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
(*event)->expose.region = _gdk_win32_hrgn_to_region (hrgn);
/* in pixels of GDK (HiDPI), as the region */
gdk_region_get_clipbox ((*event)->expose.region, &(*event)->expose.area);
(*event)->expose.count = 0;
while (list != NULL)
@ -1892,6 +1909,154 @@ handle_display_change (void)
g_signal_emit_by_name (_gdk_screen, "size_changed");
}
/* Touches of Windows 7 and later, from user32 when there: RegisterTouchWindow()
* for the windows with GDK_TOUCH_MASK, which then get WM_TOUCH. Windows
* keeps sending the mouse messages of the first finger, marked in
* GetMessageExtraInfo(), which GDK keeps from the windows that take
* touches (gdkwindow.c). Windows XP and Vista: no touches, as before. */
#define GDK_WM_TOUCH 0x0240
#define GDK_TOUCHEVENTF_MOVE 0x0001
#define GDK_TOUCHEVENTF_DOWN 0x0002
#define GDK_TOUCHEVENTF_UP 0x0004
#define GDK_TOUCHEVENTF_PRIMARY 0x0010
#define GDK_MI_WP_SIGNATURE 0xFF515700
#define GDK_MI_SIGNATURE_MASK 0xFFFFFF00
#define GDK_MI_TOUCH 0x80
typedef struct
{
LONG x, y; /* hundredths of a screen pixel */
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact, cyContact;
} GdkTouchInput;
typedef BOOL (WINAPI *t_RegisterTouchWindow) (HWND, ULONG);
typedef BOOL (WINAPI *t_UnregisterTouchWindow) (HWND);
typedef BOOL (WINAPI *t_GetTouchInputInfo) (HANDLE, UINT, GdkTouchInput *, int);
typedef BOOL (WINAPI *t_CloseTouchInputHandle) (HANDLE);
static t_RegisterTouchWindow p_RegisterTouchWindow;
static t_UnregisterTouchWindow p_UnregisterTouchWindow;
static t_GetTouchInputInfo p_GetTouchInputInfo;
static t_CloseTouchInputHandle p_CloseTouchInputHandle;
static gboolean
touch_api (void)
{
static gint state; /* 0 not looked, 1 there, 2 not */
if (state == 0)
{
HMODULE user32 = GetModuleHandleW (L"user32.dll");
p_RegisterTouchWindow = (t_RegisterTouchWindow) GetProcAddress (user32, "RegisterTouchWindow");
p_UnregisterTouchWindow = (t_UnregisterTouchWindow) GetProcAddress (user32, "UnregisterTouchWindow");
p_GetTouchInputInfo = (t_GetTouchInputInfo) GetProcAddress (user32, "GetTouchInputInfo");
p_CloseTouchInputHandle = (t_CloseTouchInputHandle) GetProcAddress (user32, "CloseTouchInputHandle");
state = p_RegisterTouchWindow && p_UnregisterTouchWindow &&
p_GetTouchInputInfo && p_CloseTouchInputHandle ? 1 : 2;
}
return state == 1;
}
void
_gdk_win32_window_update_touch (GdkWindow *window,
gboolean touch)
{
HWND hwnd;
if (GDK_WINDOW_DESTROYED (window) || !touch_api ())
return;
hwnd = GDK_WINDOW_HWND (window);
if (hwnd == NULL || GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT ||
GDK_WINDOW_TYPE (window) == GDK_WINDOW_FOREIGN)
return;
if (touch)
p_RegisterTouchWindow (hwnd, 0);
else
p_UnregisterTouchWindow (hwnd);
}
/* a mouse message that Windows made of a finger */
static gboolean
mouse_message_from_touch (void)
{
LPARAM extra = GetMessageExtraInfo ();
return (extra & GDK_MI_SIGNATURE_MASK) == GDK_MI_WP_SIGNATURE &&
(extra & GDK_MI_TOUCH) != 0;
}
static gboolean
handle_wm_touch (GdkWindow *window,
MSG *msg)
{
UINT n = LOWORD (msg->wParam), i;
GdkTouchInput *inputs;
POINT origin = { 0, 0 };
guint state;
if (n == 0 || !touch_api () || GDK_WINDOW_DESTROYED (window))
return FALSE;
inputs = g_new (GdkTouchInput, n);
if (!p_GetTouchInputInfo ((HANDLE) msg->lParam, n, inputs, sizeof (GdkTouchInput)))
{
g_free (inputs);
return FALSE;
}
ClientToScreen (GDK_WINDOW_HWND (window), &origin);
state = build_pointer_event_state (msg) &
~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
for (i = 0; i < n; i++)
{
GdkEvent *event;
GdkEventType type;
gdouble sx = inputs[i].x / 100.0, sy = inputs[i].y / 100.0;
if (inputs[i].dwFlags & GDK_TOUCHEVENTF_DOWN)
type = GDK_TOUCH_BEGIN;
else if (inputs[i].dwFlags & GDK_TOUCHEVENTF_UP)
type = GDK_TOUCH_END;
else if (inputs[i].dwFlags & GDK_TOUCHEVENTF_MOVE)
type = GDK_TOUCH_UPDATE;
else
continue;
event = gdk_event_new (type);
event->touch.window = window;
event->touch.time = _gdk_win32_get_next_tick (msg->time);
event->touch.x = GDK_WIN32_UNSCALE_D (sx - origin.x);
event->touch.y = GDK_WIN32_UNSCALE_D (sy - origin.y);
event->touch.x_root = GDK_WIN32_SCREEN_TO_ROOT_D (sx, _gdk_offset_x);
event->touch.y_root = GDK_WIN32_SCREEN_TO_ROOT_D (sy, _gdk_offset_y);
event->touch.axes = NULL;
event->touch.state = state;
/* the ids of Windows may be 0 */
event->touch.sequence = GUINT_TO_POINTER (inputs[i].dwID + 1);
event->touch.emulating_pointer = (inputs[i].dwFlags & GDK_TOUCHEVENTF_PRIMARY) != 0;
event->touch.device = _gdk_display->core_pointer;
((GdkEventPrivate *) event)->flags |= GDK_EVENT_TOUCH_SYSTEM_POINTER;
_gdk_win32_append_event (event);
}
p_CloseTouchInputHandle ((HANDLE) msg->lParam);
g_free (inputs);
return TRUE;
}
static void
generate_button_event (GdkEventType type,
gint button,
@ -1900,12 +2065,17 @@ generate_button_event (GdkEventType type,
{
GdkEvent *event = gdk_event_new (type);
if (mouse_message_from_touch ())
((GdkEventPrivate *) event)->flags |= GDK_EVENT_POINTER_EMULATED;
event->button.window = window;
event->button.time = _gdk_win32_get_next_tick (msg->time);
event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
event->button.x_root = msg->pt.x + _gdk_offset_x;
event->button.y_root = msg->pt.y + _gdk_offset_y;
current_x = (gint16) GET_X_LPARAM (msg->lParam);
current_y = (gint16) GET_Y_LPARAM (msg->lParam);
event->button.x = GDK_WIN32_UNSCALE_D (current_x);
event->button.y = GDK_WIN32_UNSCALE_D (current_y);
event->button.x_root = GDK_WIN32_SCREEN_TO_ROOT_D (msg->pt.x, _gdk_offset_x);
event->button.y_root = GDK_WIN32_SCREEN_TO_ROOT_D (msg->pt.y, _gdk_offset_y);
event->button.axes = NULL;
event->button.state = build_pointer_event_state (msg);
event->button.button = button;
@ -2082,7 +2252,7 @@ gdk_event_translate (MSG *msg,
GdkWindow *window = NULL;
GdkWindowImplWin32 *impl;
GdkWindow *orig_window, *new_window;
GdkWindow *new_window;
GdkPointerGrabInfo *grab = NULL;
GdkWindow *grab_window = NULL;
@ -2111,7 +2281,6 @@ gdk_event_translate (MSG *msg,
}
window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd);
orig_window = window;
if (window == NULL)
{
@ -2352,6 +2521,10 @@ gdk_event_translate (MSG *msg,
LOBYTE (HIWORD (msg->lParam)) == _gdk_win32_keymap_get_rshift_scancode (GDK_WIN32_KEYMAP (gdk_keymap_get_default ())))
event->key.hardware_keycode = VK_RSHIFT;
event->key.is_modifier = (msg->wParam == VK_CONTROL ||
msg->wParam == VK_SHIFT ||
msg->wParam == VK_MENU);
/* g_print ("ctrl:%02x lctrl:%02x rctrl:%02x alt:%02x lalt:%02x ralt:%02x\n", key_state[VK_CONTROL], key_state[VK_LCONTROL], key_state[VK_RCONTROL], key_state[VK_MENU], key_state[VK_LMENU], key_state[VK_RMENU]); */
build_key_event_state (event, key_state);
@ -2666,20 +2839,32 @@ gdk_event_translate (MSG *msg,
event = gdk_event_new (GDK_MOTION_NOTIFY);
event->motion.window = window;
event->motion.time = _gdk_win32_get_next_tick (msg->time);
event->motion.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
event->motion.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
event->motion.x_root = current_root_x;
event->motion.y_root = current_root_y;
current_x = (gint16) GET_X_LPARAM (msg->lParam);
current_y = (gint16) GET_Y_LPARAM (msg->lParam);
event->motion.x = GDK_WIN32_UNSCALE_D (current_x);
event->motion.y = GDK_WIN32_UNSCALE_D (current_y);
event->motion.x_root = GDK_WIN32_UNSCALE_D (current_root_x);
event->motion.y_root = GDK_WIN32_UNSCALE_D (current_root_y);
event->motion.axes = NULL;
event->motion.state = build_pointer_event_state (msg);
event->motion.is_hint = FALSE;
event->motion.device = _gdk_display->core_pointer;
if (mouse_message_from_touch ())
((GdkEventPrivate *) event)->flags |= GDK_EVENT_POINTER_EMULATED;
_gdk_win32_append_event (event);
return_val = TRUE;
break;
case GDK_WM_TOUCH:
if (handle_wm_touch (window, msg))
{
*ret_valp = 0;
return_val = TRUE;
}
break;
case WM_NCMOUSEMOVE:
GDK_NOTE (EVENTS,
g_print (" (%d,%d)",
@ -2778,28 +2963,35 @@ gdk_event_translate (MSG *msg,
ScreenToClient (msg->hwnd, &point);
event = gdk_event_new (GDK_SCROLL);
event->scroll.window = window;
{
/* What the wheel turned, in steps of WHEEL_DELTA: precision
* touchpads and fine wheels send fractions, which become
* smooth scroll events and, once they make up a step, the
* usual ones as well */
static gdouble rest[2];
GdkEvent scroll;
gdouble delta = (short) HIWORD (msg->wParam) / (gdouble) WHEEL_DELTA;
gdouble dx = 0, dy = 0;
if (msg->message == WM_MOUSEWHEEL)
{
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
GDK_SCROLL_UP : GDK_SCROLL_DOWN;
}
else if (msg->message == WM_MOUSEHWHEEL)
{
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT;
}
event->scroll.time = _gdk_win32_get_next_tick (msg->time);
event->scroll.x = (gint16) point.x;
event->scroll.y = (gint16) point.y;
event->scroll.x_root = (gint16) GET_X_LPARAM (msg->lParam) + _gdk_offset_x;
event->scroll.y_root = (gint16) GET_Y_LPARAM (msg->lParam) + _gdk_offset_y;
event->scroll.state = build_pointer_event_state (msg);
event->scroll.device = _gdk_display->core_pointer;
if (msg->message == WM_MOUSEWHEEL)
dy = - delta;
else
dx = delta;
_gdk_win32_append_event (event);
memset (&scroll, 0, sizeof scroll);
scroll.scroll.type = GDK_SCROLL;
scroll.scroll.window = window;
scroll.scroll.time = _gdk_win32_get_next_tick (msg->time);
scroll.scroll.x = GDK_WIN32_UNSCALE_D ((gint16) point.x);
scroll.scroll.y = GDK_WIN32_UNSCALE_D ((gint16) point.y);
scroll.scroll.x_root = GDK_WIN32_SCREEN_TO_ROOT_D ((gint16) GET_X_LPARAM (msg->lParam), _gdk_offset_x);
scroll.scroll.y_root = GDK_WIN32_SCREEN_TO_ROOT_D ((gint16) GET_Y_LPARAM (msg->lParam), _gdk_offset_y);
scroll.scroll.state = build_pointer_event_state (msg);
scroll.scroll.device = _gdk_display->core_pointer;
_gdk_event_emit_scroll (NULL, &scroll, TRUE, dx, dy, dx, dy, rest,
_gdk_win32_append_event);
}
return_val = TRUE;
break;
@ -3169,8 +3361,8 @@ gdk_event_translate (MSG *msg,
{
/* Resize in increments relative to the base size */
rect.left = rect.top = 0;
rect.right = impl->hints.base_width;
rect.bottom = impl->hints.base_height;
rect.right = GDK_WIN32_SC (impl->hints.base_width);
rect.bottom = GDK_WIN32_SC (impl->hints.base_height);
_gdk_win32_adjust_client_rect (window, &rect);
point.x = rect.left;
point.y = rect.top;
@ -3192,53 +3384,53 @@ gdk_event_translate (MSG *msg,
case WMSZ_BOTTOM:
if (drag->bottom == rect.bottom)
break;
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
adjust_drag (&drag->bottom, rect.bottom, GDK_WIN32_SC (impl->hints.height_inc));
break;
case WMSZ_BOTTOMLEFT:
if (drag->bottom == rect.bottom && drag->left == rect.left)
break;
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
adjust_drag (&drag->bottom, rect.bottom, GDK_WIN32_SC (impl->hints.height_inc));
adjust_drag (&drag->left, rect.left, GDK_WIN32_SC (impl->hints.width_inc));
break;
case WMSZ_LEFT:
if (drag->left == rect.left)
break;
adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
adjust_drag (&drag->left, rect.left, GDK_WIN32_SC (impl->hints.width_inc));
break;
case WMSZ_TOPLEFT:
if (drag->top == rect.top && drag->left == rect.left)
break;
adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
adjust_drag (&drag->top, rect.top, GDK_WIN32_SC (impl->hints.height_inc));
adjust_drag (&drag->left, rect.left, GDK_WIN32_SC (impl->hints.width_inc));
break;
case WMSZ_TOP:
if (drag->top == rect.top)
break;
adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
adjust_drag (&drag->top, rect.top, GDK_WIN32_SC (impl->hints.height_inc));
break;
case WMSZ_TOPRIGHT:
if (drag->top == rect.top && drag->right == rect.right)
break;
adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
adjust_drag (&drag->top, rect.top, GDK_WIN32_SC (impl->hints.height_inc));
adjust_drag (&drag->right, rect.right, GDK_WIN32_SC (impl->hints.width_inc));
break;
case WMSZ_RIGHT:
if (drag->right == rect.right)
break;
adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
adjust_drag (&drag->right, rect.right, GDK_WIN32_SC (impl->hints.width_inc));
break;
case WMSZ_BOTTOMRIGHT:
if (drag->bottom == rect.bottom && drag->right == rect.right)
break;
adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
adjust_drag (&drag->bottom, rect.bottom, GDK_WIN32_SC (impl->hints.height_inc));
adjust_drag (&drag->right, rect.right, GDK_WIN32_SC (impl->hints.width_inc));
break;
}
@ -3375,8 +3567,8 @@ gdk_event_translate (MSG *msg,
if (impl->hint_flags & GDK_HINT_MIN_SIZE)
{
rect.left = rect.top = 0;
rect.right = impl->hints.min_width;
rect.bottom = impl->hints.min_height;
rect.right = GDK_WIN32_SC (impl->hints.min_width);
rect.bottom = GDK_WIN32_SC (impl->hints.min_height);
_gdk_win32_adjust_client_rect (window, &rect);
@ -3389,8 +3581,8 @@ gdk_event_translate (MSG *msg,
int maxw, maxh;
rect.left = rect.top = 0;
rect.right = impl->hints.max_width;
rect.bottom = impl->hints.max_height;
rect.right = GDK_WIN32_SC (impl->hints.max_width);
rect.bottom = GDK_WIN32_SC (impl->hints.max_height);
_gdk_win32_adjust_client_rect (window, &rect);
@ -3402,8 +3594,36 @@ gdk_event_translate (MSG *msg,
}
else
{
/* Apparently, this is just a very big number (bigger than any widget
* could realistically be) to make sure the window is as big as
* possible when maximized.
*/
mmi->ptMaxTrackSize.x = 30000;
mmi->ptMaxTrackSize.y = 30000;
/* A window without a frame would be maximized over the whole
* monitor, taskbar included. Windows wants the maximized position
* and size as if the window were on the primary monitor, so only
* the taskbar of the nearest monitor is taken into account.
*/
if ((GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE) &
(WS_BORDER | WS_THICKFRAME)) == 0)
{
HMONITOR nearest_monitor;
MONITORINFO nearest_info;
nearest_monitor = MonitorFromWindow (GDK_WINDOW_HWND (window),
MONITOR_DEFAULTTONEAREST);
nearest_info.cbSize = sizeof (nearest_info);
if (GetMonitorInfoA (nearest_monitor, &nearest_info))
{
mmi->ptMaxPosition.x = nearest_info.rcWork.left - nearest_info.rcMonitor.left;
mmi->ptMaxPosition.y = nearest_info.rcWork.top - nearest_info.rcMonitor.top;
mmi->ptMaxSize.x = nearest_info.rcWork.right - nearest_info.rcWork.left;
mmi->ptMaxSize.y = nearest_info.rcWork.bottom - nearest_info.rcWork.top;
}
}
}
if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))
@ -3533,6 +3753,21 @@ gdk_event_translate (MSG *msg,
break;
}
}
else if (msg->wParam == CF_HDROP)
{
/* the URIs of the clipboard as files for Explorer */
_delayed_rendering_data =
_gdk_win32_selection_convert_to_hdrop (_delayed_rendering_data);
if (!_delayed_rendering_data)
break;
}
else if (msg->wParam == _cf_preferred_drop_effect)
{
_delayed_rendering_data =
_gdk_win32_selection_convert_to_drop_effect (_delayed_rendering_data);
if (!_delayed_rendering_data)
break;
}
/* The requestor is holding the clipboard, no
* OpenClipboard() is required/possible
@ -3654,7 +3889,7 @@ gdk_event_prepare (GSource *source,
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
(modal_win32_dialog == NULL &&
GetQueueStatus (QS_ALLINPUT) != 0));
GetQueueStatus (GDK_QS_INPUT) != 0));
GDK_THREADS_LEAVE ();
@ -3672,7 +3907,7 @@ gdk_event_check (GSource *source)
{
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
(modal_win32_dialog == NULL &&
GetQueueStatus (QS_ALLINPUT) != 0));
GetQueueStatus (GDK_QS_INPUT) != 0));
}
else
{

View file

@ -887,7 +887,6 @@ gdk_font_load_logfont (LOGFONT *lfp)
}
else
break;
tries++;
}
if (!hfont)

View file

@ -173,10 +173,12 @@ fixup_pen (GdkGCWin32 *win32_gc)
win32_gc->pen_num_dashes = 1;
}
if (!(win32_gc->pen_style & PS_TYPE_MASK) == PS_GEOMETRIC &&
/* single dots of a cosmetic pen: what PS_ALTERNATE is for (the
* test said "not geometric" in a way that was never true) */
if ((win32_gc->pen_style & PS_TYPE_MASK) == PS_COSMETIC &&
win32_gc->pen_dashes[0] == 1 &&
(win32_gc->pen_num_dashes == 1 ||
(win32_gc->pen_num_dashes == 2 && win32_gc->pen_dashes[0] == 1)))
(win32_gc->pen_num_dashes == 2 && win32_gc->pen_dashes[1] == 1)))
win32_gc->pen_style |= PS_ALTERNATE;
else
win32_gc->pen_style |= PS_USERSTYLE;
@ -745,7 +747,7 @@ static GdkDrawableImplWin32 *
get_impl_drawable (GdkDrawable *drawable)
{
if (GDK_IS_OFFSCREEN_WINDOW (drawable))
return _gdk_offscreen_window_get_real_drawable (GDK_OFFSCREEN_WINDOW (drawable));
return GDK_DRAWABLE_IMPL_WIN32 (_gdk_offscreen_window_get_real_drawable (GDK_OFFSCREEN_WINDOW (drawable)));
if (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable))
return GDK_DRAWABLE_IMPL_WIN32(drawable);
else if (GDK_IS_WINDOW (drawable))
@ -808,6 +810,49 @@ get_impl_drawable (GdkDrawable *drawable)
*
* Return value: The HDC.
**/
/* HiDPI: a logical unit of the DC as @scale of its pixels (1 for the
* pixels themselves) */
void
_gdk_win32_dc_set_scale (HDC hdc,
gint scale)
{
if (_gdk_win32_scale <= 1)
return;
if (scale > 1)
{
SetMapMode (hdc, MM_ANISOTROPIC);
SetWindowExtEx (hdc, 1, 1, NULL);
SetViewportExtEx (hdc, scale, scale, NULL);
}
else
SetMapMode (hdc, MM_TEXT);
}
/* an HRGN of logical units of GDK as one of Windows */
HRGN
_gdk_win32_hrgn_scale (HRGN hrgn)
{
XFORM xform = { 0 };
DWORD size;
RGNDATA *data;
HRGN result;
if (_gdk_win32_scale <= 1 || (size = GetRegionData (hrgn, 0, NULL)) == 0)
return hrgn;
data = g_malloc (size);
GetRegionData (hrgn, size, data);
xform.eM11 = xform.eM22 = (FLOAT) _gdk_win32_scale;
result = ExtCreateRegion (&xform, size, data);
g_free (data);
if (!result)
return hrgn;
DeleteObject (hrgn);
return result;
}
HDC
gdk_win32_hdc_get (GdkDrawable *drawable,
GdkGC *gc,
@ -830,6 +875,11 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0)
WIN32_GDI_FAILED ("SaveDC"), ok = FALSE;
/* HiDPI: GDK draws in its pixels, Windows maps them to its own (the
* DC goes back to them with RestoreDC in gdk_win32_hdc_release) */
if (ok)
_gdk_win32_dc_set_scale (win32_gc->hdc, _gdk_win32_drawable_scale (GDK_DRAWABLE (impl)));
if (ok && (usage & (GDK_GC_FOREGROUND | GDK_GC_BACKGROUND)))
ok = predraw (gc, impl->colormap);
@ -873,6 +923,23 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
style = win32_gc->pen_dashes;
}
/* a cosmetic pen is one pixel of Windows wide, whatever the
* mapping; a geometric one gets as wide as GDK's pixel */
if (_gdk_win32_scale > 1 &&
(win32_gc->pen_style & PS_TYPE_MASK) == PS_COSMETIC)
win32_gc->pen_style = (win32_gc->pen_style & ~(PS_TYPE_MASK | PS_STYLE_MASK)) |
PS_GEOMETRIC | PS_ENDCAP_FLAT |
((win32_gc->pen_style & PS_STYLE_MASK) == PS_ALTERNATE
? PS_USERSTYLE : (win32_gc->pen_style & PS_STYLE_MASK));
if ((win32_gc->pen_style & PS_STYLE_MASK) == PS_USERSTYLE && !style)
{
static const DWORD dots[2] = { 1, 1 };
style_count = win32_gc->pen_dashes ? win32_gc->pen_num_dashes : 2;
style = win32_gc->pen_dashes ? win32_gc->pen_dashes : dots;
}
if ((hpen = ExtCreatePen (win32_gc->pen_style,
MAX (win32_gc->pen_width, 1),
&logbrush,
@ -906,6 +973,7 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
if (ok && win32_gc->values_mask & (GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN) &&
OffsetClipRgn (win32_gc->hdc,
/* logical units: the mapping scales them */
win32_gc->values_mask & GDK_GC_CLIP_X_ORIGIN ? gc->clip_x_origin : 0,
win32_gc->values_mask & GDK_GC_CLIP_Y_ORIGIN ? gc->clip_y_origin : 0) == ERROR)
WIN32_API_FAILED ("OffsetClipRgn"), ok = FALSE;
@ -1010,8 +1078,11 @@ _gdk_win32_bitmap_to_hrgn (GdkPixmap *pixmap)
g_assert (GDK_PIXMAP_OBJECT(pixmap)->depth == 1);
bits = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->bits;
/* the bits, so an HRGN in pixels of Windows (HiDPI) */
width = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->width;
height = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->height;
width *= MAX (GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->scale, 1);
height *= MAX (GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->scale, 1);
bpl = ((width - 1)/32 + 1)*4;
/* For better performances, we will use the ExtCreateRegion()
@ -1104,6 +1175,10 @@ _gdk_win32_bitmap_to_hrgn (GdkPixmap *pixmap)
/* Clean up*/
g_free (pData);
/* a bitmap of a GdkImage has GDK's pixels (HiDPI) */
if (hRgn && GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->scale <= 1)
hRgn = _gdk_win32_hrgn_scale (hRgn);
return hRgn;
}
@ -1131,10 +1206,11 @@ _gdk_win32_gdkregion_to_hrgn (const GdkRegion *region,
{
rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++;
rect->left = boxes[i].x1 + x_origin;
rect->right = boxes[i].x2 + x_origin;
rect->top = boxes[i].y1 + y_origin;
rect->bottom = boxes[i].y2 + y_origin;
/* a region of GDK, an HRGN in pixels of Windows */
rect->left = GDK_WIN32_SC (boxes[i].x1 + x_origin);
rect->right = GDK_WIN32_SC (boxes[i].x2 + x_origin);
rect->top = GDK_WIN32_SC (boxes[i].y1 + y_origin);
rect->bottom = GDK_WIN32_SC (boxes[i].y2 + y_origin);
if (rect->left < rgndata->rdh.rcBound.left)
rgndata->rdh.rcBound.left = rect->left;

View file

@ -59,14 +59,12 @@ _gdk_window_move_resize_child (GdkWindow *window,
gint width,
gint height)
{
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
obj = GDK_WINDOW_OBJECT (window);
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
_gdk_win32_drawable_description (window),
@ -97,8 +95,9 @@ _gdk_window_move_resize_child (GdkWindow *window,
width, height));
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
width, height,
GDK_WIN32_SC (obj->x + obj->parent->abs_x),
GDK_WIN32_SC (obj->y + obj->parent->abs_y),
GDK_WIN32_SC (width), GDK_WIN32_SC (height),
SWP_NOACTIVATE | SWP_NOZORDER));
//_gdk_win32_window_tmp_reset_parent_bg (window);

View file

@ -37,6 +37,7 @@ gint _gdk_num_monitors;
GdkWin32Monitor *_gdk_monitors = NULL;
gint _gdk_offset_x, _gdk_offset_y;
gint _gdk_win32_scale = 1;
HDC _gdk_display_hdc;
HINSTANCE _gdk_dll_hinstance;
@ -69,6 +70,8 @@ UINT _cf_png;
UINT _cf_jfif;
UINT _cf_gif;
UINT _cf_url;
UINT _cf_preferred_drop_effect;
GdkAtom _gnome_copied_files;
UINT _cf_html_format;
UINT _cf_text_html;

View file

@ -175,7 +175,7 @@ gdk_image_new_bitmap (GdkVisual *visual,
gint data_bpl = (w-1)/8 + 1;
gint i;
pixmap = gdk_pixmap_new (NULL, w, h, 1);
pixmap = _gdk_win32_pixmap_new_unscaled (w, h, 1);
if (pixmap == NULL)
return NULL;
@ -223,7 +223,7 @@ _gdk_image_new_for_depth (GdkScreen *screen,
if (visual)
depth = visual->depth;
pixmap = gdk_pixmap_new (NULL, width, height, depth);
pixmap = _gdk_win32_pixmap_new_unscaled (width, height, depth);
if (pixmap == NULL)
return NULL;

View file

@ -675,7 +675,6 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
gdouble *y_out)
{
GdkWindowObject *priv, *impl_window;
GdkWindowImplWin32 *root_impl;
int i;
int x_axis = 0;
@ -709,7 +708,6 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
if (gdkdev->info.mode == GDK_MODE_SCREEN)
{
root_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl);
x_scale = GDK_WINDOW_OBJECT (_gdk_root)->width / device_width;
y_scale = GDK_WINDOW_OBJECT (_gdk_root)->height / device_height;
@ -747,12 +745,12 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
switch (gdkdev->info.axes[i].use)
{
case GDK_AXIS_X:
axis_out[i] = x_offset + x_scale * axis_data[x_axis];
axis_out[i] = x_offset + x_scale * (axis_data[x_axis] - x_min);
if (x_out)
*x_out = axis_out[i];
break;
case GDK_AXIS_Y:
axis_out[i] = y_offset + y_scale * axis_data[y_axis];
axis_out[i] = y_offset + y_scale * (axis_data[y_axis] - y_min);
if (y_out)
*y_out = axis_out[i];
break;
@ -778,9 +776,9 @@ gdk_input_get_root_relative_geometry (HWND w,
ClientToScreen (w, &pt);
if (x_ret)
*x_ret = pt.x + _gdk_offset_x;
*x_ret = GDK_WIN32_SCREEN_TO_ROOT_X (pt.x);
if (y_ret)
*y_ret = pt.y + _gdk_offset_y;
*y_ret = GDK_WIN32_SCREEN_TO_ROOT_Y (pt.y);
}
void

View file

@ -692,6 +692,7 @@ update_keymap (GdkKeymap *gdk_keymap)
if (hkls_len != keymap->layout_handles->len)
keymap->keysym_tab = g_renew (guint, keymap->keysym_tab, keysym_tab_size);
memset (key_state, 0, sizeof(key_state));
memset (keymap->keysym_tab, 0, keysym_tab_size);
g_array_set_size (keymap->layout_handles, hkls_len);
g_array_set_size (keymap->options, hkls_len);
@ -1288,7 +1289,7 @@ gdk_keymap_get_entries_for_keyval (GdkKeymap *gdk_keymap,
else
keymap = GDK_WIN32_KEYMAP (gdk_keymap);
update_keymap (gdk_keymap);
update_keymap (GDK_KEYMAP (keymap));
for (vk = 0; vk < KEY_STATE_SIZE; vk++)
{

Some files were not shown because too many files have changed in this diff Show more