Merge lp:~docky-core/plank/keybindings into lp:plank

Proposed by Rico Tzschichholz
Status: Work in progress
Proposed branch: lp:~docky-core/plank/keybindings
Merge into: lp:plank
Diff against target: 874 lines (+637/-1)
9 files modified
data/net.launchpad.plank.gschema.xml.in.in (+16/-0)
lib/DockController.vala (+18/-0)
lib/DockPreferences.vala (+9/-0)
lib/DockRenderer.vala (+74/-0)
lib/Drawing/DockTheme.vala (+86/-0)
lib/HideManager.vala (+5/-1)
lib/KeybindingManager.vala (+405/-0)
lib/Makefile.am (+1/-0)
lib/libplank.symbols (+23/-0)
To merge this branch: bzr merge lp:~docky-core/plank/keybindings
Reviewer Review Type Date Requested Status
Sergey "Shnatsel" Davidoff Pending
Danielle Foré Pending
Review via email: mp+261315@code.launchpad.net

Description of the change

Add keybindings support

Still considered work-in-progress!
* It is probably better to disable this feature by default.
* Add settings UI changes
* Support bindings for more than 10 items
* Don't stop events with "modifiers" only

To post a comment you must log in.
lp:~docky-core/plank/keybindings updated
1310. By Rico Tzschichholz

drawing: Use Gtk.IconTheme in a thread-safe way

1311. By Rico Tzschichholz

lib: Avoid some superfluous string-copying

1312. By Rico Tzschichholz

dockitem: Add the "surface == null" surface-status

1313. By Rico Tzschichholz

logger: Partial rewrite, with strip down to the "nearly" bare minimum

1314. By Rico Tzschichholz

worker: Make ThreadPool non-exclusive and use GLib.get_num_processors()

1315. By Rico Tzschichholz

filedockitem: Drop unused code

1316. By Rico Tzschichholz

build: Fix make distcheck

1317. By Rico Tzschichholz

drawingservice: Use string-array directly and don't copy to Gee.ArrayList

1318. By Rico Tzschichholz

po: Update translations

1319. By Rico Tzschichholz

src: Use more reasonable class-name and namespace-structure

1320. By Rico Tzschichholz

renderer: Schedule unhide-on-start callback "as late as possible"

1321. By Rico Tzschichholz

dockitem: Schedule icon-theme-changed callback "as late as possible"

1322. By Rico Tzschichholz

drawingservice: Make icon_theme creation thread-safe

1323. By Rico Tzschichholz

renderer: Move frame-time handling into AnimatedRenderer

Make AnimatedRenderer-class responsible to perform and schedule redraws.

1324. By Rico Tzschichholz

animatedrenderer: Use Gdk.FrameClock to determine frame-time

Conditionally use Gdk.FrameClock if Gtk+ >= 3.8 is available

1325. By Rico Tzschichholz

Revert "items: Use threaded icon-drawing for all items"

Too unstable for being usable!

1326. By Rico Tzschichholz

Add RTL support and enable it depending on the locale setting

Reverse items placement.
Mirror position for vertical docks.
Invert alignments for horizonzal docks.
Mirror badge and progress-bar.

1327. By Rico Tzschichholz

po: Update translations

1328. By Rico Tzschichholz

animatedrenderer: Always initialize frame if a redraw is scheduled

1329. By Rico Tzschichholz

po: Update translations

1330. By Rico Tzschichholz

dockrenderer: Guard duration-calculations which are used for animations

1331. By Rico Tzschichholz

Update symbols

1332. By Rico Tzschichholz

color: Avoid double setting of out-vars in hsv_to_rgb

1333. By Rico Tzschichholz

color: Clarify documention of set_min/max_* methods

1334. By Rico Tzschichholz

hidemanager: Add dodge-active hide-mode

1335. By Rico Tzschichholz

prefswindow: Use Gtk.Stack if available

1336. By Rico Tzschichholz

build: Drop dependency on gnome-common

1337. By Rico Tzschichholz

prefswindow: Allow closing the window using "Escape"

1338. By Rico Tzschichholz

po: Update translations

1339. By Rico Tzschichholz

ui: Tweak minimum gtk+ version for conditional 3.4 support

1340. By Rico Tzschichholz

build: Make sure to enable maintainer-mode by default

1341. By Rico Tzschichholz

Add icon-zoom preferences and expose gui-settings

1342. By Rico Tzschichholz

Add optional zoom animation when hovering dock-items

1343. By Rico Tzschichholz

Add ability to cache multiple sizes of drawn items

1344. By Rico Tzschichholz

Update symbols

1345. By Rico Tzschichholz

po: Update translation template

1346. By Rico Tzschichholz

surfacecache: Add missing mutex-unlock

1347. By Rico Tzschichholz

po: Update translations

1348. By Rico Tzschichholz

lib: Make sure to bind "plank" textdomain for library users

1349. By Rico Tzschichholz

lib: Replace non-constant string-concatenation with string.printf()

1350. By Rico Tzschichholz

appdockitem: Always indicate running application despite its window-count

1351. By Rico Tzschichholz

tests: Add google-mock support

1352. By kay van der Zander

gmock: Add tests for Color

1353. By Rico Tzschichholz

hidemanager: Rework enter/leave-event handling to determine "Hovered"

This removes handling of send_event and use "Disabled" for visible menu.

1354. By Rico Tzschichholz

po: Update translations

1355. By Rico Tzschichholz

ui: Fix "Icon Zoom" label spanning

1356. By Rico Tzschichholz

dockwindow: Reinstate "handling of send_event" to fix broken internal DnD

Regression of r1353

1357. By Rico Tzschichholz

surfacecache: Fix build with gee-1.0

1358. By Rico Tzschichholz

dockcontainer: Update element's RemoveTime on add/replace accordingly

1359. By Rico Tzschichholz

lib: Commonize naming of fields which are holding handler/timer-ids

Adjust some explictly typed assignments too.

1360. By Rico Tzschichholz

dockrenderer: Use animated_draw() and don't listen to HoveredItem changes

1361. By Rico Tzschichholz

dockrenderer: Do not forcefully unhide the dock if it already is

If we do it will cause the dock to hide and unhide again on startup.

1362. By Rico Tzschichholz

Revert "dockrenderer: Use animated_draw() and don't listen to HoveredItem changes"

1363. By Rico Tzschichholz

positionmanager: Make item's background-region always cover dock's background from bottom up

1364. By Rico Tzschichholz

po: Update translations

1365. By Rico Tzschichholz

hidemanager: Don't use actual cursor coords of leave-notify-event

If we received a leave-notify-event then don't be silly and make sure
update_hovered_with_coords() will set Hovered to false by passing
(-1, -1).

1366. By Rico Tzschichholz

hidemanager: Reinstate "handling of send_event" to avoid confusion with menu

Regression of r1353

1367. By Rico Tzschichholz

dockrenderer: Output the Cairo.SurfaceType used by Gtk+

1368. By Rico Tzschichholz

positionmanager: Fix background-size calculation with enabled icon-zoom

We need to take the zoomed icon-size into account to properly adjust the
horizontal padding for the background-sizing while differentiating
between first and last item.

1369. By xapantu

hidemanager: Ignore pressure-reveal for 'absolute' input-devices

1370. By Rico Tzschichholz

dockelement: Make using -Werror=pointer-to-int-cast pass

1371. By Rico Tzschichholz

dockwindow: Make using -Werror=unused-result pass

1372. By Rico Tzschichholz

dockrenderer: Adjust shadow-size if window-scale-factor > 1 aka HiDPI

1373. By Rico Tzschichholz

po: Update translations

1374. By Rico Tzschichholz

lib: Cast some callbacks to avoid the creation of wrappers

1375. By Rico Tzschichholz

build: Require cairo >= 1.10

1376. By Rico Tzschichholz

lib: Cast some callbacks to avoid the creation of wrappers

1377. By Rico Tzschichholz

dbusmanager: Fix naming of fields which are holding handler/timer-ids

1378. By Rico Tzschichholz

dockrenderer: Avoid usage of Cairo.SurfaceType.COGL

1379. By Rico Tzschichholz

build: Clean bamf/gtk+ version check

1380. By Rico Tzschichholz

itemfactory: Make get_launcher_from_dockitem() a bit more safer/verbose

1381. By Rico Tzschichholz

dockcontainer: Add remove_all()

1382. By Rico Tzschichholz

dockrenderer: Guard against empty dock (which ideally won't happen)

1383. By Rico Tzschichholz

dockcontroller: Clean out old default-provider after replacing it

1384. By Rico Tzschichholz

dockcontainer: Optimize prepend()

1385. By Rico Tzschichholz

po: Update translations

1386. By Rico Tzschichholz

itemfactory: Avoid a string-copying

1387. By Rico Tzschichholz

positionmanager: Demote criticals of get_draw_value_for_item() to debug/warning

1388. By Rico Tzschichholz

Prepare 0.10.0 release

1389. By Rico Tzschichholz

Back to development

1390. By Mike Gabriel

animatedrenderer: Fix typo in error message

1391. By Rico Tzschichholz

build: Require valac >= 0.24.0 and obsolete conditionals

1392. By Rico Tzschichholz

po: Update translations

1393. By Rico Tzschichholz

po: Update translations

1394. By Rico Tzschichholz

filedockitem: Correctly display filenames with underscores in folder-menu

1395. By Rico Tzschichholz

positionmanager: Just return primary_monitor if empty plug_name was given

1396. By Rico Tzschichholz

positionmanager: Add verbose output for monitor_geo_changed

1397. By Rico Tzschichholz

dockitemprovider: Insert items where the data was dropped

If there is currently no HoveredItem try to determine the nearest one as
drop-point.

1398. By Rico Tzschichholz

lib: Tweak method signature of file-monitor callbacks

1399. By Rico Tzschichholz

lib: FileMonitorEvent is a simple enum not a flag

1400. By Rico Tzschichholz

lib: Avoid some superfluous reference-taking

1401. By Rico Tzschichholz

plankdockitem: Open "preferences" on left-click instead of "about"

1402. By Rico Tzschichholz

defaultappprovider: Don't ignore opened applications if Wnck doesn't know

Better don't rely on Wnck if Bamf reported an opened application. If an
application is for whatever reason replacing or renaming its window on
startup we might drop it while Wnck reports a window-count of 0.

1403. By Rico Tzschichholz

transientdockitem: Delayed reloading of the window-icon if needed

If the window-icon was null on the first try then schedule a 2nd one.

1404. By Rico Tzschichholz

lib: Actually pass e.g. -lm to the linker by adding it to *_LIBADD

1405. By Rico Tzschichholz

po: Update translations

1406. By Rico Tzschichholz

Prepare 0.10.1 release

1407. By Rico Tzschichholz

Back to development

1408. By Rico Tzschichholz

build: Be more rebust for parallel building

1409. By Rico Tzschichholz

dockrenderer: Don't request a redraw if "transient_items" is empty

1410. By Rico Tzschichholz

dockrenderer: Use non-linear transition in/out the "zoom" state

Increase transition-time to 200ms and use cubic-easing.

1411. By Rico Tzschichholz

easing: Some optimization, avoid vala's struct-copying by using pointers

1412. By Rico Tzschichholz

build: Be more rebust for parallel building

1413. By Rico Tzschichholz

easing: Use proper codestyle for ANIMATION_MODES while it is a const

1414. By Rico Tzschichholz

dockrenderer: Factor out jump-calculation into easing_bounce

1415. By Rico Tzschichholz

dockrenderer: Define and use some internal constants

1416. By Rico Tzschichholz

po: Update translations

1417. By Rico Tzschichholz

Add docklets support (internal/private)

Based on initially proposed docky 3.0 branch

1418. By Rico Tzschichholz

Add GSettings support and transition DockPreferences to it

1419. By Rico Tzschichholz

Update symbols

1420. By Rico Tzschichholz

po: Don't translate gschema for now

1421. By Rico Tzschichholz

Drop nested namespaces

1422. By Rico Tzschichholz

Rename DockSurface to Surface

1423. By Rico Tzschichholz

Rename AnimatedRenderer to Renderer

1424. By Rico Tzschichholz

build: Bump api and library version

1425. By Rico Tzschichholz

Keep existing theme and dockitem-files working and update them

1426. By Rico Tzschichholz

Update NEWS

1427. By Rico Tzschichholz

dockitem: Remove merge-conflict cruft

1428. By Danielle Foré

data: Improve strings of GSettings schema

1430. By Rico Tzschichholz

settings: Use unowned var and avoid ref'ing in loop

1431. By Rico Tzschichholz

docklets: Move to public API

1432. By Rico Tzschichholz

docklets: Make Docklet an interface and do follow up changes

1433. By Rico Tzschichholz

Add non-functional docklets-gui

1434. By Rico Tzschichholz

docs: Fix build

1435. By Rico Tzschichholz

build: Fix make distcheck

1436. By Rico Tzschichholz

tests: Set PLANK_DOCKLET_DIRS to docklets builddir for test-environment

1437. By Rico Tzschichholz

build: Add "run" target for conveniently running plank uninstalled

So running "make run" from the top_builddir will start the just built
plank with the required environment variables to actually pick things up
from the current builddir.

1438. By Rico Tzschichholz

services: Don't leak array-container of ObjectClass.list_properties()

ObjectClass.list_properties() transfers the container which needs to be
freed. If valac 0.26 is availble this can be managed.

1439. By Rico Tzschichholz

preferences: Cache various strings to avoid retrieving them several times

1440. By Rico Tzschichholz

settings: Cache class-type-name string

1441. By Rico Tzschichholz

tests: Make sure to use "test1" as dock-name

1442. By Rico Tzschichholz

dockitem: Don't leak array-container of ObjectClass.list_properties()

1443. By Rico Tzschichholz

Add methods to check some desktop environment types

1444. By Rico Tzschichholz

trash: Implement perform_empty_trash()

Only try using Nautilus on "GNOME" and "Unity" enviroments

1445. By Rico Tzschichholz

theme: Add "CascadeHide" option

If true it will cause background and icons to unhide/hide with different
speeds so they will leave/hit the screen-edge at the same time.

1446. By Rico Tzschichholz

po: Update translations

1447. By Rico Tzschichholz

dragmanager: Don't grab input and abort this drag if DragItem is null

1448. By Rico Tzschichholz

dockwindow: Be more persuasive to get the window where is should be

1449. By Rico Tzschichholz

po: Update translations

1450. By Rico Tzschichholz

Use fixed ObjectClass.list_properties() of valac 0.31/32 if available

1451. By Rico Tzschichholz

dockitem: Actually use internal constant ITEM_INVALID_DURATION

1452. By Rico Tzschichholz

po: Make use of "translator-credits" for Gtk.AboutDialog

1453. By Rico Tzschichholz

po: Update translations

1454. By Rico Tzschichholz

lib: Add internal compatibility wrapper for gtk+ 3.19.1+

1455. By Rico Tzschichholz

widgets: Adjust custom widgets for gtk+ 3.19.1+

1456. By Rico Tzschichholz

theme: Create and use custom Gtk.StyleContext

1457. By Rico Tzschichholz

dragmanager: Better handling if the actual selection-data is null

1458. By Rico Tzschichholz

dockitem: Only use file-monitor for "file://"-icon-files

1459. By Rico Tzschichholz

build: Add "run-debug" target for running plank uninstalled within gdb

1460. By Rico Tzschichholz

lib: Move HoverWindow instance into DockController

1461. By Rico Tzschichholz

dragmanager: Show descriptive tooltip on external-dnd actions

1462. By Rico Tzschichholz

dragmanager: desktop-files are special and deserve the drop-to-dock text

1463. By Rico Tzschichholz

po: Update translations

1464. By Rico Tzschichholz

po: Update translations

1465. By Rico Tzschichholz

data: Update appdata to 0.6+ format

1466. By Rico Tzschichholz

appdata: Make "summary" translatable, re-use tweaked desktop-file comment

1467. By Rico Tzschichholz

po: Update translations

1468. By Rico Tzschichholz

Welcome to 2016

1469. By Rico Tzschichholz

Use clamp() instead of min(max())

1470. By Rico Tzschichholz

dockpreferences: No need to notify about external changes of DockItems

1471. By Rico Tzschichholz

dockcontroller: Serialize possible DockItems change on start-up

1472. By Rico Tzschichholz

dockcontroller: Fix r1471 and actually save DockItems change on start-up

1473. By Rico Tzschichholz

color: Fix mess-up of r1469

1474. By Rico Tzschichholz

filedockitem: Hide "Keep in Dock" wile LockItems is enabled

1475. By Rico Tzschichholz

po: Update translations

1476. By Rico Tzschichholz

dockrenderer: Don't apply window-scale-factor twice on foreground-icon-size

Regression of r1343

1477. By Rico Tzschichholz

applicationdockitem: Check LauncherEntry values for actual changes

Also restrict the precision of "progress".

1478. By Rico Tzschichholz

items: Reduce redraw requests on LauncherEntry updates

1479. By Rico Tzschichholz

items: Fix build without dbusmenu-glib

1480. By Rico Tzschichholz

unity: Handle bad LauncherAPI clients which have an insane update-rate

Skip/hold requests if they are arriving within a defined threshold of
32ms after the previous one.

This avoids plank to freeze while not being able to handle all requests.

1481. By Rico Tzschichholz

positionmanager: Expand dock on external-drag without enabled zoom too

Also try harder to insert dropped elements at the actually desired spot.

1482. By Rico Tzschichholz

unity: Allow a specific amount of fast-updates before skipping/delaying

Cope with applications which are firing update-requests for multiple
application-uris at the same time.

1483. By Rico Tzschichholz

Revert "dockpreferences: No need to notify about external changes of DockItems"

This breaks GLib.Settings.bind() so that DockItems never get saved.

1484. By Rico Tzschichholz

Allow and handle uris with "docklet" scheme

1485. By Rico Tzschichholz

tests: Drop PreferencesWindow test

1486. By Rico Tzschichholz

Add some functionality to docklets GUI

Drag'n'drop or double-click a docklet to add it.

1487. By Rico Tzschichholz

settings: Must take reference of matched ParamSpec

Not doing so results in an undefined behaviour while things ran out of
scope when calling GSettings.bind().

This reverts r1430

1488. By Rico Tzschichholz

build: Fix gtk+-3.0 < 3.10 (non-HiDPI)

1489. By Rico Tzschichholz

preferenceswindow: Allow changing the backing DockController

1490. By Rico Tzschichholz

unity: Expose API to handle LauncherEntry DBus clients

1491. By Rico Tzschichholz

po: Update translations

1492. By Rico Tzschichholz

Cast callbacks to GLib.SourceFunc where possible

1493. By Rico Tzschichholz

unity: Use the real sender-name given by NameOwnerChanged

1494. By Rico Tzschichholz

build: Add autogen.sh to tarball

Conveniently rebuild/update the autotools downstream.

1495. By Rico Tzschichholz

po: Update translations

1496. By Rico Tzschichholz

examples: Add UnityClient example

1497. By Rico Tzschichholz

abstractmain: Use new GLib.Application commandline handling API

Require glib >= 2.40

1498. By Rico Tzschichholz

build: Drop support for gee-1.0

1499. By Rico Tzschichholz

build: Drop obsololete glib conditionals and bump vala's target-glib

1500. By Rico Tzschichholz

build: Drop support for gtk+ < 3.10

1501. By Rico Tzschichholz

ui: Use valac's gtktemplate support

1502. By Rico Tzschichholz

po: Update translations

1503. By Rico Tzschichholz

lib: Update symbols

1504. By Rico Tzschichholz

build: Only cairo >= 1.13 is required for HiDPI

1505. By Rico Tzschichholz

tests: Make sure to quit "dock" test application

1506. By Rico Tzschichholz

preferenceswindow: Keep translated "Preferences" string around for now

1507. By Rico Tzschichholz

docktheme: Adjust draw-position item-badge to avoid cropped shadow

1508. By Rico Tzschichholz

positionmanager: Partly restore original icon-zoom

1509. By Rico Tzschichholz

dockitem: Handle file-monitor event where current launcher was target

If "other" of FileMonitorEvent.MOVED matches our current launcher-file
than it got replaced by a new file, so avoid doing anything other than
loading possible new information.

1510. By Rico Tzschichholz

items: Handle "PinnedOnly" in DefaultApplicationDockItemProvider

This is more efficient than doing this in the DockController. Only the
actually effected items are created/purged on a settings change.

1511. By Rico Tzschichholz

factories: Generalize "dockitem-file" loader

1512. By Rico Tzschichholz

items: Add LauncherEntry's transient-items only if allowed

Regression of r1510

1513. By Rico Tzschichholz

Add "simple and experimental" multi-dock support

Running multiple concurrent instances while using "-n|--name"
is still possible.

There are no exposed GUI controls, therefore the newly added
"enabled-docks" settings-key should be used.

1514. By Rico Tzschichholz

items: Add transient-items only if allowed

1515. By Rico Tzschichholz

Update NEWS

1516. By Rico Tzschichholz

po: Update translations

1517. By Rico Tzschichholz

utils: Add internal create_settings() and try_create_settings()

... and make use of them where possible.

1518. By Rico Tzschichholz

utils: Add internal string_split_combine()

1519. By Rico Tzschichholz

utils: Add internal file_is_dockitem()

1520. By Rico Tzschichholz

settings: Allow to specify gsetting's bind-flags

1521. By Rico Tzschichholz

Follow the environment's setting whether to show notifications or not

If false, urgent-bounce and urgent-glow animations are disabled.

1522. By Rico Tzschichholz

lib: Move DockItemDrawValue and its dependencies to top-level namespace

1523. By Rico Tzschichholz

docs: Fix build

1524. By Rico Tzschichholz

controller: If the item-count has changed do a more thorough size-update

1525. By Rico Tzschichholz

positionmanager: Drop redundant call of update_regions()

1526. By Rico Tzschichholz

surfacecache: Force allow-downscale if drawing-time is insanely high

If drawing-time of a single surface exceeds a certains limit (30ms) and
"flags" is NONE then set ALLOW_DOWNSCALE to make it less demanding.

Also mark the created surface, so the DockRenderer can try to ease things
out for later draw requests.

1527. By Rico Tzschichholz

services: Rename internal Offsettings to EnvironmentSettings

1528. By Rico Tzschichholz

Check existence of keys in 3rd-party GSchemas before using them

Accessing a non-existing key is a fatal error for GSettings.

1529. By Rico Tzschichholz

po: Update translations

1530. By Rico Tzschichholz

prefs: Add TooltipsEnabled setting

This controls whether to show tooltips on hovering items with the cursor.
Tooltips showing up to descibe ongoing DnD-actions are not impacted.

It is enabled by default.

1531. By Rico Tzschichholz

hidemanager: TOUCHPAD devices are able to perform pressure on a barrier

1532. By Rico Tzschichholz

preferenceswindow: Hide "auto-pinning" setting

1533. By Rico Tzschichholz

preferenceswindow: Hide "show-dock-item" setting

Make "show-dock-item" default to false

1534. By Rico Tzschichholz

data: Some tweaking of the default themes

1535. By Rico Tzschichholz

Update README

1536. By Rico Tzschichholz

Update NEWS

1537. By Rico Tzschichholz

Prepare 0.11.0 release

1538. By Rico Tzschichholz

Back to development

1539. By Rico Tzschichholz

system: Use DesktopAppInfo.from_filename() to set desktop-filename

If the filename property is not set then an empty string will be send out
via org.gtk.gio.DesktopAppInfo rather than the proper desktop-filename
that we actually have. This is used for startup-notifications by Bamf.

1540. By Rico Tzschichholz

po: Update translations

1541. By Rico Tzschichholz

dockletmanager: Only handle properly named docklet-libraries

1542. By Rico Tzschichholz

controller: Actually emmit elements_changed() to make DBusClient work

1543. By Rico Tzschichholz

vapi: Sync libbamf3.vapi with 0.5.3~bzr0+16.04.20160322.1-0ubuntu1

1544. By Rico Tzschichholz

applicationdockitem: Force indicator-update if running-state changed

1545. By Rico Tzschichholz

applicationdockitem: Use child-* signals of Bamf.View

The window-* signals are emitted too early and the internal window/xid
caches of Bamf aren't updated yet.

1546. By Rico Tzschichholz

po: Update translations

1547. By Rico Tzschichholz

Prepare 0.11.1 release

1548. By Rico Tzschichholz

Back to development

1549. By Rico Tzschichholz

lib: Update symbols

1550. By Rico Tzschichholz

surface: Some minor cleaning

1551. By Rico Tzschichholz

drawing/color: Add support for HSL and some convenience functions

1552. By Rico Tzschichholz

clippy: Pass correct index in menu-item-callback

1553. By Rico Tzschichholz

clippy: text parameter of ClipboardTextReceivedFunc is allowed to be null

1554. By Rico Tzschichholz

po: Update translations

1555. By Rico Tzschichholz

clippy: Need to own the clipboard's content before allowed to clear it

1556. By Rico Tzschichholz

po: Update translations

1557. By Rico Tzschichholz

build: Require valac >= 0.26.0 and drop obsolete conditionals

1558. By Rico Tzschichholz

lib: Use vala's Cairo.Surface.get/set_device_scale() bindings

1559. By Rico Tzschichholz

vapi: Drop internal copy of x11.vapi

1560. By Rico Tzschichholz

lib: Add and enforce some file-count limits

This is just a safe-guard to prevent plank from "blowing up" if we are
about to handle an unreasonable amount of files.

1561. By Rico Tzschichholz

docklets: Fill in some descriptions and not leave them blank

1562. By Rico Tzschichholz

Prepare 0.11.2 release

1563. By Rico Tzschichholz

Back to development

1564. By Rico Tzschichholz

po: Update translations

1565. By Rico Tzschichholz

Add CPUMonitor docklet

1566. By Rico Tzschichholz

po: Update translations

1567. By Rico Tzschichholz

appdata: Add some keywords and translate-url

1568. By Rico Tzschichholz

tests: Fix type mismatch

1569. By Rico Tzschichholz

clippy: Move generic-typed field initializer to construct

1570. By Rico Tzschichholz

po: Update translations

1571. By Rico Tzschichholz

surfacecache: Never clear the cache completely

1572. By Rico Tzschichholz

po: Update translations

1573. By Rico Tzschichholz

Make use of vala's native Regex support where possible

1574. By Rico Tzschichholz

vapi: Avoid "Deprecated" warning for libbamf3

1575. By Rico Tzschichholz

windows: Hide tooltips if the user performed action on a dockitem

Obviously tooltips will be hidden on appearance of the menu. In addition
to that it will hide on click- and scroll-events too now.

This avoids obstructing maybe important windows parts the user wants to
interact with.

1576. By Rico Tzschichholz

appdockitem: Don't over-react on user-visible changes and keep transients

Dropping an running application here is a bit harsh in case of transient
items. If a splashscreen is shown then this bit changes along the
starting process and is fatal for not-pinned items.

1577. By Rico Tzschichholz

appdockitem: Trust bamf with providing us the window-count

1578. By Rico Tzschichholz

filedockitem: Use the file's display-name where possible

This is the proper string to use for user-visible references to a file.

1579. By Rico Tzschichholz

Drop references to gthread-2.0

This is deprecated and obsolete since glib 2.32.0.

1580. By Rico Tzschichholz

logger: Reinstate null-check for non-initialized calling

1581. By Rico Tzschichholz

unity: Fix spelling error

1582. By Rico Tzschichholz

Prepare 0.11.3 release

1583. By Rico Tzschichholz

Back to development

1584. By Rico Tzschichholz

Welcome to 2017

Unmerged revisions

1586. By Rico Tzschichholz

keybindingsmanager: Use gdk_window_add/remove_filter()

1585. By Rico Tzschichholz

Add initial support for Keybindings to access items

There is the possiblity to define base-modifier key to trigger
keybindings-overlay and an additional modifier key for optional
item-action. The first 10 items will have an active binding.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/net.launchpad.plank.gschema.xml.in.in'
--- data/net.launchpad.plank.gschema.xml.in.in 2016-03-09 08:51:55 +0000
+++ data/net.launchpad.plank.gschema.xml.in.in 2017-01-16 09:48:10 +0000
@@ -71,11 +71,27 @@
71 <_summary>Icon Size</_summary>71 <_summary>Icon Size</_summary>
72 <_description>The size of dock items, in pixels.</_description>72 <_description>The size of dock items, in pixels.</_description>
73 </key>73 </key>
74 <key name="item-accelerator" type="s">
75 <default>'Super_L'</default>
76 <_summary>The base modifier-key for item keybinding shortcuts</_summary>
77 <_description></_description>
78 </key>
74 <key name="items-alignment" enum='GtkAlignType'>79 <key name="items-alignment" enum='GtkAlignType'>
75 <default>'center'</default>80 <default>'center'</default>
76 <_summary>The alignment of dock items</_summary>81 <_summary>The alignment of dock items</_summary>
77 <_description>Possible values are "fill", "start", "end", and "center".</_description>82 <_description>Possible values are "fill", "start", "end", and "center".</_description>
78 </key>83 </key>
84 <key name="item-option-accelerator" type="s">
85 <default>'Shift_L'</default>
86 <_summary>The additional modifier-key for optional item keybinding shortcuts</_summary>
87 <_description></_description>
88 </key>
89 <key name="keybinding-unhide-delay" type="i">
90 <range min="0"/>
91 <default>400</default>
92 <_summary>Keybinding unhide delay</_summary>
93 <_description>Length of the delay before showing keybinding-overlay the dock, in milliseconds.</_description>
94 </key>
79 <key name="lock-items" type="b">95 <key name="lock-items" type="b">
80 <default>false</default>96 <default>false</default>
81 <_summary>Lock dock items</_summary>97 <_summary>Lock dock items</_summary>
8298
=== modified file 'lib/DockController.vala'
--- lib/DockController.vala 2016-03-23 19:51:11 +0000
+++ lib/DockController.vala 2017-01-16 09:48:10 +0000
@@ -40,6 +40,7 @@
40 public DockRenderer renderer { get; protected set; }40 public DockRenderer renderer { get; protected set; }
41 public DockWindow window { get; protected set; }41 public DockWindow window { get; protected set; }
42 public HoverWindow hover { get; protected set; }42 public HoverWindow hover { get; protected set; }
43 public KeybindingManager keybinding_manager { get; protected set; }
43 44
44 public DockItemProvider? default_provider { get; private set; }45 public DockItemProvider? default_provider { get; private set; }
45 46
@@ -100,6 +101,7 @@
100 window = new DockWindow (this);101 window = new DockWindow (this);
101 hover = new HoverWindow ();102 hover = new HoverWindow ();
102 renderer = new DockRenderer (this, window);103 renderer = new DockRenderer (this, window);
104 keybinding_manager = new KeybindingManager (this);
103 }105 }
104 106
105 ~DockController ()107 ~DockController ()
@@ -140,6 +142,14 @@
140 renderer.initialize ();142 renderer.initialize ();
141 143
142 window.show_all ();144 window.show_all ();
145
146 // FIXME maybe do this on a separate thread while this takes some time if X is stalling
147 // putting it into an idle at least gives the illusion of starting up fast ;-)
148 Idle.add (() => {
149 keybinding_manager.initialize ();
150
151 return false;
152 });
143 }153 }
144 154
145 /**155 /**
@@ -224,6 +234,14 @@
224 }234 }
225 }235 }
226 236
237 public void virtual_click_item_at (int pos, PopupButton button)
238 {
239 if (visible_items.size < pos + 1)
240 return;
241
242 visible_items[pos].clicked (button, 0, Gtk.get_current_event_time ());
243 }
244
227 protected override void update_visible_elements ()245 protected override void update_visible_elements ()
228 {246 {
229 base.update_visible_elements ();247 base.update_visible_elements ();
230248
=== modified file 'lib/DockPreferences.vala'
--- lib/DockPreferences.vala 2016-03-04 15:54:48 +0000
+++ lib/DockPreferences.vala 2017-01-16 09:48:10 +0000
@@ -90,6 +90,15 @@
90 [Description(nick = "tooltips-enabled", blurb = "Whether to show tooltips when items are hovered.")]90 [Description(nick = "tooltips-enabled", blurb = "Whether to show tooltips when items are hovered.")]
91 public bool TooltipsEnabled { get; set; }91 public bool TooltipsEnabled { get; set; }
92 92
93 [Description(nick = "item-accelerator", blurb = "The base modifier-key for item keybinding shortcuts.")]
94 public string ItemAccelerator { get; set; }
95
96 [Description(nick = "item-option-accelerator", blurb = "The additional modifier-key for optional item keybinding shortcuts.")]
97 public string ItemOptionAccelerator { get; set; }
98
99 [Description(nick = "keybinding-unhide-delay", blurb = "Time (in ms) to wait before showing keybinding-overlay the dock.")]
100 public uint KeybindingUnhideDelay { get; set; }
101
93 /**102 /**
94 * {@inheritDoc}103 * {@inheritDoc}
95 */104 */
96105
=== modified file 'lib/DockRenderer.vala'
--- lib/DockRenderer.vala 2016-06-01 09:48:44 +0000
+++ lib/DockRenderer.vala 2017-01-16 09:48:10 +0000
@@ -29,6 +29,11 @@
29 public DockTheme theme { get; private set; }29 public DockTheme theme { get; private set; }
30 30
31 /**31 /**
32 * If the dock should show the keybindings and which.
33 */
34 public Keybinding VisibleKeybinding { get; set; default = 0; }
35
36 /**
32 * The current progress [0.0..1.0] of the hide-animation of the dock.37 * The current progress [0.0..1.0] of the hide-animation of the dock.
33 */38 */
34 [CCode (notify = false)]39 [CCode (notify = false)]
@@ -62,13 +67,16 @@
62 Surface? indicator_buffer = null;67 Surface? indicator_buffer = null;
63 Surface? urgent_indicator_buffer = null;68 Surface? urgent_indicator_buffer = null;
64 Surface? urgent_glow_buffer = null;69 Surface? urgent_glow_buffer = null;
70 Gee.HashMap<uint, Surface> keybinding_buffers;
65 71
66 int64 last_hide = 0LL;72 int64 last_hide = 0LL;
67 int64 last_hovered_changed = 0LL;73 int64 last_hovered_changed = 0LL;
74 int64 last_keybinding = 0LL;
68 75
69 bool screen_is_composited = false;76 bool screen_is_composited = false;
70 bool show_notifications = true;77 bool show_notifications = true;
71 uint reset_position_manager_timer_id = 0U;78 uint reset_position_manager_timer_id = 0U;
79 uint keybindings_timer_id = 0U;
72 int window_scale_factor = 1;80 int window_scale_factor = 1;
73 bool is_first_frame = true;81 bool is_first_frame = true;
74 bool zoom_changed = false;82 bool zoom_changed = false;
@@ -98,6 +106,7 @@
98 {106 {
99 transient_items = new Gee.HashSet<DockItem> ();107 transient_items = new Gee.HashSet<DockItem> ();
100 current_items = new Gee.ArrayList<unowned DockItem> ();108 current_items = new Gee.ArrayList<unowned DockItem> ();
109 keybinding_buffers = new Gee.HashMap<uint, Surface> ();
101#if BENCHMARK110#if BENCHMARK
102 benchmark = new Gee.ArrayList<string> ();111 benchmark = new Gee.ArrayList<string> ();
103#endif112#endif
@@ -129,6 +138,46 @@
129 controller.window.notify["HoveredItem"].disconnect (animated_draw);138 controller.window.notify["HoveredItem"].disconnect (animated_draw);
130 }139 }
131 140
141 /**
142 * Unhide the dock immediately if needed and show keybindings after a short delay
143 */
144 public void show_keybindings ()
145 {
146 if (keybindings_timer_id > 0U)
147 return;
148
149 keybindings_timer_id = Timeout.add (controller.prefs.KeybindingUnhideDelay, () => {
150 keybindings_timer_id = 0U;
151 last_keybinding = GLib.get_monotonic_time ();
152 VisibleKeybinding |= Keybinding.ITEMS;
153
154 animated_draw ();
155
156 return false;
157 });
158 }
159
160 /**
161 * Hide keybindings immediately and hide the dock if needed
162 */
163 public void hide_keybindings ()
164 {
165 if (keybindings_timer_id > 0U) {
166 Source.remove (keybindings_timer_id);
167 keybindings_timer_id = 0U;
168 }
169
170 if (VisibleKeybinding != 0) {
171 var now = GLib.get_monotonic_time ();
172 if (now - last_keybinding > controller.prefs.KeybindingUnhideDelay * 1000)
173 last_keybinding = now;
174
175 VisibleKeybinding = 0;
176 }
177
178 animated_draw ();
179 }
180
132 void prefs_changed (Object prefs, ParamSpec prop)181 void prefs_changed (Object prefs, ParamSpec prop)
133 {182 {
134 switch (prop.name) {183 switch (prop.name) {
@@ -213,6 +262,8 @@
213 urgent_indicator_buffer = null;262 urgent_indicator_buffer = null;
214 urgent_glow_buffer = null;263 urgent_glow_buffer = null;
215 264
265 keybinding_buffers.clear ();
266
216 animated_draw ();267 animated_draw ();
217 }268 }
218 269
@@ -839,6 +890,26 @@
839 // draw indicators890 // draw indicators
840 if (draw_value.show_indicator && item.Indicator != IndicatorState.NONE)891 if (draw_value.show_indicator && item.Indicator != IndicatorState.NONE)
841 draw_indicator_state (cr, draw_value.hover_region, item.Indicator, item.State);892 draw_indicator_state (cr, draw_value.hover_region, item.Indicator, item.State);
893
894 // draw keybinding overlay
895 var keybinding_time = frame_time - last_keybinding;
896 opacity = double.min (1, keybinding_time / (double) (theme.HideTime * 1000));
897 if (VisibleKeybinding == 0)
898 opacity = 1 - opacity;
899 if (opacity > 0) {
900 //FIXME Use letters for for 10+ items
901 var number = (item.Position + 1) % 10;
902 var is_option = ((VisibleKeybinding & Keybinding.ITEMS_OPTION) == Keybinding.ITEMS_OPTION);
903 var index = (is_option ? number + 1024 : number);
904
905 Surface? keybinding_surface = null;
906 if ((keybinding_surface = keybinding_buffers.get (index)) == null) {
907 keybinding_surface = theme.create_keybinding (icon_size / 2, number.to_string (), item_buffer, is_option);
908 keybinding_buffers.set (index, keybinding_surface);
909 }
910 cr.set_source_surface (keybinding_surface.Internal, draw_region.x + icon_size / 4, draw_region.y + icon_size / 4);
911 cr.paint_with_alpha (opacity);
912 }
842 }913 }
843 914
844 void draw_item_shadow (Cairo.Context cr, DockItem item, DockItemDrawValue draw_value)915 void draw_item_shadow (Cairo.Context cr, DockItem item, DockItemDrawValue draw_value)
@@ -1109,6 +1180,9 @@
1109 return true;1180 return true;
1110 }1181 }
1111 1182
1183 if (frame_time - last_keybinding <= theme.HideTime * 1000)
1184 return true;
1185
1112 if (transient_items.size > 0)1186 if (transient_items.size > 0)
1113 return true;1187 return true;
1114 1188
11151189
=== modified file 'lib/Drawing/DockTheme.vala'
--- lib/Drawing/DockTheme.vala 2016-03-12 15:14:09 +0000
+++ lib/Drawing/DockTheme.vala 2017-01-16 09:48:10 +0000
@@ -276,6 +276,92 @@
276 }276 }
277277
278 /**278 /**
279 * Creates a keybinding overlay
280 *
281 * @param size the size of the surface
282 * @param text the string to show
283 * @param model existing surface to use as basis of new surface
284 * @param is_option slightly different style for another function
285 * @return a new dock surface with the keybinding overlay drawn on it
286 */
287 public Surface create_keybinding (int size, string text, Surface model, bool is_option = false)
288 {
289 Logger.verbose ("DockTheme.create_keybinding (size = %i, text = %s)", size, text);
290
291 var surface = new Surface.with_surface (size, size, model);
292 surface.clear ();
293
294 if (size <= 0)
295 return surface;
296
297 var cr = surface.Context;
298
299 var line_width = 2.0;
300 var padding = Math.ceil (size / 12.0);
301 double x = line_width / 2.0;
302 double y = line_width / 2.0;
303 double height = size - 2 * line_width;
304 double width = size - 2 * line_width;
305
306 cr.set_line_width (line_width);
307
308 Cairo.Pattern stroke, fill;
309
310 // draw outline shadow
311 stroke = new Cairo.Pattern.rgba (0.2, 0.2, 0.2, 0.3);
312 draw_rounded_line (cr, x, y, width + line_width, height, true, true, stroke, null);
313
314 // draw filled gradient with outline
315 stroke = new Cairo.Pattern.linear (0, y, 0, y + height);
316 stroke.add_color_stop_rgba (0.2, 0.0, 0.0, 0.0, 0.9);
317 stroke.add_color_stop_rgba (0.8, 0.0, 0.0, 0.0, 0.8);
318 fill = new Cairo.Pattern.linear (0, y, 0, y + height);
319 fill.add_color_stop_rgba (0.1, 0.0, 0.0, 0.0, 0.8);
320 fill.add_color_stop_rgba (0.9, 0.0, 0.0, 0.0, 0.9);
321 draw_rounded_line (cr, x, y, width, height, true, true, stroke, fill);
322
323 // draw inline highlight
324 if (!is_option)
325 stroke = new Cairo.Pattern.rgba (0.9, 0.9, 0.9, 0.1);
326 else
327 stroke = new Cairo.Pattern.rgba (0.9, 0.9, 0.9, 0.9);
328 draw_rounded_line (cr, x + line_width, y + line_width, width - 2 * line_width, height - 2 * line_width, true, true, stroke, null);
329
330 var layout = new Pango.Layout (Gdk.pango_context_get ());
331 layout.set_width ((int) (width * Pango.SCALE));
332 layout.set_ellipsize (Pango.EllipsizeMode.NONE);
333
334 var font_description = new Gtk.Style ().font_desc;
335 font_description.set_absolute_size ((int) (height * Pango.SCALE));
336 font_description.set_weight (Pango.Weight.BOLD);
337 layout.set_font_description (font_description);
338
339 layout.set_text (text, -1);
340 Pango.Rectangle ink_rect, logical_rect;
341 layout.get_pixel_extents (out ink_rect, out logical_rect);
342
343 var scale = double.min (1.0, double.min ((width - 2.0 * padding - 2.0 * line_width) / (double) logical_rect.width, (height - 2.0 * padding) / (double) logical_rect.height));
344
345 cr.set_source_rgba (1.0, 1.0, 1.0, 0.2);
346
347 cr.move_to (x + Math.floor (width / 2.0 - scale * logical_rect.width / 2.0), y + Math.floor (height / 2.0 - scale * logical_rect.height / 2.0));
348
349 // draw text
350 cr.save ();
351 if (scale < 1)
352 cr.scale (scale, scale);
353
354 cr.set_line_width (line_width);
355 Pango.cairo_layout_path (cr, layout);
356 cr.stroke_preserve ();
357 cr.set_source_rgba (1.0, 1.0, 1.0, 0.95);
358 cr.fill ();
359 cr.restore ();
360
361 return surface;
362 }
363
364 /**
279 * Draws an active glow for an item.365 * Draws an active glow for an item.
280 *366 *
281 * @param surface the surface to draw onto367 * @param surface the surface to draw onto
282368
=== modified file 'lib/HideManager.vala'
--- lib/HideManager.vala 2016-03-08 22:15:30 +0000
+++ lib/HideManager.vala 2017-01-16 09:48:10 +0000
@@ -137,6 +137,8 @@
137 unowned DockWindow window = controller.window;137 unowned DockWindow window = controller.window;
138 unowned Wnck.Screen wnck_screen = Wnck.Screen.get_default ();138 unowned Wnck.Screen wnck_screen = Wnck.Screen.get_default ();
139 139
140 controller.renderer.notify["VisibleKeybinding"].connect (update_hovered);
141
140#if HAVE_BARRIERS142#if HAVE_BARRIERS
141 initialize_barriers_support ();143 initialize_barriers_support ();
142#endif144#endif
@@ -159,6 +161,7 @@
159 unowned Wnck.Screen wnck_screen = Wnck.Screen.get_default ();161 unowned Wnck.Screen wnck_screen = Wnck.Screen.get_default ();
160 162
161 controller.prefs.notify.disconnect (prefs_changed);163 controller.prefs.notify.disconnect (prefs_changed);
164 controller.renderer.notify["VisibleKeybinding"].disconnect (update_hovered);
162 165
163 window.enter_notify_event.disconnect (handle_enter_notify_event);166 window.enter_notify_event.disconnect (handle_enter_notify_event);
164 window.leave_notify_event.disconnect (handle_leave_notify_event);167 window.leave_notify_event.disconnect (handle_leave_notify_event);
@@ -215,6 +218,7 @@
215 unowned PositionManager position_manager = controller.position_manager;218 unowned PositionManager position_manager = controller.position_manager;
216 unowned DockWindow window = controller.window;219 unowned DockWindow window = controller.window;
217 unowned DragManager drag_manager = controller.drag_manager;220 unowned DragManager drag_manager = controller.drag_manager;
221 unowned DockRenderer renderer = controller.renderer;
218 222
219 freeze_notify ();223 freeze_notify ();
220 224
@@ -233,7 +237,7 @@
233 }237 }
234 238
235 // disable hiding if menu is visible or drags are active239 // disable hiding if menu is visible or drags are active
236 var disabled = (window.menu_is_visible () || drag_manager.InternalDragActive || drag_manager.ExternalDragActive);240 var disabled = (window.menu_is_visible () || renderer.VisibleKeybinding > 0 || drag_manager.InternalDragActive || drag_manager.ExternalDragActive);
237 if (Disabled != disabled) {241 if (Disabled != disabled) {
238 Disabled = disabled;242 Disabled = disabled;
239 update_needed = true;243 update_needed = true;
240244
=== added file 'lib/KeybindingManager.vala'
--- lib/KeybindingManager.vala 1970-01-01 00:00:00 +0000
+++ lib/KeybindingManager.vala 2017-01-16 09:48:10 +0000
@@ -0,0 +1,405 @@
1//
2// Copyright (C) 2012 Rico Tzschichholz
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17
18namespace Plank
19{
20 [Flags]
21 public enum Keybinding {
22 ITEMS = 1 << 0,
23 ITEMS_OPTION = 1 << 1
24 }
25
26 /**
27 * This class is in charge to grab keybindings on the X11 display
28 * and filter X11-events and passing on such events to the registed
29 * handler methods.
30 */
31 public class KeybindingManager : GLib.Object
32 {
33 /**
34 * The controller for this dock.
35 */
36 public DockController controller { private get; construct; }
37
38 /**
39 * list of bound keybindings
40 */
41 Gee.ArrayList<Binding> bindings = new Gee.ArrayList<Binding> ();
42
43 /**
44 * locked modifiers used to grab all keys whatever lock key
45 * is pressed.
46 */
47 static uint[] ignored_masks = {
48 0,
49 Gdk.ModifierType.MOD2_MASK, // NUM_LOCK
50 Gdk.ModifierType.LOCK_MASK, // CAPS_LOCK
51 Gdk.ModifierType.MOD5_MASK, // SCROLL_LOCK
52 Gdk.ModifierType.MOD2_MASK | Gdk.ModifierType.LOCK_MASK,
53 Gdk.ModifierType.MOD2_MASK | Gdk.ModifierType.MOD5_MASK,
54 Gdk.ModifierType.LOCK_MASK | Gdk.ModifierType.MOD5_MASK,
55 Gdk.ModifierType.MOD2_MASK | Gdk.ModifierType.LOCK_MASK | Gdk.ModifierType.MOD5_MASK
56 };
57
58 /**
59 * Helper class to store keybinding
60 */
61 class Binding
62 {
63 public string accelerator;
64 public uint8 keycode;
65 public Gdk.ModifierType modifiers;
66 public KeybindingHandlerFunc handler;
67
68 public Binding (string _accelerator, uint8 _keycode,
69 Gdk.ModifierType _modifiers, owned KeybindingHandlerFunc _handler)
70 {
71 accelerator = _accelerator;
72 keycode = _keycode;
73 modifiers = _modifiers;
74 handler = _handler;
75 }
76 }
77
78 /**
79 * Keybinding func needed to bind key to handler
80 *
81 * @param event passing on gdk event
82 */
83 public delegate void KeybindingHandlerFunc (X.Event event);
84
85 public KeybindingManager (DockController controller)
86 {
87 GLib.Object (controller: controller);
88 }
89
90 construct
91 {
92 gdk_window_add_filter (null, (Gdk.FilterFunc) xevent_filter);
93 }
94
95 ~KeybindingManager ()
96 {
97 unbind_all ();
98
99 gdk_window_remove_filter (null, (Gdk.FilterFunc) xevent_filter);
100 }
101
102 public void initialize ()
103 {
104 var item_accel = controller.prefs.ItemAccelerator;
105 var item_option_accel = controller.prefs.ItemOptionAccelerator;
106
107 var mod = KeybindingManager.convert_to_modifier_only (item_accel);
108 var option_mod = KeybindingManager.convert_to_modifier_only (item_option_accel);
109
110 if (controller.prefs.ItemAccelerator == "") {
111 warning ("%s is not a modifier! Keybindings will not be available!", item_accel);
112 return;
113 }
114
115 // bind base accelerator
116 if (!bind (item_accel, controller.renderer.show_keybindings)
117 || !bind ("<Release>" + item_accel, controller.renderer.hide_keybindings)) {
118 warning ("Keybindings will not be available!");
119 return;
120 }
121
122 bind (mod + "1", () => { controller.virtual_click_item_at (0, PopupButton.LEFT); });
123 bind (mod + "2", () => { controller.virtual_click_item_at (1, PopupButton.LEFT); });
124 bind (mod + "3", () => { controller.virtual_click_item_at (2, PopupButton.LEFT); });
125 bind (mod + "4", () => { controller.virtual_click_item_at (3, PopupButton.LEFT); });
126 bind (mod + "5", () => { controller.virtual_click_item_at (4, PopupButton.LEFT); });
127 bind (mod + "6", () => { controller.virtual_click_item_at (5, PopupButton.LEFT); });
128 bind (mod + "7", () => { controller.virtual_click_item_at (6, PopupButton.LEFT); });
129 bind (mod + "8", () => { controller.virtual_click_item_at (7, PopupButton.LEFT); });
130 bind (mod + "9", () => { controller.virtual_click_item_at (8, PopupButton.LEFT); });
131 bind (mod + "0", () => { controller.virtual_click_item_at (9, PopupButton.LEFT); });
132
133 // bind option accelerator
134 if (item_option_accel == "") {
135 warning ("%s is not a modifier! Optional keybindings will not be available!", item_option_accel);
136 return;
137 }
138
139 bind (mod + item_option_accel, () => {
140 controller.renderer.VisibleKeybinding |= Keybinding.ITEMS_OPTION;
141 controller.renderer.animated_draw ();
142 });
143 bind ("<Release>" + mod + item_option_accel, () => {
144 controller.renderer.VisibleKeybinding &= ~Keybinding.ITEMS_OPTION;
145 controller.renderer.animated_draw ();
146 });
147 bind ("<Release>" + option_mod + item_option_accel, controller.renderer.hide_keybindings);
148
149 bind (mod + option_mod + "1", () => { controller.virtual_click_item_at (0, PopupButton.MIDDLE); });
150 bind (mod + option_mod + "2", () => { controller.virtual_click_item_at (1, PopupButton.MIDDLE); });
151 bind (mod + option_mod + "3", () => { controller.virtual_click_item_at (2, PopupButton.MIDDLE); });
152 bind (mod + option_mod + "4", () => { controller.virtual_click_item_at (3, PopupButton.MIDDLE); });
153 bind (mod + option_mod + "5", () => { controller.virtual_click_item_at (4, PopupButton.MIDDLE); });
154 bind (mod + option_mod + "6", () => { controller.virtual_click_item_at (5, PopupButton.MIDDLE); });
155 bind (mod + option_mod + "7", () => { controller.virtual_click_item_at (6, PopupButton.MIDDLE); });
156 bind (mod + option_mod + "8", () => { controller.virtual_click_item_at (7, PopupButton.MIDDLE); });
157 bind (mod + option_mod + "9", () => { controller.virtual_click_item_at (8, PopupButton.MIDDLE); });
158 bind (mod + option_mod + "0", () => { controller.virtual_click_item_at (9, PopupButton.MIDDLE); });
159 }
160
161 /**
162 * Bind accelerator to given handler
163 *
164 * @param accelerator accelerator parsable by Gtk.accelerator_parse
165 * @param handler handler called when given accelerator is pressed
166 * @return wether the bind was successful or not
167 */
168 public bool bind (string accelerator, owned KeybindingHandlerFunc handler)
169 {
170 Logger.verbose ("Binding key " + accelerator);
171
172 // convert accelerator
173 uint keysym;
174 Gdk.ModifierType modmask;
175 Gtk.accelerator_parse (accelerator, out keysym, out modmask);
176
177 unowned X.Display display = Gdk.X11.get_default_xdisplay ();
178 var xid = Gdk.X11.get_default_root_xwindow ();
179
180 uint8 keycode = display.keysym_to_keycode (keysym);
181 if (keycode == 0)
182 return false;
183
184 var keystr = X.keysym_to_string (keysym);
185 if (keystr == null)
186 return false;
187
188 // FIXME somethings is wrong with the SUPER modifier between the GDK and X values
189 // so replace SUPER_MASK with MOD4_MASK
190 if ((modmask & Gdk.ModifierType.SUPER_MASK) == Gdk.ModifierType.SUPER_MASK)
191 modmask = (modmask & ~Gdk.ModifierType.SUPER_MASK) | Gdk.ModifierType.MOD4_MASK;
192
193 // trap XErrors to avoid closing of application
194 // even when grabing of key fails
195 Gdk.error_trap_push ();
196
197 // grab key finally
198 // also grab all keys which are combined with a lock key such NumLock
199 foreach (var ignored_mask in ignored_masks) {
200 Gdk.error_trap_push ();
201 display.grab_key (keycode, modmask | ignored_mask, xid, false, X.GrabMode.Async, X.GrabMode.Async);
202
203 // wait until all X request have been processed
204 Gdk.flush ();
205 var result = Gdk.error_trap_pop ();
206 if (result != X.ErrorCode.SUCCESS) {
207 warning ("Failed to bind key 0x%X ('%s') with modifiers 0x%X", keycode, keystr, modmask);
208 if (result == X.ErrorCode.BAD_ACCESS)
209 debug ("Some other program is already using the key 0x%X ('%s') with modifiers 0x%X as a binding", keycode, keystr, modmask | ignored_mask);
210 return false;
211 }
212 }
213
214 Gdk.error_trap_pop ();
215
216 Logger.verbose ("Successfully bound key 0x%X ('%s') with modifiers 0x%X", keycode, keystr, modmask);
217
218 // if this is a key-released binding then add corresponding modifiermask
219 // for keycode to our modmask if it is a modifier
220 if ((modmask & Gdk.ModifierType.RELEASE_MASK) == Gdk.ModifierType.RELEASE_MASK)
221 modmask |= get_modmask_for_keycode (keycode);
222
223 // store binding
224 var binding = new Binding (accelerator, keycode, modmask, handler);
225 bindings.add (binding);
226
227 return true;
228 }
229
230 /**
231 * Unbind given accelerator.
232 *
233 * @param accelerator accelerator parsable by Gtk.accelerator_parse
234 */
235 public void unbind (string accelerator)
236 {
237 Logger.verbose ("Unbinding key " + accelerator);
238
239 unowned X.Display display = Gdk.X11.get_default_xdisplay ();
240 var xid = Gdk.X11.get_default_root_xwindow ();
241
242 // unbind all keys with given accelerator
243 var remove_bindings = new Gee.ArrayList<Binding> ();
244 foreach (var binding in bindings) {
245 if (str_equal (accelerator, binding.accelerator)) {
246 // if this is a key-released binding then remove corresponding modifiermask
247 // for keycode to our modmask if it is a modifier which we added on bind
248 if ((binding.modifiers & Gdk.ModifierType.RELEASE_MASK) == Gdk.ModifierType.RELEASE_MASK)
249 binding.modifiers &= ~get_modmask_for_keycode (binding.keycode);
250
251 foreach (var ignored_mask in ignored_masks)
252 display.ungrab_key (binding.keycode, binding.modifiers | ignored_mask, xid);
253 remove_bindings.add (binding);
254 }
255 }
256
257 // remove unbound keys
258 bindings.remove_all (remove_bindings);
259 }
260
261 /**
262 * Unbind all registered bindings.
263 */
264 public void unbind_all ()
265 {
266 unowned X.Display display = Gdk.X11.get_default_xdisplay ();
267 var xid = Gdk.X11.get_default_root_xwindow ();
268
269 // unbind all keys
270 foreach (var binding in bindings)
271 foreach (var ignored_mask in ignored_masks) {
272 // if this is a key-released binding then remove corresponding modifiermask
273 // for keycode to our modmask if it is a modifier which we added on bind
274 if ((binding.modifiers & Gdk.ModifierType.RELEASE_MASK) != 0)
275 binding.modifiers &= ~get_modmask_for_keycode (binding.keycode);
276
277 display.ungrab_key (binding.keycode, binding.modifiers | ignored_mask, xid);
278 }
279
280 bindings.clear ();
281 }
282
283 /**
284 * Event filter method needed to fetch X.Events
285 */
286 [CCode (instance_pos = -1)]
287 Gdk.FilterReturn xevent_filter (Gdk.XEvent gdk_xevent, Gdk.Event gdk_event)
288 {
289 var filter_return = Gdk.FilterReturn.CONTINUE;
290 X.Event* xevent = (X.Event*) gdk_xevent;
291
292 if (xevent->type != X.EventType.KeyPress && xevent->type != X.EventType.KeyRelease)
293 return filter_return;
294
295 // remove NumLock, CapsLock and ScrollLock from key state
296 uint event_mods = (xevent->xkey.state & ~(ignored_masks[7]));
297
298 foreach (var binding in bindings) {
299 if (xevent->xkey.keycode != binding.keycode)
300 continue;
301
302 if ((xevent->type == X.EventType.KeyPress && (binding.modifiers == event_mods))
303 || (xevent->type == X.EventType.KeyRelease
304 && (binding.modifiers & Gdk.ModifierType.RELEASE_MASK) == Gdk.ModifierType.RELEASE_MASK
305 && (binding.modifiers & ~Gdk.ModifierType.RELEASE_MASK) == event_mods)) {
306
307 binding.handler (*xevent);
308
309 // don't pass this event any futher
310 filter_return = Gdk.FilterReturn.REMOVE;
311 }
312 }
313
314 return filter_return;
315 }
316
317 /**
318 * Convert the given accelerator to a modifier only accelerator.
319 * This will convert the key to a modifier if possible and append it.
320 *
321 * @param accelerator accelerator parsable by Gtk.accelerator_parse
322 */
323 public static string convert_to_modifier_only (string accelerator)
324 {
325 uint keysym;
326 Gdk.ModifierType modmask;
327 Gtk.accelerator_parse (accelerator, out keysym, out modmask);
328
329 unowned X.Display display = Gdk.X11.get_default_xdisplay ();
330 uint8 keycode = display.keysym_to_keycode (keysym);
331
332 if (keycode > 0)
333 modmask |= get_modmask_for_keycode (keycode);
334
335 return get_accelerator_for_modmask (modmask);
336 }
337
338 static string get_accelerator_for_modmask (Gdk.ModifierType modmask)
339 {
340 string result = "";
341
342 if ((modmask & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK)
343 result += "<Ctrl>";
344 if ((modmask & Gdk.ModifierType.MOD1_MASK) == Gdk.ModifierType.MOD1_MASK)
345 result += "<Alt>";
346 if ((modmask & Gdk.ModifierType.SHIFT_MASK) == Gdk.ModifierType.SHIFT_MASK)
347 result += "<Shift>";
348 if ((modmask & Gdk.ModifierType.META_MASK) == Gdk.ModifierType.META_MASK)
349 result += "<AltGr>";
350 if ((modmask & Gdk.ModifierType.HYPER_MASK) == Gdk.ModifierType.HYPER_MASK)
351 result += "";
352 if (((modmask & Gdk.ModifierType.SUPER_MASK) == Gdk.ModifierType.SUPER_MASK
353 || (modmask & Gdk.ModifierType.MOD4_MASK) == Gdk.ModifierType.MOD4_MASK))
354 result += "<Super>";
355
356 return result;
357 }
358
359 /**
360 * Convert keycode to ModifierType if it is a modifier
361 * otherwise return 0x0
362 */
363 static Gdk.ModifierType get_modmask_for_keycode (uint keycode)
364 {
365 Gdk.ModifierType modmask;
366
367 unowned X.Display display = Gdk.X11.get_default_xdisplay ();
368 var i = 0;
369 var keysym = display.keycode_to_keysym ((uint8)keycode, i);
370
371 switch (keysym) {
372 case Gdk.Key.Control_L:
373 case Gdk.Key.Control_R:
374 modmask = Gdk.ModifierType.CONTROL_MASK;
375 break;
376 case Gdk.Key.Alt_L:
377 case Gdk.Key.Alt_R:
378 modmask = Gdk.ModifierType.MOD1_MASK;
379 break;
380 case Gdk.Key.Shift_L:
381 case Gdk.Key.Shift_R:
382 modmask = Gdk.ModifierType.SHIFT_MASK;
383 break;
384 case Gdk.Key.Meta_L:
385 case Gdk.Key.Meta_R:
386 modmask = Gdk.ModifierType.META_MASK;
387 break;
388 case Gdk.Key.Hyper_L:
389 case Gdk.Key.Hyper_R:
390 modmask = Gdk.ModifierType.HYPER_MASK;
391 break;
392 case Gdk.Key.Super_L:
393 case Gdk.Key.Super_R:
394 // FIXME somethings is wrong with the SUPER modifier between the GDK and X values
395 modmask = Gdk.ModifierType.MOD4_MASK; //Gdk.ModifierType.SUPER_MASK;
396 break;
397 default:
398 modmask = 0x0;
399 break;
400 }
401
402 return modmask;
403 }
404 }
405}
0406
=== modified file 'lib/Makefile.am'
--- lib/Makefile.am 2016-02-28 12:06:16 +0000
+++ lib/Makefile.am 2017-01-16 09:48:10 +0000
@@ -65,6 +65,7 @@
65 DockRenderer.vala \65 DockRenderer.vala \
66 DragManager.vala \66 DragManager.vala \
67 HideManager.vala \67 HideManager.vala \
68 KeybindingManager.vala \
68 PositionManager.vala \69 PositionManager.vala \
69 DBus/Client.vala \70 DBus/Client.vala \
70 DBus/Interfaces.vala \71 DBus/Interfaces.vala \
7172
=== modified file 'lib/libplank.symbols'
--- lib/libplank.symbols 2016-04-10 09:00:49 +0000
+++ lib/libplank.symbols 2017-01-16 09:48:10 +0000
@@ -130,6 +130,7 @@
130plank_dock_controller_get_hide_manager130plank_dock_controller_get_hide_manager
131plank_dock_controller_get_hover131plank_dock_controller_get_hover
132plank_dock_controller_get_Items132plank_dock_controller_get_Items
133plank_dock_controller_get_keybinding_manager
133plank_dock_controller_get_launchers_folder134plank_dock_controller_get_launchers_folder
134plank_dock_controller_get_name135plank_dock_controller_get_name
135plank_dock_controller_get_position_manager136plank_dock_controller_get_position_manager
@@ -143,9 +144,11 @@
143plank_dock_controller_set_drag_manager144plank_dock_controller_set_drag_manager
144plank_dock_controller_set_hide_manager145plank_dock_controller_set_hide_manager
145plank_dock_controller_set_hover146plank_dock_controller_set_hover
147plank_dock_controller_set_keybinding_manager
146plank_dock_controller_set_position_manager148plank_dock_controller_set_position_manager
147plank_dock_controller_set_renderer149plank_dock_controller_set_renderer
148plank_dock_controller_set_window150plank_dock_controller_set_window
151plank_dock_controller_virtual_click_item_at
149plank_dock_element_accept_drop152plank_dock_element_accept_drop
150plank_dock_element_as_uri153plank_dock_element_as_uri
151plank_dock_element_can_accept_drop154plank_dock_element_can_accept_drop
@@ -289,7 +292,10 @@
289plank_dock_preferences_get_HideDelay292plank_dock_preferences_get_HideDelay
290plank_dock_preferences_get_HideMode293plank_dock_preferences_get_HideMode
291plank_dock_preferences_get_IconSize294plank_dock_preferences_get_IconSize
295plank_dock_preferences_get_ItemAccelerator
296plank_dock_preferences_get_ItemOptionAccelerator
292plank_dock_preferences_get_ItemsAlignment297plank_dock_preferences_get_ItemsAlignment
298plank_dock_preferences_get_KeybindingUnhideDelay
293plank_dock_preferences_get_LockItems299plank_dock_preferences_get_LockItems
294plank_dock_preferences_get_Monitor300plank_dock_preferences_get_Monitor
295plank_dock_preferences_get_Offset301plank_dock_preferences_get_Offset
@@ -313,7 +319,10 @@
313plank_dock_preferences_set_HideDelay319plank_dock_preferences_set_HideDelay
314plank_dock_preferences_set_HideMode320plank_dock_preferences_set_HideMode
315plank_dock_preferences_set_IconSize321plank_dock_preferences_set_IconSize
322plank_dock_preferences_set_ItemAccelerator
323plank_dock_preferences_set_ItemOptionAccelerator
316plank_dock_preferences_set_ItemsAlignment324plank_dock_preferences_set_ItemsAlignment
325plank_dock_preferences_set_KeybindingUnhideDelay
317plank_dock_preferences_set_LockItems326plank_dock_preferences_set_LockItems
318plank_dock_preferences_set_Monitor327plank_dock_preferences_set_Monitor
319plank_dock_preferences_set_Offset328plank_dock_preferences_set_Offset
@@ -332,14 +341,19 @@
332plank_dock_renderer_get_local_cursor341plank_dock_renderer_get_local_cursor
333plank_dock_renderer_get_theme342plank_dock_renderer_get_theme
334plank_dock_renderer_get_type343plank_dock_renderer_get_type
344plank_dock_renderer_get_VisibleKeybinding
335plank_dock_renderer_get_zoom_in_progress345plank_dock_renderer_get_zoom_in_progress
346plank_dock_renderer_hide_keybindings
336plank_dock_renderer_initialize347plank_dock_renderer_initialize
337plank_dock_renderer_new348plank_dock_renderer_new
338plank_dock_renderer_reset_buffers349plank_dock_renderer_reset_buffers
350plank_dock_renderer_set_VisibleKeybinding
351plank_dock_renderer_show_keybindings
339plank_dock_renderer_update_local_cursor352plank_dock_renderer_update_local_cursor
340plank_dock_theme_construct353plank_dock_theme_construct
341plank_dock_theme_create_background354plank_dock_theme_create_background
342plank_dock_theme_create_indicator355plank_dock_theme_create_indicator
356plank_dock_theme_create_keybinding
343plank_dock_theme_create_urgent_glow357plank_dock_theme_create_urgent_glow
344plank_dock_theme_draw_active_glow358plank_dock_theme_draw_active_glow
345plank_dock_theme_draw_item_count359plank_dock_theme_draw_item_count
@@ -473,6 +487,15 @@
473plank_item_factory_make_element487plank_item_factory_make_element
474plank_item_factory_new488plank_item_factory_new
475plank_item_state_get_type489plank_item_state_get_type
490plank_keybinding_get_type
491plank_keybinding_manager_bind
492plank_keybinding_manager_construct
493plank_keybinding_manager_convert_to_modifier_only
494plank_keybinding_manager_get_type
495plank_keybinding_manager_initialize
496plank_keybinding_manager_new
497plank_keybinding_manager_unbind
498plank_keybinding_manager_unbind_all
476plank_logger_get_DisplayLevel499plank_logger_get_DisplayLevel
477plank_logger_get_type500plank_logger_get_type
478plank_logger_initialize501plank_logger_initialize

Subscribers

People subscribed via source and target branches

to status/vote changes: