Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
dialog-events.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/* Authors:
7 * bulia byak <bulia@dr.com>
8 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
9 *
10 * Copyright (C) 2003-2014 Authors
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
15#include <gtkmm/entry.h>
16#include <gtkmm/spinbutton.h>
17#include <gtkmm/window.h>
18#include <gtkmm/version.h>
19
20#ifdef GDK_WINDOWING_X11
21#include <gdk/x11/gdkx.h>
22#endif
23
24#include "desktop.h"
25#include "enums.h"
26#include "inkscape.h"
27#include "preferences.h"
28#include "ui/dialog-events.h"
29
33void sp_dialog_defocus(Gtk::Window *win)
34{
35 // find out the document window we're transient for
36 if (auto w = win->get_transient_for()) {
37 // switch to it
38 w->present();
39 }
40}
41
42void sp_dialog_defocus_on_enter(Gtk::Entry *e)
43{
44 e->signal_activate().connect([e] {
45 sp_dialog_defocus(dynamic_cast<Gtk::Window*>(e->get_root()));
46 });
47}
48
49void sp_dialog_defocus_on_enter(Gtk::SpinButton &s)
50{
51#if GTKMM_CHECK_VERSION(4, 14, 0)
52 s.signal_activate().connect([&] {
53 sp_dialog_defocus(dynamic_cast<Gtk::Window*>(s.get_root()));
54 });
55#endif
56}
57
61void sp_transientize(Gtk::Window &window)
62{
63 auto prefs = Inkscape::Preferences::get();
64
65#ifdef GDK_WINDOWING_X11
66 // FIXME: Temporary Win32 special code to enable transient dialogs
67 // _set_skip_taskbar_hint makes transient dialogs NON-transient! When dialogs
68 // are made transient (_set_transient_for), they are already removed from
69 // the taskbar in Win32.
70 if (prefs->getBool("/options/dialogsskiptaskbar/value")) {
71 // https://discourse.gnome.org/t/how-to-hide-app-from-taskbar-in-gtk4/7084
72 auto root = gtk_widget_get_root(window.Gtk::Widget::gobj());
73 if (GTK_IS_NATIVE(root)) {
74 auto native = GTK_NATIVE(root);
75 auto surface = gtk_native_get_surface(native);
76 if (GDK_IS_X11_SURFACE(surface)) {
77 auto x11surface = GDK_X11_SURFACE(surface);
78 gdk_x11_surface_set_skip_taskbar_hint(x11surface, TRUE);
79 }
80 }
81 }
82#endif
83
84 int transient_policy = prefs->getIntLimited("/options/transientpolicy/value", PREFS_DIALOGS_WINDOWS_NORMAL,
86
87#ifdef _WIN32 // Win32 special code to enable transient dialogs
88 transient_policy = PREFS_DIALOGS_WINDOWS_AGGRESSIVE;
89#endif
90
91 if (transient_policy) {
92 // if there's an active document window, attach dialog to it as a transient:
93 if (SP_ACTIVE_DESKTOP) {
94 SP_ACTIVE_DESKTOP->setWindowTransient(window, transient_policy);
95 }
96 }
97}
98
99/*
100 Local Variables:
101 mode:c++
102 c-file-style:"stroustrup"
103 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
104 indent-tabs-mode:nil
105 fill-column:99
106 End:
107*/
108// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Cairo::RefPtr< Cairo::ImageSurface > surface
Definition canvas.cpp:137
static Preferences * get()
Access the singleton Preferences object.
const double w
Definition conic-4.cpp:19
RootCluster root
Editable view implementation.
void sp_transientize(Gtk::Window &window)
Make the argument dialog transient to the currently active document window.
void sp_dialog_defocus_on_enter(Gtk::Entry *e)
void sp_dialog_defocus(Gtk::Window *win)
Remove focus from window to whoever it is transient for.
Event handler for dialog windows.
@ PREFS_DIALOGS_WINDOWS_NORMAL
Definition enums.h:142
@ PREFS_DIALOGS_WINDOWS_AGGRESSIVE
Definition enums.h:143
@ PREFS_DIALOGS_WINDOWS_NONE
Definition enums.h:141
Singleton class to access the preferences file in a convenient way.