Commit Graph

187 Commits

Author SHA1 Message Date
Carlos Garnacho 02eea132c2 widgets: Add GimpDeviceInfo API to generate a GtkPadController
This API call will snapshot the current configuration of a device
into a GtkPadController, that is created and attached to a toplevel
(this event controller only acts on toplevels).

This controller will handle pad events, trigger actions, and update
compositor feedback (e.g. GNOME Shell pad OSD) as per the actions
mapped in the configuration dialog.
2023-12-08 12:35:34 +00:00
Carlos Garnacho 224566bb84 widgets: Detect disconnected pads as pads in GimpDeviceInfo
Return a suitable GdkInputSource for those configured pads, so that
they show up as pads in configuration even if disconnected.
2023-12-08 12:35:34 +00:00
Carlos Garnacho 8182f7d683 widgets: Add pad configuration to GimpDeviceInfo
Add property/getters for the pad configuration, and hook it
up to the serialization mechanism, so pad configuration is part
of device configuration.
2023-12-08 12:35:34 +00:00
Jehan e3bb3bf57f app: fix address sanitizer error.
The error is:

> app/widgets/gimpdeviceinfo.c:387:13: runtime error: null pointer passed as argument 1, which is declared to never be nul
2023-04-20 15:36:11 +02:00
Jehan c799d5235e app: fix a CRITICAL when physical device axis list changes.
After some investigation, I am a bit unsure of why this happens exactly,
but I have a case that the device's axis number listed is not right and
this only becomes apparent after the stylus gets close then further from
the tablet-display. This fixes it, though I think we should look more
closely and reorganize a bit this whole part of our code, which seems
unecessarily complicated and duplicating some data already in GTK/GDK,
like the list of axis, etc. (though maybe it was necessary back when
this was first implemented before more logics got moved to GDK?)
2022-03-26 19:07:48 +01:00
Stanislav Grinkov 619cb91230 Remove unnecessary gimpmarshal.h and gimpwidgetsmarshal.h includes. 2021-08-13 18:01:13 +00:00
Jehan d4e501919e app: revert to "gimp-paintbrush-tool" as default tool.
A UI unit test (paintbrush_is_standard_tool()) was expecting the
paintbrush tool to be the default tool. This actually does not fit with
my tests as the crop tool was always the default tool if I were to
delete my config folder and start anew. Yet it was working for the unit
testing at the very least since `make check` used to work until now, and
was broken by my change.

Anyway with my new code (commit 31e38fe869) and this additional one, now
it should work both for unit tests and real usage. So this commit fixes
both the CI and the originally expected default tool.

For the record, Aryeom also agrees that paintbrush is a good default
tool for first usage/discovery of GIMP.
2020-12-12 13:06:37 +01:00
Jehan 31e38fe869 app: better tool defaults depending on the device source.
This code is the result of discussions with and propositions by Aryeom
who thinks (and I agree obviously) better defaults should be set for
beginners and first time users. This is only a first change, more
similar defaults updates will likely come in the next few months on
various parts of GIMP.

Existing code was only making a differenciation for eraser-type devices,
setting them to the eraser tool (which is fine of course).
So far, I only added 2 types of device source, which we should
definitely special-case as well: pen tools (tablet styluses) should
definitely map to the Paintbrush (pencil could be a reasonable defaults
too, though brush seems much more common); as for touchscreen, I chose
to map to the Smudge tool (though to be fair, if we had gesture
recognition, this should not map to any tool). I also set a generic
default now because it seems that right now, we don't specify anything
(it ends up defaulting to the Crop tool for first uses, at least in my
case). I set the rectangle select tool. I'm not sure it actually makes
particular sense, but at least it's probably better to default to
something not destructive for first time users.
2020-12-11 00:30:50 +01:00
Jehan 273972bc4d app: do not reuse stored configuration on virtual devices.
Virtual devices are only reflection on the various physical devices
attached to it (mouse, touchpads, styluses, etc.). Keeping settings when
the device is updated just makes no sense. Worse it can actually cause
issues by setting axis uses from one device where an axis use is 'none'
(and it's normal) to another where 'none' ends up disabling the axis.
2020-12-10 23:54:24 +01:00
Jehan 1c06751c08 app: update when device axes/keys change.
Earlier code was assuming it should not happen. Actually it can happen,
in particular with virtual devices (on which several physical devices
can be attached and switching to one or the other would update the
virtual device to mimick its features).
2020-12-08 23:17:23 +01:00
Jehan e3ee463815 app: move GimpDeviceInfo variables to a private structure.
It's just better practice to not leave all these variables public,
implicitly allowing various code to use these directly (also making
debugging harder).
2020-12-08 21:07:37 +01:00
Jehan de739bde23 app: better code to handle GimpDeviceInfo axes.
Axis names can now be returned with gimp_device_info_get_axis_name() and
I added a dedicated function gimp_device_info_ignore_axis() to handle
the case of an axis to ignore.
I also improved the code with less redundancy to handle the axes data
(both the use and name arrays will always exist and be created and will
be n_axes size, hence avoiding bad out-of-bound reads). This includes
some code refactorization avoiding near code duplication to make sure we
always have the same logics, by creating the gimp_device_info_updated()
static function.
2020-12-08 20:28:25 +01:00
Jehan 1ed87e2d17 app: improve input device axes display "Input Devices" dialog.
- First only show the axes returned by GDK (which means the axes
  returned by the driver if I understand correctly), and even within
  these, ignore the ones set as "ignore" because they are likely bogus
  axes (Carlos said drivers sometimes add a bunch of axis; I am guessing
  this is because many are generic drivers for various models of tablets
  so instead of have variable length of axes, they just set some to be
  ignored).
- Also use the names returned by GDK instead of our fixed set of names.
  The main advantage is that these are more accurate. For instance
  rather than showing just "X" for the firxt axis, the GDK names would
  be "Abs X" for a tablet and "Rel X" for a mouse. The drawbacks is that
  it doesn't look like GDK is actually translating these, and since we
  don't have the strings in our code, we don't either. This will have to
  be figured out.
  Note that we still need to use the fixed set of names
  (axis_use_strings array) when a device is disconnected.
- If some device didn't have any axes at all, don't show an empty list.
  Don't show the curve widget either.
- In the Axes list, select by default the first axis with curve (which
  would be only pressure so far if a device has this axis), because this
  is one of the main feature still doable with this dialog, so it's a
  bit of a time-waste if we don't show this directly. In no axes has a
  curve, just show the first axis in the list.
2020-12-05 01:03:59 +01:00
Jehan 74a7a5d3e2 Issue #2495: different code for Windows and Linux on duplicate devices.
After discussing with Mitch, it turn out commit 717c183a3e was fixing
(or rather working around) actual issues of broken device/usb stack
issues on Linux, as expected.
Nevertheless on Windows, this broke in turn many tablets (see commit
ce24e16083). Therefore we do a very ugly #ifdef to bail from duplicate
devices on Windows whereas we continue on Linux. This fix and difference
of behavior is completely empirical, rather than based on actual good
logics, so that's quite annoying, but well… not much choice here.

Also note that since we had no report of breakage on other OSes (such as
macOS/BSD), at least that I know of, I let them with the Linux code
path.
2018-12-11 16:05:41 +01:00
Jehan ce24e16083 Issue #2495: many tablets broken by GIMP 2.10.8.
We had many reports of tablets from various brands (Huion, Gaomon,
XP-Pen…) broken in the last release (though working fine when
downgrading to 2.10.6). Latest Huion drivers seem to fix the issue
(according to at least one report), but this is not the case for other
tablets.

Though unable to test myself, provided stderr logs indicate that we hit
the case when 2 devices with the same name are registered. Therefore
this commit is basically reverting commit 717c183a3e (though keeping and
completing the comments). I don't think there is an ultimate solution
here but with this regression, experience shows us there seem to be a
lot more breakage when overwriting the device with newer occurences (at
least on Windows). It is unclear though if commit 717c183a3e was also
supposed to fix another case actually encountered. If so, we will need
to get an even more advanced solution.
2018-12-07 00:15:04 +01:00
Michael Natterer 7adb6c26e5 Issue #2210 - GIMP crashes on startup if usb mouse is present
In GimpDeviceInfo, make sure that the info->axes and info->keys arrays
always have info->n_axes and info->n_keys members. Also sync axes and
keys between GdkDevice and GimpDeviceInfo more often, and some
cleanup.
2018-10-12 19:55:56 +02:00
Marco Ciampa 7bfd22ca68 Fixed small typo 2018-09-17 19:34:41 +02:00
Michael Natterer 717c183a3e app: make GimpDeviceInfo more rubust against broken device listings
gimp_device_info_set_device(): don't just bail out if a device with
the same name is added again, instead, simply continue and overwrite
the info's old device with the new one.

NOTE that this only happens if something is wrong on the USB or udev
or libinput or whatever side and the same device is present multiple
times. The only "safe" thing is to assume that devices listed earlier
are dead and dangling entities and that the last registered device is
the one actually delivering events.
2018-08-20 20:02:19 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer f06d0485e6 app: don't g_return_if_fail() in gimp_device_info_set_device()
when the GimpDeviceInfo already has a device. This is not a programming
error that should trigger a bug report popup, it's something else about
non-uniqueness of device names, or whatever. Simply g_printerr() a more
useful message that can help to debug this and bail out.
2018-06-17 15:09:56 +02:00
Michael Natterer 6f6ec64fa9 app: the return value of gdk_device_get_has_cursor() has become meaningless
so for now assume that all devices except floating ones move the
pointer, and figure out the details once multiple masters actually
exits.
2018-05-20 21:06:35 +02:00
Michael Natterer d2edafbf16 app: use GdkDeviceTool properties to GimpDeviceInfo
and display the current tool's info in GimpDeviceInfoEditor.
2018-05-20 21:06:35 +02:00
Michael Natterer 9a4c9b6650 app: add "source", "vendor-id" and "product-id" to GimpDeviceInfo
and display them in GimpDeviceInfoEditor.
2018-05-20 21:06:35 +02:00
Michael Natterer 89a4ea85ef app: port GimpDeviceManager and GimpDeviceInfo to GdkSeat
and also be smarter about what devices we enable by default: enable
all tablet devices and disable all things mouse, they can still be
enabled in the device dialog.
2018-05-20 21:06:35 +02:00
Michael Natterer 3b00ba8f06 app: remove some forgotten #undef GSEAL_ENABLE 2018-05-20 21:06:29 +02:00
Michael Natterer fc440cc4d0 app: port the device sort function to GdkDeviceManager
Also make sure we don't pass around uninitialized keyvals and
modifiers of device keys.
2018-05-20 21:06:27 +02:00
Michael Natterer de3bd90f9a app: introduce struct GimpDeviceKey because GdkDeviceKey is gone 2018-05-20 21:06:27 +02:00
Michael Natterer 0f90d95ab4 app: use GdkDevice accessors 2018-05-20 21:06:27 +02:00
Michael Natterer 2f629072f1 Bug 787919 - Tool options are lost when switching device
GimpDeviceInfo is the only way to store per-device settings like
color, brush etc. It used to be derived from GimpContext and therefore
limited to the context's properties, causing everything else (all
tool-individual options) to be lost on device change.

Derive it from GimpToolPreset instead, so it's capable of storing
arbitrary tool options.

Adapt things to the new class hierarchy and add a bunch of signal
handlers that make sure the active device's GimpDeviceInfo is updated
properly when the tool changes. Also change device switching
accordingly.

Change GimpDeviceStatus to only show the stuff that is relevant to
each device's tool.

And various small changes to make things work properly...
2018-05-16 02:09:19 +02:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
Michael Natterer 0cb3e75f79 app: use a lot of g_clear_object() and g_clear_pointer()
More than 2000 lines of code less in app/, instead of

if (instance->member)
  {
    g_object_unref/g_free/g_whatever (instance->member);
    instance->member = NULL;
  }

we now simply use

g_clear_object/pointer (&instance->member);
2017-07-15 18:42:44 +02:00
Michael Natterer dda54c1df8 Deprecate stock items for good and change all icon defines to GIMP_ICON_*
Try to sort all GIMP_ICON_* defines into FDO categories like in
https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html

Add defines for all icons we override, rename some icons to their FDO
standard names, and mark the ones we duplicate with a comment so we
don't forget to rename those to standard names in 3.0.
2017-03-05 16:01:59 +01:00
Michael Natterer 47ef3be145 Initialize GValues with G_VALUE_INIT instead of { 0, } 2016-03-26 15:59:26 +01:00
Michael Natterer e5b6806fe2 app: port tons of files to the new GIMP_CONFIG_PROP_FOO() macros
and remove lots of labels from calls to gimp_prop_foo_new(). Also
had to manually remove some unwanted labels that are now added
automatically, fixes bug #761880.
2016-02-11 23:46:24 +01:00
Michael Natterer 23037b5230 app: convert all stock IDs kept around by the core by icon names
Particularly GimpViewable's stock_id. Make sure old config files
containing stock IDs are still properly parsed.
2014-05-07 01:01:56 +02:00
Michael Natterer 4e340b613b Bug 688715 - Unconfigured eraser should be set to eraser tool
I don't know what I tested before, but it didn't work. This patch does
the magic in two places, one of which I missed.
2012-11-23 01:17:52 +01:00
Michael Natterer 908f727f0a Chain up unconditionally in GObject::constructed()
It's supported since GLib 2.28.
2012-11-12 21:51:22 +01:00
Michael Natterer 7610e299ae Use GimpValueArray and GimpParamSpecValueArray
instead of the deprecated stuff from GLib.
2012-05-04 00:51:50 +02:00
Michael Natterer 867da8f293 app: add gimp_context_get_foreground,background_pixel()
which takes a Babl format to convert from/to.
Include <gegl.h> in a million places.
2012-05-02 17:50:41 +02:00
Michael Natterer a1712a0ec7 app: emit "changed" when GimpDeviceInfo's device gets (un)set 2011-02-28 16:08:12 +01:00
Michael Natterer 012eb1dd93 app: zero the reallocated keys and axes arrays in GimpDeviceInfo 2011-02-06 11:20:07 +01:00
Michael Natterer 202124c438 app: implement GObject::constructed() instead of ::constructor() 2011-01-14 09:38:46 +01:00
Michael Natterer 5caee48645 app: run all input axes through gimp_device_info_map_axis()
and let that function alone worry about whether there actually is a
curve for that axis.
2010-12-20 20:00:47 +01:00
Michael Natterer 9c98b0b804 app: sort present devices to the beginning of the device list
and make sure the core pointer is always first in the list.
2010-12-09 22:02:24 +01:00
Michael Natterer 8bc0e569ec app: use gimp_object_name_collate() when sorting device names 2010-12-09 21:45:04 +01:00
Michael Natterer d91a1d5b6c app: don't call g_object_set_data() on a NULL object 2010-12-09 20:55:53 +01:00
Michael Natterer 6429c3de1b app: #undef GSEAL_ENABLE to build against the gtk-2-22 branch
GDK structs and objects have been sealed in gtk-2-22, but we can't
use the newly introduced accessors yet.
2010-05-30 17:19:47 +02:00
Michael Natterer 5f0255e269 Add GIMP_STOCK_INPUT_DEVICE icons and use them for the devices dialog
From icon masta Jimmac.
2010-02-19 21:25:24 +01:00
Michael Natterer 53ac78a4a0 app: register the pressure curve are sreialibable property
so it is actually saved to devicerc.
2010-02-18 21:35:45 +01:00
Michael Natterer 7a1b77fb07 app: gimp_device_info_map_axis(): "value" is a double, not a boolean 2010-02-16 19:29:37 +01:00