├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── dash.js
├── debian
├── changelog
├── compat
├── control
├── copyright
├── gnome-shell-extension-cosmic-workspaces.install
├── rules
└── source
│ └── format
├── extension.js
├── gestures.js
├── metadata.json
├── overviewControls.js
├── prefs.js
├── schemas
└── org.gnome.shell.extensions.cosmic-workspaces.gschema.xml
├── settings.ui
├── stylesheet.css
├── swipeTracker.js
├── util.js
├── workspace.js
├── workspaceSwitcherPopup.js
├── workspaceThumbnail.js
└── workspacesView.js
/.gitignore:
--------------------------------------------------------------------------------
1 | _build
2 | schemas/gschemas.compiled
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Basic Makefile
2 |
3 | # Retrieve the UUID from ``metadata.json``
4 | UUID = $(shell grep -E '^[ ]*"uuid" :' ./metadata.json | sed 's@^[ ]*"uuid" :[ ]*"\(.\+\)",[ ]*@\1@')
5 |
6 | ifeq ($(XDG_DATA_HOME),)
7 | XDG_DATA_HOME = $(HOME)/.local/share
8 | endif
9 |
10 | ifeq ($(strip $(DESTDIR)),)
11 | INSTALLBASE = $(XDG_DATA_HOME)/gnome-shell/extensions
12 | else
13 | INSTALLBASE = $(DESTDIR)/usr/share/gnome-shell/extensions
14 | endif
15 | INSTALLNAME = $(UUID)
16 |
17 | SRC = $(wildcard *.css) \
18 | $(wildcard *.js) \
19 | $(wildcard *.json) \
20 | $(wildcard *.ui) \
21 | $(wildcard schemas/*.gschema.xml) \
22 | schemas/gschemas.compiled
23 |
24 | $(info UUID is "$(UUID)")
25 |
26 | .PHONY: all clean install zip-file
27 |
28 | all: $(SRC)
29 | rm -rf _build
30 | for i in $^ ; do \
31 | mkdir -p _build/$$(dirname $$i) ; \
32 | cp $$i _build/$$i ; \
33 | done
34 |
35 | schemas/gschemas.compiled: schemas/*.gschema.xml
36 | glib-compile-schemas schemas
37 |
38 | clean:
39 | rm -rf _build
40 |
41 | install: all
42 | rm -rf $(INSTALLBASE)/$(INSTALLNAME)
43 | mkdir -p $(INSTALLBASE)/$(INSTALLNAME)
44 | cp -r _build/* $(INSTALLBASE)/$(INSTALLNAME)/
45 |
46 | zip-file: all
47 | cd _build && zip -qr "../$(UUID)$(VSTRING).zip" .
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vertical Overview
2 |
3 | ## Description
4 | Gnome has had vertically stacked workspaces for a long time. The Gnome 40 update unfortunately made the switch to a horizontal layout. A choice that many Gnome users disagree with. This extension Aims to replace the new Gnome overview with something that resembles the old style.
5 |
6 | ## Preview image
7 | 
8 |
9 | ## Installation:
10 | You install it through [Gnome Extensions](https://extensions.gnome.org/extension/4144/vertical-overview/).
11 |
12 | Or you can install it manually:
13 | ```
14 | git clone https://github.com/pop-os/cosmic-workspaces.git
15 | cd cosmic-workspaces
16 | make
17 | make install
18 | ```
19 |
20 | If you use X11, reload the server (press `Alt-F2` and type `r`).
21 | If you use Wayland, log out and log in.
22 | You can detect your Windowing System in Settings → About.
23 |
24 | Then enable the extension in "Extensions" application or via command:
25 |
26 | ```
27 | gnome-extensions enable cosmic-workspaces@system76.com
28 | ```
29 |
30 | ## FAQ
31 | #### **How do I get back `Super + Page Up/Down` to switch workspaces?**
32 |
33 | @romgrk and @m2-farzan have got you covered Until I get around to adding this:
34 | https://github.com/RensAlthuis/vertical-overview/issues/7#issuecomment-816054137
35 |
36 |
37 |
38 | ## Donations
39 | I never expected this to be something I have to consider. I really don't expect anyone to donate, nor do I want anyone to feel obligated to do so. I do this because I enjoy it and will for sure keeping working on it as long as I can. However multiple people have asked me to make a donation button, so here it is. If you are considering donating, Thank you so much! I really appreciate it.
40 |
41 | [](https://www.paypal.com/donate?hosted_button_id=8JSADCLQR58KJ)
42 |
--------------------------------------------------------------------------------
/dash.js:
--------------------------------------------------------------------------------
1 | const { Clutter, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
2 | const AppDisplay = imports.ui.appDisplay;
3 | const AppFavorites = imports.ui.appFavorites;
4 | const DND = imports.ui.dnd;
5 | const IconGrid = imports.ui.iconGrid;
6 | const Main = imports.ui.main;
7 | const Overview = imports.ui.overview;
8 | const Dash = imports.ui.dash;
9 | const { DashIcon, DashItemContainer, getAppFromSource, DragPlaceholderItem } = imports.ui.dash;
10 |
11 | const Self = imports.misc.extensionUtils.getCurrentExtension();
12 | const Util = Self.imports.util;
13 |
14 | var DASH_ANIMATION_TIME = 200;
15 | var DASH_ITEM_LABEL_SHOW_TIME = 150;
16 | var DASH_ITEM_LABEL_HIDE_TIME = 100;
17 | var DASH_ITEM_HOVER_TIMEOUT = 300;
18 |
19 | const baseIconSizes = [16, 22, 24, 32, 48, 64];
20 |
21 | function override() {
22 | Util.bindSetting('override-dash', (settings, label) => {
23 | if (settings.get_boolean(label)) {
24 | global.vertical_overview.GSFunctions['Dash'] = Util.overrideProto(Dash.Dash.prototype, DashOverride);
25 | global.vertical_overview.GSFunctions['DashItemContainer'] = Util.overrideProto(Dash.DashItemContainer.prototype, DashItemContainerOverride);
26 | set_to_vertical();
27 | Util.bindSetting('dash-max-height', dash_max_height);
28 | Util.bindSetting('hide-dash', hide_dash);
29 | Util.bindSetting('show-apps-on-top', show_apps_on_top);
30 | Util.bindSetting('dash-max-icon-size', dash_max_icon_size);
31 | Util.bindSetting('custom-run-indicator', custom_run_indicator);
32 | Util.bindSetting('dash-move-labels', dash_move_labels);
33 | global.vertical_overview.dash_override = true;
34 | } else {
35 | reset(false);
36 | }
37 | });
38 | }
39 |
40 |
41 | function reset(isDisable) {
42 | if (global.vertical_overview.dash_override) {
43 | set_to_horizontal();
44 | Util.overrideProto(Dash.Dash.prototype, global.vertical_overview.GSFunctions['Dash']);
45 | Util.overrideProto(Dash.DashItemContainer.prototype, global.vertical_overview.GSFunctions['DashItemContainer']);
46 | global.vertical_overview.dash_override = false;
47 |
48 | Util.unbindSetting('dash-max-height', () => {
49 | delete Main.overview._overview._controls.dashMaxHeightScale;
50 | });
51 |
52 | Util.unbindSetting('hide-dash', (settings, label) => {
53 | if (settings.get_boolean(label))
54 | Main.overview._overview._controls.dash.show();
55 | });
56 |
57 | Util.unbindSetting('show-apps-on-top', () => {
58 | let dash = Main.overview._overview._controls.dash;
59 | dash._dashContainer.set_child_at_index(dash._showAppsIcon, 1);
60 | });
61 |
62 | Util.unbindSetting('dash-max-icon-size', () => {
63 | delete Main.overview._overview._controls.dash.maxIconSizeOverride;
64 | });
65 |
66 | Util.unbindSetting('custom-run-indicator', () => {
67 | delete Main.overview._overview._controls.dash.customRunIndicatorEnabled;
68 | });
69 |
70 | Util.unbindSetting('dash-move-labels', () => {
71 | delete global.vertical_overview.dash_move_labels;
72 | });
73 | }
74 | // override-dash shouldn't be unbound unless the extension is disabled,
75 | // otherwise it can't be re-enabled without restarting the extension
76 | if (isDisable)
77 | Util.unbindSetting('override-dash');
78 | }
79 |
80 | function set_to_vertical() {
81 | let dash = Main.overview._overview._controls.dash;
82 | global.vertical_overview.dash_workId = dash._workId;
83 | dash._workId = Main.initializeDeferredWork(dash._box, dash._redisplay.bind(dash));
84 |
85 | dash._box.layout_manager.orientation = Clutter.Orientation.VERTICAL;
86 | dash._dashContainer.layout_manager.orientation = Clutter.Orientation.VERTICAL;
87 | dash._dashContainer.y_expand = false;
88 | dash._dashContainer.x_expand = true;
89 | dash.x_align = Clutter.ActorAlign.START;
90 | dash.y_align = Clutter.ActorAlign.CENTER;
91 |
92 | dash.add_style_class_name("vertical-overview");
93 | if (global.vertical_overview.old_style_enabled && global.vertical_overview.default_old_style_enabled) {
94 | dash.add_style_class_name("vertical-overview-old-dash");
95 | }
96 |
97 | let sizerBox = dash._background.get_children()[0];
98 | sizerBox.clear_constraints();
99 | sizerBox.add_constraint(new Clutter.BindConstraint({
100 | source: dash._showAppsIcon.icon,
101 | coordinate: Clutter.BindCoordinate.WIDTH,
102 | }));
103 | sizerBox.add_constraint(new Clutter.BindConstraint({
104 | source: dash._dashContainer,
105 | coordinate: Clutter.BindCoordinate.HEIGHT,
106 | }));
107 | dash._box.remove_all_children();
108 | dash._separator = null;
109 | dash._queueRedisplay();
110 | }
111 |
112 | function dash_max_height(settings, label) {
113 | Main.overview._overview._controls.layoutManager.dashMaxHeightScale = settings.get_int(label) / 100.0;
114 | }
115 |
116 | function hide_dash(settings, label) {
117 | if (settings.get_boolean(label)) {
118 | Main.overview._overview._controls.dash.hide();
119 | } else {
120 | Main.overview._overview._controls.dash.show();
121 | }
122 | }
123 |
124 | function show_apps_on_top(settings, label) {
125 | let dash = Main.overview._overview._controls.dash;
126 | if (settings.get_boolean(label)) {
127 | dash._dashContainer.set_child_at_index(dash._showAppsIcon, 0);
128 | } else {
129 | dash._dashContainer.set_child_at_index(dash._showAppsIcon, 1);
130 | }
131 | }
132 |
133 | function dash_max_icon_size(settings, label) {
134 | let dash = Main.overview._overview._controls.dash;
135 | dash.maxIconSizeOverride = settings.get_int(label);
136 | dash._queueRedisplay();
137 | }
138 |
139 | function custom_run_indicator(settings, label) {
140 | let dash = Main.overview._overview._controls.dash;
141 | if (settings.get_boolean(label)) {
142 | dash.customRunIndicatorEnabled = true;
143 | } else {
144 | dash.customRunIndicatorEnabled = false;
145 | }
146 |
147 | dash._box.remove_all_children();
148 | dash._separator = null;
149 | dash._queueRedisplay();
150 | }
151 |
152 | function dash_move_labels(settings, label) {
153 | global.vertical_overview.dash_move_labels = settings.get_boolean(label);
154 | }
155 |
156 | function dash_old_style() {
157 | let dash = Main.overview._overview._controls.dash;
158 |
159 | if (global.vertical_overview.dash_override) {
160 | if (global.vertical_overview.default_old_style_enabled) {
161 | dash.add_style_class_name("vertical-overview");
162 | } else {
163 | dash.remove_style_class_name("vertical-overview");
164 | }
165 |
166 | if (global.vertical_overview.old_style_enabled) {
167 | dash.add_style_class_name("vertical-overview-old-dash");
168 | } else {
169 | dash.remove_style_class_name("vertical-overview-old-dash");
170 | }
171 | }
172 | }
173 |
174 | function dash_disable_style() {
175 | let dash = Main.overview._overview._controls.dash;
176 | dash.remove_style_class_name("vertical-overview");
177 | dash.remove_style_class_name("vertical-overview-old-dash");
178 | }
179 |
180 | function set_to_horizontal() {
181 | let dash = Main.overview._overview._controls.dash;
182 | dash._workId = global.vertical_overview.dash_workId; //pretty sure this is a leak, but there no provided way to disconnect these...
183 | dash._box.layout_manager.orientation = Clutter.Orientation.HORIZONTAL;
184 | dash._dashContainer.layout_manager.orientation = Clutter.Orientation.HORIZONTAL;
185 | dash._dashContainer.y_expand = true;
186 | dash._dashContainer.x_expand = false;
187 | dash.x_align = Clutter.ActorAlign.CENTER;
188 | dash.y_align = 0;
189 |
190 | dash_disable_style();
191 |
192 | let sizerBox = dash._background.get_children()[0];
193 | sizerBox.clear_constraints();
194 | sizerBox.add_constraint(new Clutter.BindConstraint({
195 | source: dash._showAppsIcon.icon,
196 | coordinate: Clutter.BindCoordinate.HEIGHT,
197 | }));
198 | sizerBox.add_constraint(new Clutter.BindConstraint({
199 | source: dash._dashContainer,
200 | coordinate: Clutter.BindCoordinate.WIDTH,
201 | }));
202 |
203 | dash._box.remove_all_children();
204 | dash._separator = null;
205 | dash._queueRedisplay();
206 | }
207 |
208 | var DashItemContainerOverride = {
209 | showLabel() {
210 | if (!this._labelText)
211 | return;
212 |
213 | this.label.set_text(this._labelText);
214 | this.label.opacity = 0;
215 | this.label.show();
216 |
217 | let [stageX, stageY] = this.get_transformed_position();
218 |
219 | let x, y;
220 | if(global.vertical_overview.dash_move_labels) {
221 | const itemHeight = this.allocation.get_height();
222 | const labelHeight = this.label.get_height();
223 | const yOffset = Math.floor((itemHeight - labelHeight) / 2);
224 |
225 |
226 | let node = this.label.get_theme_node();
227 | const xOffset = node.get_length('-x-offset');
228 |
229 | x = stageX + this.width + xOffset;
230 | y = Math.clamp(stageY + yOffset, 0, global.stage.height - labelHeight);
231 | } else {
232 | const itemWidth = this.allocation.get_width();
233 |
234 | const labelWidth = this.label.get_width();
235 | const xOffset = Math.floor((itemWidth - labelWidth) / 2);
236 |
237 | let node = this.label.get_theme_node();
238 | const yOffset = node.get_length('-y-offset');
239 |
240 | x = Math.clamp(stageX + xOffset, 0, global.stage.width - labelWidth);
241 | y = stageY - this.label.height - yOffset;
242 | }
243 |
244 | this.label.set_position(x, y);
245 | this.label.ease({
246 | opacity: 255,
247 | duration: DASH_ITEM_LABEL_SHOW_TIME,
248 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
249 | });
250 | }
251 | }
252 |
253 | var DashOverride = {
254 | handleDragOver: function (source, actor, _x, y, _time) {
255 | let app = getAppFromSource(source);
256 |
257 | // Don't allow favoriting of transient apps
258 | if (app == null || app.is_window_backed())
259 | return DND.DragMotionResult.NO_DROP;
260 |
261 | if (!global.settings.is_writable('favorite-apps'))
262 | return DND.DragMotionResult.NO_DROP;
263 |
264 | let favorites = AppFavorites.getAppFavorites().getFavorites();
265 | let numFavorites = favorites.length;
266 |
267 | let favPos = favorites.indexOf(app);
268 |
269 | let children = this._box.get_children();
270 | let numChildren = children.length;
271 | let boxHeight = this._box.height;
272 |
273 | // Keep the placeholder out of the index calculation; assuming that
274 | // the remove target has the same size as "normal" items, we don't
275 | // need to do the same adjustment there.
276 | if (this._dragPlaceholder) {
277 | boxHeight -= this._dragPlaceholder.height;
278 | numChildren--;
279 | }
280 |
281 | // Same with the separator
282 | if (this._separator) {
283 | boxHeight -= this._separator.height;
284 | numChildren--;
285 | }
286 |
287 | let pos;
288 | if (!this._emptyDropTarget)
289 | pos = Math.floor(y * numChildren / boxHeight);
290 | else
291 | pos = 0; // always insert at the top when dash is empty
292 |
293 | // Put the placeholder after the last favorite if we are not
294 | // in the favorites zone
295 | if (pos > numFavorites)
296 | pos = numFavorites;
297 |
298 | if (pos !== this._dragPlaceholderPos && this._animatingPlaceholdersCount === 0) {
299 | this._dragPlaceholderPos = pos;
300 |
301 | // Don't allow positioning before or after self
302 | if (favPos != -1 && (pos == favPos || pos == favPos + 1)) {
303 | this._clearDragPlaceholder();
304 | return DND.DragMotionResult.CONTINUE;
305 | }
306 |
307 | // If the placeholder already exists, we just move
308 | // it, but if we are adding it, expand its size in
309 | // an animation
310 | let fadeIn;
311 | if (this._dragPlaceholder) {
312 | this._dragPlaceholder.destroy();
313 | fadeIn = false;
314 | } else {
315 | fadeIn = true;
316 | }
317 |
318 | this._dragPlaceholder = new DragPlaceholderItem();
319 | this._dragPlaceholder.child.set_width(this.iconSize / 2);
320 | this._dragPlaceholder.child.set_height(this.iconSize);
321 | this._box.insert_child_at_index(this._dragPlaceholder,
322 | this._dragPlaceholderPos);
323 | this._dragPlaceholder.show(fadeIn);
324 | }
325 |
326 | if (!this._dragPlaceholder)
327 | return DND.DragMotionResult.NO_DROP;
328 |
329 | let srcIsFavorite = favPos != -1;
330 |
331 | if (srcIsFavorite)
332 | return DND.DragMotionResult.MOVE_DROP;
333 |
334 | return DND.DragMotionResult.COPY_DROP;
335 | },
336 |
337 | _redisplay: function () {
338 | let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
339 |
340 | let running = this._appSystem.get_running();
341 |
342 | let children = this._box.get_children().filter(actor => {
343 | return actor.child &&
344 | actor.child._delegate &&
345 | actor.child._delegate.app;
346 | });
347 | // Apps currently in the dash
348 | let oldApps = children.map(actor => actor.child._delegate.app);
349 | // Apps supposed to be in the dash
350 | let newApps = [];
351 |
352 | for (let id in favorites)
353 | newApps.push(favorites[id]);
354 |
355 | for (let i = 0; i < running.length; i++) {
356 | let app = running[i];
357 | if (app.get_id() in favorites)
358 | continue;
359 | newApps.push(app);
360 | }
361 |
362 | // Figure out the actual changes to the list of items; we iterate
363 | // over both the list of items currently in the dash and the list
364 | // of items expected there, and collect additions and removals.
365 | // Moves are both an addition and a removal, where the order of
366 | // the operations depends on whether we encounter the position
367 | // where the item has been added first or the one from where it
368 | // was removed.
369 | // There is an assumption that only one item is moved at a given
370 | // time; when moving several items at once, everything will still
371 | // end up at the right position, but there might be additional
372 | // additions/removals (e.g. it might remove all the launchers
373 | // and add them back in the new order even if a smaller set of
374 | // additions and removals is possible).
375 | // If above assumptions turns out to be a problem, we might need
376 | // to use a more sophisticated algorithm, e.g. Longest Common
377 | // Subsequence as used by diff.
378 | let addedItems = [];
379 | let removedActors = [];
380 |
381 | let newIndex = 0;
382 | let oldIndex = 0;
383 | while (newIndex < newApps.length || oldIndex < oldApps.length) {
384 | let oldApp = oldApps.length > oldIndex ? oldApps[oldIndex] : null;
385 | let newApp = newApps.length > newIndex ? newApps[newIndex] : null;
386 |
387 | // No change at oldIndex/newIndex
388 | if (oldApp == newApp) {
389 | oldIndex++;
390 | newIndex++;
391 | continue;
392 | }
393 |
394 | // App removed at oldIndex
395 | if (oldApp && !newApps.includes(oldApp)) {
396 | removedActors.push(children[oldIndex]);
397 | oldIndex++;
398 | continue;
399 | }
400 |
401 | // App added at newIndex
402 | if (newApp && !oldApps.includes(newApp)) {
403 | addedItems.push({
404 | app: newApp,
405 | item: this._createAppItem(newApp),
406 | pos: newIndex
407 | });
408 | newIndex++;
409 | continue;
410 | }
411 |
412 | // App moved
413 | let nextApp = newApps.length > newIndex + 1
414 | ? newApps[newIndex + 1] : null;
415 | let insertHere = nextApp && nextApp == oldApp;
416 | let alreadyRemoved = removedActors.reduce((result, actor) => {
417 | let removedApp = actor.child._delegate.app;
418 | return result || removedApp == newApp;
419 | }, false);
420 |
421 | if (insertHere || alreadyRemoved) {
422 | let newItem = this._createAppItem(newApp);
423 | addedItems.push({
424 | app: newApp,
425 | item: newItem,
426 | pos: newIndex + removedActors.length
427 | });
428 | newIndex++;
429 | } else {
430 | removedActors.push(children[oldIndex]);
431 | oldIndex++;
432 | }
433 | }
434 |
435 | for (let i = 0; i < addedItems.length; i++) {
436 | this._box.insert_child_at_index(addedItems[i].item,
437 | addedItems[i].pos);
438 | }
439 |
440 | for (let i = 0; i < removedActors.length; i++) {
441 | let item = removedActors[i];
442 |
443 | // Don't animate item removal when the overview is transitioning
444 | // or hidden
445 | if (Main.overview.visible && !Main.overview.animationInProgress)
446 | item.animateOutAndDestroy();
447 | else
448 | item.destroy();
449 | }
450 |
451 | this._adjustIconSize();
452 |
453 | // Skip animations on first run when adding the initial set
454 | // of items, to avoid all items zooming in at once
455 |
456 | let animate = this._shownInitially && Main.overview.visible &&
457 | !Main.overview.animationInProgress;
458 |
459 | if (!this._shownInitially)
460 | this._shownInitially = true;
461 |
462 | for (let i = 0; i < addedItems.length; i++)
463 | addedItems[i].item.show(animate);
464 |
465 | // Update separator
466 | const nFavorites = Object.keys(favorites).length;
467 | const nIcons = children.length + addedItems.length - removedActors.length;
468 | if (nFavorites > 0 && nFavorites < nIcons) {
469 | // destroy the horizontal seperator if it exists.
470 | // this is incredibly janky, but I can't think of a better way atm.
471 | if (this._separator && this._separator.height !== 1) {
472 | this._separator.destroy();
473 | this._separator = null;
474 | }
475 |
476 | if (!this._separator) {
477 | this._separator = new St.Widget({
478 | style_class: 'dash-separator',
479 | x_align: Clutter.ActorAlign.CENTER,
480 | y_align: Clutter.ActorAlign.CENTER,
481 | width: this.iconSize,
482 | height: 1
483 | });
484 | this._box.add_child(this._separator)
485 | }
486 |
487 | //FIXME: separator placement is broken (also in original dash)
488 | let pos = nFavorites;
489 | if (this._dragPlaceholder)
490 | pos++;
491 | this._box.set_child_at_index(this._separator, pos);
492 | } else if (this._separator) {
493 | this._separator.destroy();
494 | this._separator = null;
495 | }
496 | // Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=692744
497 | // Without it, StBoxLayout may use a stale size cache
498 | this._box.queue_relayout();
499 | },
500 |
501 | _adjustIconSize: function () {
502 | // For the icon size, we only consider children which are "proper"
503 | // icons (i.e. ignoring drag placeholders) and which are not
504 | // animating out (which means they will be destroyed at the end of
505 | // the animation)
506 | let iconChildren = this._box.get_children().filter(actor => {
507 | return actor.child &&
508 | actor.child._delegate &&
509 | actor.child._delegate.icon &&
510 | !actor.animatingOut;
511 | });
512 |
513 | iconChildren.push(this._showAppsIcon);
514 |
515 | if (this._maxWidth === -1 || this._maxHeight === -1)
516 | return;
517 |
518 | const themeNode = this.get_theme_node();
519 | const maxAllocation = new Clutter.ActorBox({
520 | x1: 0,
521 | y1: 0,
522 | x2: 42, /* not whatever */
523 | y2: this._maxHeight,
524 | });
525 |
526 | let maxContent = themeNode.get_content_box(maxAllocation);
527 | let spacing = themeNode.get_length('spacing');
528 |
529 | let firstButton = iconChildren[0].child;
530 | let firstIcon = firstButton._delegate.icon;
531 |
532 | // Enforce valid spacings during the size request
533 | firstIcon.icon.ensure_style();
534 | const [, , iconWidth, iconHeight] = firstIcon.icon.get_preferred_size();
535 | const [, , buttonWidth, buttonHeight] = firstButton.get_preferred_size();
536 |
537 | let availWidth = this._maxWidth;
538 | availWidth -= this._background.get_theme_node().get_horizontal_padding();
539 | availWidth -= themeNode.get_horizontal_padding();
540 | availWidth -= buttonWidth - iconWidth;
541 |
542 | let availHeight = maxContent.y2 - maxContent.y1;
543 | availHeight -= iconChildren.length * (buttonHeight - iconHeight) +
544 | (iconChildren.length - 1) * spacing;
545 |
546 | const maxIconSize = Math.min(availWidth, availHeight / iconChildren.length);
547 |
548 | let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
549 | let iconSizes = baseIconSizes.map(s => s * scaleFactor);
550 |
551 | let newIconSize = baseIconSizes[0];
552 | for (let i = 0; i < iconSizes.length; i++) {
553 | if (iconSizes[i] <= maxIconSize)
554 | newIconSize = baseIconSizes[i];
555 | }
556 |
557 | if (this.maxIconSizeOverride > 0 && this.maxIconSizeOverride < newIconSize) {
558 | newIconSize = this.maxIconSizeOverride;
559 | }
560 |
561 | if (newIconSize == this.iconSize)
562 | return;
563 |
564 | let oldIconSize = this.iconSize;
565 | this.iconSize = newIconSize;
566 | this.emit('icon-size-changed');
567 |
568 | let scale = oldIconSize / newIconSize;
569 | for (let i = 0; i < iconChildren.length; i++) {
570 | let icon = iconChildren[i].child._delegate.icon;
571 |
572 | // Set the new size immediately, to keep the icons' sizes
573 | // in sync with this.iconSize
574 | icon.setIconSize(this.iconSize);
575 |
576 | // Don't animate the icon size change when the overview
577 | // is transitioning, not visible or when initially filling
578 | // the dash
579 | if (!Main.overview.visible || Main.overview.animationInProgress ||
580 | !this._shownInitially)
581 | continue;
582 |
583 | let [targetWidth, targetHeight] = icon.icon.get_size();
584 |
585 | // Scale the icon's texture to the previous size and
586 | // tween to the new size
587 | icon.icon.set_size(icon.icon.width * scale,
588 | icon.icon.height * scale);
589 |
590 | icon.icon.ease({
591 | width: targetWidth,
592 | height: targetHeight,
593 | duration: DASH_ANIMATION_TIME,
594 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
595 | });
596 | }
597 |
598 | if (this._separator) {
599 | this._separator.ease({
600 | width: this.iconSize,
601 | duration: DASH_ANIMATION_TIME,
602 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
603 | });
604 | }
605 | },
606 |
607 | _createAppItem: function (app) {
608 | let appIcon = new DashIcon(app);
609 |
610 | if (this.customRunIndicatorEnabled) {
611 | let indicator = appIcon._dot;
612 | indicator.x_align = Clutter.ActorAlign.START;
613 | indicator.y_align = null;
614 | }
615 |
616 | appIcon.connect('menu-state-changed',
617 | (o, opened) => {
618 | this._itemMenuStateChanged(item, opened);
619 | });
620 |
621 | let item = new DashItemContainer();
622 | item.setChild(appIcon);
623 |
624 | // Override default AppIcon label_actor, now the
625 | // accessible_name is set at DashItemContainer.setLabelText
626 | appIcon.label_actor = null;
627 | item.setLabelText(app.get_name());
628 |
629 | appIcon.icon.setIconSize(this.iconSize);
630 | this._hookUpLabel(item, appIcon);
631 |
632 | return item;
633 | }
634 | }
635 |
--------------------------------------------------------------------------------
/debian/changelog:
--------------------------------------------------------------------------------
1 | gnome-shell-extension-cosmic-workspaces (0.1.0) impish; urgency=medium
2 |
3 | * Initial release.
4 |
5 | -- Jeremy Soller Tue, 31 Aug 2021 12:41:14 -0600
6 |
--------------------------------------------------------------------------------
/debian/compat:
--------------------------------------------------------------------------------
1 | 10
2 |
--------------------------------------------------------------------------------
/debian/control:
--------------------------------------------------------------------------------
1 | Source: gnome-shell-extension-cosmic-workspaces
2 | Section: gnome
3 | Priority: optional
4 | Maintainer: Jeremy Soller
5 | Build-Depends: debhelper (>= 10), libglib2.0-bin
6 | Standards-Version: 3.9.8
7 | Homepage: https://github.com/pop-os/cosmic-workspaces
8 | Vcs-Git: https://github.com/pop-os/cosmic-workspaces.git
9 |
10 | Package: gnome-shell-extension-cosmic-workspaces
11 | Architecture: all
12 | Depends: gnome-shell (>= 40), ${misc:Depends}
13 | Replaces: gnome-shell-extension-vertical-overview
14 | Breaks: gnome-shell-extension-vertical-overview
15 | Description: Gnome-shell extension to switch to vertical workspace orientation
16 |
--------------------------------------------------------------------------------
/debian/copyright:
--------------------------------------------------------------------------------
1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2 | Upstream-Name: cosmic-workspaces
3 | Source: https://github.com/pop-os/cosmic-workspaces
4 |
5 | Files: *
6 | Copyright: 2021 System76
7 | License: GPLv3
8 |
--------------------------------------------------------------------------------
/debian/gnome-shell-extension-cosmic-workspaces.install:
--------------------------------------------------------------------------------
1 | schemas/org.gnome.shell.extensions.cosmic-workspaces.gschema.xml usr/share/glib-2.0/schemas
2 |
--------------------------------------------------------------------------------
/debian/rules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/make -f
2 | # -*- makefile -*-
3 |
4 | # Uncomment this to turn on verbose mode.
5 | #export DH_VERBOSE=1
6 |
7 | BASEDIR=debian/gnome-shell-extension-cosmic-workspaces/usr/share/gnome-shell/extensions/cosmic-workspaces@system76.com
8 |
9 | %:
10 | dh $@
11 |
12 | override_dh_install:
13 | dh_install
14 | rm -rf $(BASEDIR)/schemas
15 |
--------------------------------------------------------------------------------
/debian/source/format:
--------------------------------------------------------------------------------
1 | 3.0 (native)
2 |
--------------------------------------------------------------------------------
/extension.js:
--------------------------------------------------------------------------------
1 | const __DEBUG__ = true;
2 |
3 | const { Gio, Meta, Shell, Clutter, GObject, Graphene, St } = imports.gi;
4 | const WindowManager = imports.ui.windowManager;
5 | const Main = imports.ui.main;
6 |
7 | const Self = imports.misc.extensionUtils.getCurrentExtension();
8 | const Util = Self.imports.util;
9 | const OverviewControlsOverride = Self.imports.overviewControls;
10 | const WorkspacesViewOverrides = Self.imports.workspacesView;
11 | const WorkspaceThumbnailOverrides = Self.imports.workspaceThumbnail;
12 | const WorkspaceSwitcherPopupOverride = Self.imports.workspaceSwitcherPopup;
13 | const DashOverride = Self.imports.dash;
14 | const Gestures = Self.imports.gestures;
15 | const Background = imports.ui.background;
16 | const WorkspaceOverrides = Self.imports.workspace;
17 |
18 | function init() {
19 | }
20 |
21 | function enable() {
22 | if (__DEBUG__) global.log("[VERTICAL-OVERVIEW] starting overrides");
23 | global.vertical_overview = {};
24 | global.vertical_overview.GSFunctions = {};
25 | bindSettings();
26 |
27 | const settings_schema = Gio.SettingsSchemaSource.get_default().lookup('org.gnome.shell.extensions.pop-cosmic', true);
28 | global.vertical_overview.workspace_picker_left = true;
29 | if (settings_schema !== null) {
30 | const settings = new Gio.Settings({ settings_schema: settings_schema });
31 | global.vertical_overview.cosmic_settings = settings;
32 | settings.connect('changed::workspace-picker-left', (settings, label) => {
33 | global.vertical_overview.workspace_picker_left = settings.get_boolean(label);
34 | });
35 | global.vertical_overview.workspace_picker_left = settings.get_boolean('workspace-picker-left');
36 | }
37 |
38 | OverviewControlsOverride.override();
39 | WorkspacesViewOverrides.override();
40 | WorkspaceThumbnailOverrides.override();
41 | WorkspaceOverrides.override();
42 | Gestures.override();
43 | DashOverride.override();
44 | WorkspaceSwitcherPopupOverride.override();
45 |
46 | //this is the magic function that switches the internal layout to vertical
47 | global.workspace_manager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT, true, -1, 1);
48 |
49 | //rebinding keys is necessary because bound functions don't update if the prototype for that function is changed
50 | rebind_keys(Main.overview._overview._controls);
51 |
52 |
53 | if (__DEBUG__) global.log("[VERTICAL_OVERVIEW] enabled");
54 | }
55 |
56 | function disable() {
57 | if (__DEBUG__) global.log("[VERTICAL-OVERVIEW] resetting overrides");
58 |
59 | OverviewControlsOverride.reset();
60 | WorkspacesViewOverrides.reset();
61 | WorkspaceOverrides.reset();
62 | WorkspaceThumbnailOverrides.reset();
63 | Gestures.reset();
64 | DashOverride.reset(true);
65 | WorkspaceSwitcherPopupOverride.reset();
66 |
67 | rebind_keys(Main.overview._overview._controls);
68 |
69 | global.workspaceManager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT, false, 1, -1);
70 |
71 | delete global.vertical_overview.cosmic_settings;
72 |
73 | for (var key in global.vertical_overview.settings.signals) {
74 | Util.unbindSetting(key);
75 | };
76 |
77 | delete global.vertical_overview;
78 | if (__DEBUG__) global.log("[VERTICAL-OVERVIEW] disabled");
79 | }
80 |
81 | function bindSettings() {
82 | let controlsManager = Main.overview._overview._controls;
83 |
84 | Util.bindSetting('left-offset', (settings, label) => {
85 | controlsManager.layoutManager.leftOffset = settings.get_int(label);
86 | });
87 |
88 | Util.bindSetting('right-offset', (settings, label) => {
89 | controlsManager.layoutManager.rightOffset = settings.get_int(label);
90 | });
91 |
92 | Util.bindSetting('scaling-workspace-background', (settings, label) => {
93 | if (settings.get_boolean(label)) {
94 | WorkspaceOverrides.scalingWorkspaceBackgroundOverride();
95 | } else {
96 | WorkspaceOverrides.scalingWorkspaceBackgroundReset();
97 | }
98 | });
99 |
100 | Util.bindSetting('static-background', (settings, label) => {
101 | if (settings.get_boolean(label)) {
102 | WorkspaceOverrides.staticBackgroundOverride();
103 | } else {
104 | WorkspaceOverrides.staticBackgroundReset();
105 | }
106 | });
107 |
108 | Util.bindSetting('workspace-peek-distance', (settings, label) => {
109 | global.vertical_overview.workspacePeek = settings.get_int(label);
110 | });
111 |
112 | Util.bindSetting('dash-to-panel-left-right-fix', (settings, label) => {
113 | global.vertical_overview.misc_dTPLeftRightFix = settings.get_boolean(label);
114 | });
115 |
116 | Util.bindSetting('default-old-style', (settings, label) => {
117 | global.vertical_overview.default_old_style_enabled = settings.get_boolean(label);
118 | DashOverride.dash_old_style();
119 | WorkspaceThumbnailOverrides.thumbnails_old_style();
120 | });
121 |
122 | Util.bindSetting('old-style', (settings, label) => {
123 | global.vertical_overview.old_style_enabled = settings.get_boolean(label);
124 | DashOverride.dash_old_style();
125 | WorkspaceThumbnailOverrides.thumbnails_old_style();
126 | });
127 |
128 | Util.bindSetting('panel-in-overview', (settings, label) => {
129 | if (settings.get_boolean(label)) {
130 | if (global.vertical_overview.panel_signal_found) {
131 | global.vertical_overview.panel_signal.disconnected = true;
132 | } else {
133 | const callbackString = "()=>{this.add_style_pseudo_class('overview');}";
134 | let i = 0;
135 | while (i < Main.overview._signalConnections.length) {
136 | const signal = Main.overview._signalConnections[i];
137 | if (signal.name == 'showing') {
138 | if (signal.callback.toString().replace(/[\ \n]/g, "") == callbackString) {
139 | global.vertical_overview.panel_signal = signal;
140 | global.vertical_overview.panel_signal_found = true;
141 | signal.disconnected = true;
142 | break;
143 | }
144 | }
145 | i++;
146 | }
147 | }
148 | } else {
149 | if (global.vertical_overview.panel_signal_found) {
150 | global.vertical_overview.panel_signal.disconnected = false;
151 | }
152 | }
153 | });
154 | }
155 |
156 | function rebind_keys(self) {
157 | Main.wm.removeKeybinding('shift-overview-up');
158 | Main.wm.removeKeybinding('shift-overview-down');
159 |
160 | Main.wm.addKeybinding('shift-overview-up',
161 | new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
162 | Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
163 | Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
164 | () => self._shiftState(Meta.MotionDirection.UP));
165 |
166 | Main.wm.addKeybinding('shift-overview-down',
167 | new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
168 | Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
169 | Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
170 | () => self._shiftState(Meta.MotionDirection.DOWN))
171 | }
172 |
--------------------------------------------------------------------------------
/gestures.js:
--------------------------------------------------------------------------------
1 | const { Gio, Meta, Shell, Clutter, GObject } = imports.gi;
2 | const Main = imports.ui.main;
3 |
4 | const Self = imports.misc.extensionUtils.getCurrentExtension();
5 | const SwipeTracker = Self.imports.swipeTracker;
6 |
7 | const USE_3_FINGER_SWIPES = false;
8 |
9 | function override() {
10 | if (USE_3_FINGER_SWIPES) {
11 | global.vertical_overview.swipeTracker = Main.overview._swipeTracker;
12 | global.vertical_overview.swipeTracker.enabled = false;
13 |
14 | const swipeTracker = new SwipeTracker.SwipeTracker(global.stage,
15 | Clutter.Orientation.VERTICAL,
16 | Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
17 | { allowDrag: false, allowScroll: false });
18 | swipeTracker.connect('begin', Main.overview._gestureBegin.bind(Main.overview));
19 | swipeTracker.connect('update', Main.overview._gestureUpdate.bind(Main.overview));
20 | swipeTracker.connect('end', Main.overview._gestureEnd.bind(Main.overview));
21 | Main.overview._swipeTracker = swipeTracker;
22 | } else {
23 | let workspacesDisplay = Main.overview._overview._controls._workspacesDisplay;
24 | global.vertical_overview.swipeTracker = workspacesDisplay._swipeTracker;
25 | global.vertical_overview.swipeTracker.enabled = false;
26 |
27 | const swipeTracker = new SwipeTracker.SwipeTracker(
28 | Main.layoutManager.overviewGroup,
29 | Clutter.Orientation.VERTICAL,
30 | Shell.ActionMode.OVERVIEW,
31 | { allowDrag: false });
32 | swipeTracker.allowLongSwipes = true;
33 | swipeTracker.connect('begin', workspacesDisplay._switchWorkspaceBegin.bind(workspacesDisplay));
34 | swipeTracker.connect('update', workspacesDisplay._switchWorkspaceUpdate.bind(workspacesDisplay));
35 | swipeTracker.connect('end', workspacesDisplay._switchWorkspaceEnd.bind(workspacesDisplay));
36 | workspacesDisplay._swipeTracker = swipeTracker;
37 |
38 |
39 | let workspaceAnimation = Main.wm._workspaceAnimation;
40 | global.vertical_overview.animationSwipeTracker = workspaceAnimation._swipeTracker;
41 | global.vertical_overview.animationSwipeTracker.enabled = false;
42 |
43 | const swipeTrackerAnimation = new SwipeTracker.SwipeTracker(global.stage,
44 | Clutter.Orientation.VERTICAL,
45 | Shell.ActionMode.NORMAL,
46 | { allowDrag: false });
47 | swipeTrackerAnimation.connect('begin', workspaceAnimation._switchWorkspaceBegin.bind(workspaceAnimation));
48 | swipeTrackerAnimation.connect('update', workspaceAnimation._switchWorkspaceUpdate.bind(workspaceAnimation));
49 | swipeTrackerAnimation.connect('end', workspaceAnimation._switchWorkspaceEnd.bind(workspaceAnimation));
50 | workspaceAnimation._swipeTracker = swipeTrackerAnimation;
51 |
52 | global.display.bind_property('compositor-modifiers',
53 | workspaceAnimation._swipeTracker, 'scroll-modifiers',
54 | GObject.BindingFlags.SYNC_CREATE);
55 |
56 | }
57 | }
58 |
59 | function reset() {
60 |
61 | if (USE_3_FINGER_SWIPES) {
62 | var swipeTracker = Main.overview._swipeTracker;
63 | Main.overview._swipeTracker = global.vertical_overview.swipeTracker;
64 | swipeTracker.destroy();
65 | delete swipeTracker;
66 | Main.overview._swipeTracker.enabled = true;
67 | } else {
68 | let workspacesDisplay = Main.overview._overview._controls._workspacesDisplay;
69 | var swipeTracker = workspacesDisplay._swipeTracker;
70 | workspacesDisplay._swipeTracker = global.vertical_overview.swipeTracker;
71 | swipeTracker.destroy();
72 | delete swipeTracker;
73 |
74 | let workspaceAnimation = Main.wm._workspaceAnimation;
75 | let animationSwipeTracker = workspaceAnimation._swipeTracker;
76 | animationSwipeTracker.destroy();
77 | delete animationSwipeTracker;
78 |
79 | workspaceAnimation._swipeTracker = global.vertical_overview.animationSwipeTracker;
80 | workspaceAnimation._swipeTracker.enabled = true;
81 | }
82 |
83 | }
--------------------------------------------------------------------------------
/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "Cosmic Workspaces",
3 | "description" : "Bringing back vertically stacked workspaces",
4 | "original-author": "rens.althuis@gmail.com",
5 | "shell-version" : [
6 | "40",
7 | "41",
8 | "42"
9 | ],
10 | "url" : "",
11 | "uuid" : "cosmic-workspaces@system76.com",
12 | "version" : "6"
13 | }
14 |
--------------------------------------------------------------------------------
/overviewControls.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /* exported ControlsManager */
3 |
4 | const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi;
5 |
6 | const AppDisplay = imports.ui.appDisplay;
7 | const Dash = imports.ui.dash;
8 | const { ExtensionState } = imports.misc.extensionUtils;
9 | const Layout = imports.ui.layout;
10 | const Main = imports.ui.main;
11 | const Overview = imports.ui.overview;
12 | const SearchController = imports.ui.searchController;
13 | const Util = imports.misc.util;
14 | const WindowManager = imports.ui.windowManager;
15 | const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
16 | const WorkspacesView = imports.ui.workspacesView;
17 | const OverviewControls = imports.ui.overviewControls;
18 |
19 | const Self = imports.misc.extensionUtils.getCurrentExtension();
20 | const _Util = Self.imports.util;
21 |
22 | const SMALL_WORKSPACE_RATIO = 0.15;
23 | const DASH_MAX_HEIGHT_RATIO = 0.15;
24 |
25 | const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
26 |
27 | var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
28 |
29 | var ControlsState = {
30 | HIDDEN: 0,
31 | WINDOW_PICKER: 1,
32 | APP_GRID: 2,
33 | };
34 |
35 | function override() {
36 | global.vertical_overview.GSFunctions['ControlsManagerLayout'] = _Util.overrideProto(OverviewControls.ControlsManagerLayout.prototype, ControlsManagerLayoutOverride);
37 | global.vertical_overview.GSFunctions['ControlsManager'] = _Util.overrideProto(OverviewControls.ControlsManager.prototype, ControlsManagerOverride);
38 |
39 | let controlsManager = Main.overview._overview._controls;
40 | global.vertical_overview._updateID = controlsManager._stateAdjustment.connect("notify::value", _updateWorkspacesDisplay.bind(controlsManager));
41 | global.vertical_overview._workspaceDisplayVisibleID = controlsManager._workspacesDisplay.connect("notify::visible", controlsManager._workspacesDisplay._updateWorkspacesViews.bind(controlsManager._workspacesDisplay));
42 | }
43 |
44 | function reset() {
45 | _Util.overrideProto(OverviewControls.ControlsManagerLayout.prototype, global.vertical_overview.GSFunctions['ControlsManagerLayout']);
46 | _Util.overrideProto(OverviewControls.ControlsManager.prototype, global.vertical_overview.GSFunctions['ControlsManager']);
47 |
48 | let controlsManager = Main.overview._overview._controls;
49 | controlsManager._stateAdjustment.disconnect(global.vertical_overview._updateID);
50 | controlsManager._workspacesDisplay.disconnect(global.vertical_overview._workspaceDisplayVisibleID);
51 | controlsManager._workspacesDisplay.reactive = true;
52 | controlsManager._workspacesDisplay.setPrimaryWorkspaceVisible(true);
53 | }
54 |
55 | var ControlsManagerLayoutOverride = {
56 | _computeWorkspacesBoxForState(state, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
57 | const workspaceBox = workAreaBox.copy();
58 | const [startX, startY] = workAreaBox.get_origin();
59 | const [width, height] = workspaceBox.get_size();
60 |
61 | const { spacing } = this;
62 | const { expandFraction } = this._workspacesThumbnails;
63 | const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
64 |
65 | switch (state) {
66 | case ControlsState.HIDDEN:
67 | if (global.vertical_overview.misc_dTPLeftRightFix) {
68 | let [w, h] = Main.layoutManager.panelBox.get_size();
69 | let [x, y] = Main.layoutManager.panelBox.get_transformed_position();
70 | if (x > 0) { // if x > 0 assume panel is on the right side
71 | workspaceBox.set_size(width - w, box.y2);
72 | } else {
73 | workspaceBox.set_origin(w / 2, box.y1);
74 | }
75 | }
76 | break;
77 | case ControlsState.WINDOW_PICKER:
78 | case ControlsState.APP_GRID:
79 | const newWidth = width - this._workspacesThumbnails.width * ( scaleFactor > 1 ? scaleFactor : 2);
80 | const newXOrigin = global.vertical_overview.workspace_picker_left
81 | ? this._workspacesThumbnails.x + this._workspacesThumbnails.width + spacing * 2
82 | : this._workspacesThumbnails.x - newWidth - spacing * 2;
83 | workspaceBox.set_origin(
84 | newXOrigin,
85 | startY + searchHeight + spacing * expandFraction);
86 | workspaceBox.set_size(
87 | newWidth,
88 | height - startY - (searchHeight + spacing * expandFraction) * 2);
89 | break;
90 | }
91 |
92 | return workspaceBox;
93 | },
94 |
95 | _getAppDisplayBoxForState(state, workAreaBox, searchHeight, dashHeight, appGridBox) {
96 | const [startX, startY] = workAreaBox.get_origin();
97 | const [width, height] = workAreaBox.get_size();
98 | const appDisplayBox = new Clutter.ActorBox();
99 | const { spacing } = this;
100 |
101 | switch (state) {
102 | case ControlsState.HIDDEN:
103 | case ControlsState.WINDOW_PICKER:
104 | appDisplayBox.set_origin(startX, workspaceBox.y2);
105 | break;
106 | case ControlsState.APP_GRID:
107 | appDisplayBox.set_origin(startX,
108 | startY + searchHeight + spacing);
109 | break;
110 | }
111 |
112 | appDisplayBox.set_size(width,
113 | height - startY - searchHeight - spacing
114 | );
115 |
116 | return appDisplayBox;
117 | },
118 |
119 | vfunc_allocate: function(container, box) {
120 | const childBox = new Clutter.ActorBox();
121 |
122 | const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
123 | var leftOffset = this.leftOffset * scaleFactor;
124 | let rightOffset = this.rightOffset * scaleFactor;
125 |
126 | const { spacing } = this;
127 |
128 | let startY = 0;
129 |
130 | if (global.vertical_overview.misc_dTPLeftRightFix) {
131 | let [w, h] = Main.layoutManager.panelBox.get_size();
132 | leftOffset -= w;
133 | } else {
134 | if (Main.layoutManager.panelBox.y === Main.layoutManager.primaryMonitor.y) {
135 | startY = Main.layoutManager.panelBox.height;
136 | box.y1 += startY;
137 | }
138 | }
139 |
140 | const [width, height] = box.get_size();
141 | let availableHeight = height;
142 |
143 | // Search entry
144 | const searchHeight = 0;
145 | availableHeight -= spacing;
146 |
147 | // Dash
148 | if (global.vertical_overview.dash_override) {
149 | if (!global.vertical_overview.settings.object.get_boolean('hide-dash')) {
150 | let dashHeight = height * this.dashMaxHeightScale;
151 | this._dash.setMaxSize(leftOffset, dashHeight);
152 | let [, maxDashWidth] = this._dash.get_preferred_width(height);
153 | childBox.set_origin(0, startY);
154 | childBox.set_size(leftOffset, height);
155 | this._dash.allocate(childBox);
156 | }
157 | } else {
158 | const maxDashHeight = Math.round(box.get_height() * DASH_MAX_HEIGHT_RATIO);
159 | this._dash.setMaxSize(width, maxDashHeight);
160 |
161 | let [, dashHeight] = this._dash.get_preferred_height(width);
162 | dashHeight = Math.min(dashHeight, maxDashHeight);
163 | childBox.set_origin(0, startY + height - dashHeight);
164 | childBox.set_size(width, dashHeight);
165 | this._dash.allocate(childBox);
166 |
167 | availableHeight -= dashHeight + spacing;
168 |
169 | }
170 |
171 | // Workspace Thumbnails
172 | if (this._workspacesThumbnails.visible) {
173 | let origin, size;
174 | if (global.vertical_overview.workspace_picker_left) {
175 | origin = [0, startY];
176 | size = [leftOffset, height];
177 | } else {
178 | origin = [width - rightOffset, startY];
179 | size = [rightOffset, height];
180 | }
181 |
182 | const cosmicDock = _Util.getDock();
183 | if (cosmicDock) {
184 | const mainDock = cosmicDock.stateObj.dockManager.mainDock;
185 |
186 | const [, dashHeight] = mainDock.get_preferred_height(width);
187 | const [, dashWidth] = mainDock.get_preferred_width(height);
188 |
189 | if (mainDock.position == St.Side.BOTTOM) {
190 | size[1] -= dashHeight;
191 | } else if (mainDock.position == St.Side.LEFT && global.vertical_overview.workspace_picker_left) {
192 | origin[0] += dashWidth;
193 | } else if (mainDock.position == St.Side.RIGHT && !global.vertical_overview.workspace_picker_left) {
194 | origin[0] -= dashWidth;
195 | }
196 | }
197 |
198 | childBox.set_origin(...origin);
199 | childBox.set_size(...size);
200 |
201 | this._workspacesThumbnails.allocate(childBox);
202 | }
203 |
204 | // Workspaces
205 | let params = [box, startY, searchHeight, leftOffset, rightOffset];
206 | const transitionParams = this._stateAdjustment.getStateTransitionParams();
207 |
208 | // Update cached boxes
209 | for (const state of Object.values(ControlsState)) {
210 | this._cachedWorkspaceBoxes.set(
211 | state, this._computeWorkspacesBoxForState(state, ...params));
212 | }
213 |
214 | let workspacesBox;
215 | if (!transitionParams.transitioning) {
216 | workspacesBox = this._cachedWorkspaceBoxes.get(transitionParams.currentState);
217 | } else {
218 | const initialBox = this._cachedWorkspaceBoxes.get(transitionParams.initialState);
219 | const finalBox = this._cachedWorkspaceBoxes.get(transitionParams.finalState);
220 | workspacesBox = initialBox.interpolate(finalBox, transitionParams.progress);
221 | }
222 |
223 | this._workspacesDisplay.allocate(workspacesBox);
224 |
225 |
226 | // App grid
227 | if (this._appDisplay.visible) {
228 | params = [box, startY, searchHeight];
229 | let appDisplayBox;
230 | if (!transitionParams.transitioning) {
231 | appDisplayBox =
232 | this._getAppDisplayBoxForState(transitionParams.currentState, ...params);
233 | } else {
234 | const initialBox =
235 | this._getAppDisplayBoxForState(transitionParams.initialState, ...params);
236 | const finalBox =
237 | this._getAppDisplayBoxForState(transitionParams.finalState, ...params);
238 |
239 | appDisplayBox = initialBox.interpolate(finalBox, transitionParams.progress);
240 | }
241 |
242 | this._appDisplay.allocate(appDisplayBox);
243 | }
244 |
245 | // Search
246 | childBox.set_origin(leftOffset, startY + searchHeight + spacing);
247 | childBox.set_size(width - leftOffset - rightOffset, availableHeight);
248 | this._searchController.allocate(childBox);
249 | this._runPostAllocation();
250 | }
251 | }
252 |
253 | var ControlsManagerOverride = {
254 | _getFitModeForState: function(state) {
255 | switch (state) {
256 | case ControlsState.HIDDEN:
257 | case ControlsState.WINDOW_PICKER:
258 | return WorkspacesView.FitMode.SINGLE;
259 | case ControlsState.APP_GRID:
260 | return WorkspacesView.FitMode.SINGLE;
261 | default:
262 | return WorkspacesView.FitMode.SINGLE;
263 | }
264 | },
265 |
266 | _getThumbnailsBoxParams: function() {
267 | const { initialState, finalState, progress } =
268 | this._stateAdjustment.getStateTransitionParams();
269 |
270 | const paramsForState = s => {
271 | opacity = 255;
272 | scale = 1;
273 | return { opacity, scale } ;
274 | };
275 |
276 | const initialParams = paramsForState(initialState);
277 | const finalParams = paramsForState(finalState);
278 |
279 | return [
280 | Util.lerp(initialParams.opacity, finalParams.opacity, progress),
281 | Util.lerp(initialParams.scale, finalParams.scale, progress),
282 | ];
283 | },
284 |
285 | _updateThumbnailsBox: function(animate = false) {
286 | const { shouldShow } = this._thumbnailsBox;
287 | const { searchActive } = this._searchController;
288 | const [opacity, scale] = this._getThumbnailsBoxParams();
289 |
290 | const thumbnailsBoxVisible = shouldShow && !searchActive && opacity !== 0 && !Main.overview.dash.showAppsButton.checked;
291 | if (thumbnailsBoxVisible) {
292 | this._thumbnailsBox.opacity = 0;
293 | this._thumbnailsBox.visible = thumbnailsBoxVisible;
294 | }
295 |
296 | const params = {
297 | opacity: searchActive ? 0 : opacity,
298 | duration: animate ? SIDE_CONTROLS_ANIMATION_TIME : 0,
299 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
300 | onComplete: () => (this._thumbnailsBox.visible = thumbnailsBoxVisible)
301 | };
302 |
303 | if (!searchActive) {
304 | params.scale_x = scale;
305 | params.scale_y = scale;
306 | }
307 |
308 | this._thumbnailsBox.ease(params);
309 | },
310 |
311 | animateToOverview: function(state, callback) {
312 | this._ignoreShowAppsButtonToggle = true;
313 |
314 | this._searchController.prepareToEnterOverview();
315 | this._workspacesDisplay.prepareToEnterOverview();
316 |
317 | this._stateAdjustment.value = ControlsState.HIDDEN;
318 |
319 | this._workspacesDisplay.opacity = 255;
320 | this._workspacesDisplay.setPrimaryWorkspaceVisible(!this.dash.showAppsButton.checked);
321 | this._workspacesDisplay.reactive = !this.dash.showAppsButton.checked;
322 |
323 | this._stateAdjustment.ease(state, {
324 | duration: Overview.ANIMATION_TIME,
325 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
326 | onStopped: () => {
327 | if (callback)
328 | callback();
329 | },
330 | });
331 |
332 | this.dash.showAppsButton.checked =
333 | state === ControlsState.APP_GRID;
334 |
335 | this._ignoreShowAppsButtonToggle = false;
336 | }
337 | }
338 |
339 | function _updateWorkspacesDisplay() {
340 | const { initialState, finalState, progress } = this._stateAdjustment.getStateTransitionParams();
341 | const { searchActive } = this._searchController;
342 |
343 | //TODO: fix scaling (or just remove it)
344 | const paramsForState = s => {
345 | let opacity, scale;
346 | switch (s) {
347 | case ControlsState.HIDDEN:
348 | case ControlsState.WINDOW_PICKER:
349 | opacity = 255;
350 | scale = 1;
351 | break;
352 | case ControlsState.APP_GRID:
353 | opacity = 0;
354 | scale = 0.5;
355 | break;
356 | default:
357 | opacity = 255;
358 | scale = 1;
359 | break;
360 | }
361 | return { opacity, scale };
362 | };
363 |
364 | let initialParams = paramsForState(initialState);
365 | let finalParams = paramsForState(finalState);
366 |
367 | let opacity = Math.round(Util.lerp(initialParams.opacity, finalParams.opacity, progress))
368 | let scale = Util.lerp(initialParams.scale, finalParams.scale, progress);
369 |
370 | let workspacesDisplayVisible = (opacity != 0) && !(searchActive);
371 | let params = {
372 | opacity: opacity,
373 | scale: scale,
374 | duration: 0,
375 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
376 | onComplete: () => {
377 | // this._workspacesDisplay.visible = !(progress == 1 && finalState == ControlsState.APP_GRID);
378 | this._workspacesDisplay.reactive = workspacesDisplayVisible;
379 | this._workspacesDisplay.setPrimaryWorkspaceVisible(workspacesDisplayVisible);
380 | }
381 | }
382 |
383 | this._workspacesDisplay.ease(params);
384 | }
385 |
--------------------------------------------------------------------------------
/prefs.js:
--------------------------------------------------------------------------------
1 | const Gdk = imports.gi.Gdk;
2 | const Gio = imports.gi.Gio;
3 | const Gtk = imports.gi.Gtk;
4 |
5 | function open_panel() {
6 | const appinfo = Gio.DesktopAppInfo.new("gnome-desktop-workspaces-panel.desktop");
7 | const launch_ctx = Gdk.Display.get_default().get_app_launch_context();
8 | appinfo.launch([], launch_ctx);
9 | }
10 |
11 | function init() {
12 | }
13 |
14 | function buildPrefsWidget() {
15 | const label = new Gtk.Label({
16 | label: "Configuration for the dock, the top bar, the workspaces overview, and\nother COSMIC components is available in the Settings application.",
17 | justify: Gtk.Justification.CENTER,
18 | });
19 |
20 | const button = new Gtk.Button({
21 | label: "Configure in Settings",
22 | halign: Gtk.Align.CENTER,
23 | });
24 | button.connect("clicked", open_panel);
25 |
26 | const box = new Gtk.Box({
27 | orientation: Gtk.Orientation.VERTICAL,
28 | spacing: 18,
29 | halign: Gtk.Align.CENTER,
30 | valign: Gtk.Align.CENTER,
31 | });
32 | box.append(label);
33 | box.append(button);
34 |
35 | return box;
36 | }
37 |
--------------------------------------------------------------------------------
/schemas/org.gnome.shell.extensions.cosmic-workspaces.gschema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 300
7 |
8 | Distance between left side of the monitor and the workspaces display.
9 | Controls the width of the thumbnails
10 |
11 |
12 |
13 |
14 | 300
15 |
16 | Distance between right side of the monitor and the workspaces display.
17 | Controls the width of the thumbnails
18 |
19 |
20 |
21 |
22 | 0
23 | position of thumbnails in percentage
24 |
25 |
26 |
27 | 80
28 | Maximum height of the dash
29 |
30 |
31 |
32 | false
33 | Move show applications button to the top of dash
34 |
35 |
36 |
37 | 64
38 | Maximum icon size on dash
39 |
40 |
41 |
42 | false
43 | Changes run indicator from dot to bar on the left side of icons
44 |
45 |
46 |
47 | false
48 | Disable if you are use other extensions that override the dash
49 |
50 |
51 |
52 | false
53 | hide the dash
54 |
55 |
56 |
57 | true
58 | add static background
59 |
60 |
61 |
62 | true
63 | scaling workspace background in overview
64 |
65 |
66 |
67 | 0
68 | workspace peek distance in pixels
69 |
70 |
71 |
72 | false
73 | Move the labels in the dash to the right of the icons
74 |
75 |
76 |
77 | false
78 | Fixes for dash to panel
79 |
80 |
81 |
82 | false
83 | Show dash and workspace thumbnails in boxes connected to the sides of the screen
84 |
85 |
86 |
87 | false
88 | Disable this if you're using another pre-40 shell theme
89 |
90 |
91 |
92 | true
93 | Disable top bar turning transparent in overview
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/settings.ui:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
20 |
26 |
32 |
38 |
680 |
681 |
--------------------------------------------------------------------------------
/stylesheet.css:
--------------------------------------------------------------------------------
1 | /* General dash */
2 | #dash.vertical-overview {
3 | margin-right: 5px;
4 | padding: 10px 0;
5 | }
6 |
7 | #dash.vertical-overview .dash-item-container .app-well-app,
8 | #dash.vertical-overview .show-apps {
9 | padding-right: 10px;
10 | padding-top: 2px;
11 | padding-bottom: 2px;
12 | }
13 |
14 | #dash.vertical-overview .dash-separator {
15 | height: 1px;
16 | margin-right: 0;
17 | margin-top: 7px;
18 | margin-bottom: 7px;
19 | background-color: transparentize(#eeeeec, 0.7);
20 | }
21 |
22 | #dash.vertical-overview .overview-icon {
23 | padding: 10px 0;
24 | }
25 |
26 | #dash.vertical-overview .app-well-app-running-dot {
27 | margin: 6px 0px;
28 | }
29 |
30 | /* 40 style dash */
31 | #dash.vertical-overview .dash-item-container:last-child {
32 | margin-bottom: 14px;
33 | }
34 |
35 | #dash.vertical-overview .dash-background {
36 | margin-left: 16px;
37 | }
38 |
39 | #dash.vertical-overview .dash-item-container .app-well-app,
40 | #dash.vertical-overview .show-apps {
41 | padding-left: 26px;
42 | }
43 |
44 | #dash.vertical-overview .dash-separator {
45 | margin-left: 16px;
46 | }
47 |
48 | /* 3.38 style dash */
49 | #dash.vertical-overview.vertical-overview-old-dash {
50 | color: #eeeeec;
51 | background-color: rgba(32, 32, 32, 0.76);
52 | border: 1px solid rgba(255, 255, 255, 0.16);
53 | padding: 0px 0;
54 | border-radius: 0 15px 15px 0;
55 | border-left-width: 0;
56 | }
57 |
58 | #dash.vertical-overview.vertical-overview-old-dash .show-apps:active .overview-icon,
59 | #dash.vertical-overview.vertical-overview-old-dash .show-apps:checked .overview-icon {
60 | background-color: rgba(7, 7, 7, 0.46);
61 | }
62 |
63 | #dash.vertical-overview.vertical-overview-old-dash .dash-item-container:last-child {
64 | margin-bottom: 0px;
65 | }
66 |
67 | #dash.vertical-overview.vertical-overview-old-dash .dash-background {
68 | background: none;
69 | margin-left: 0;
70 | }
71 |
72 | #dash.vertical-overview.vertical-overview-old-dash .dash-item-container .app-well-app,
73 | #dash.vertical-overview.vertical-overview-old-dash .show-apps {
74 | padding-left: 10px;
75 | }
76 |
77 | #dash.vertical-overview.vertical-overview-old-dash .dash-separator {
78 | margin-left: 0px;
79 | }
80 |
81 | /* 3.38 style workspace thumbnails */
82 | .vertical-overview.workspace-thumbnails,
83 | .workspace-thumbnails {
84 | color: #eeeeee;
85 | background-color: rgba(32, 32, 32, 0.65);
86 | padding: 24px;
87 | border-radius: 24px;
88 | margin: 4px;
89 | spacing: 24px;
90 | }
91 |
92 | .workspace-thumbnail-indicator {
93 | border: 4px solid #FBB86C;
94 | border-radius: 8px;
95 | }
96 |
97 | .workspace-thumbnail {
98 | border-radius: 8px;
99 | }
100 |
--------------------------------------------------------------------------------
/swipeTracker.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /* exported SwipeTracker */
3 |
4 | const { Clutter, Gio, GObject, Meta } = imports.gi;
5 |
6 | const Main = imports.ui.main;
7 | const Params = imports.misc.params;
8 |
9 | // FIXME: ideally these values matches physical touchpad size. We can get the
10 | // correct values for gnome-shell specifically, since mutter uses libinput
11 | // directly, but GTK apps cannot get it, so use an arbitrary value so that
12 | // it's consistent with apps.
13 | const TOUCHPAD_BASE_HEIGHT = 300;
14 | const TOUCHPAD_BASE_WIDTH = 400;
15 |
16 | const EVENT_HISTORY_THRESHOLD_MS = 150;
17 |
18 | const SCROLL_MULTIPLIER = 10;
19 | const SWIPE_MULTIPLIER = 0.5;
20 |
21 | const MIN_ANIMATION_DURATION = 100;
22 | const MAX_ANIMATION_DURATION = 400;
23 | const VELOCITY_THRESHOLD_TOUCH = 0.3;
24 | const VELOCITY_THRESHOLD_TOUCHPAD = 0.6;
25 | const DECELERATION_TOUCH = 0.998;
26 | const DECELERATION_TOUCHPAD = 0.997;
27 | const VELOCITY_CURVE_THRESHOLD = 2;
28 | const DECELERATION_PARABOLA_MULTIPLIER = 0.35;
29 | const DRAG_THRESHOLD_DISTANCE = 16;
30 |
31 | // Derivative of easeOutCubic at t=0
32 | const DURATION_MULTIPLIER = 3;
33 | const ANIMATION_BASE_VELOCITY = 0.002;
34 | const EPSILON = 0.005;
35 |
36 | const GESTURE_FINGER_COUNT = 4;
37 |
38 | const State = {
39 | NONE: 0,
40 | SCROLLING: 1,
41 | };
42 |
43 | const TouchpadState = {
44 | NONE: 0,
45 | PENDING: 1,
46 | HANDLING: 2,
47 | IGNORED: 3,
48 | };
49 |
50 | const EventHistory = class {
51 | constructor() {
52 | this.reset();
53 | }
54 |
55 | reset() {
56 | this._data = [];
57 | }
58 |
59 | trim(time) {
60 | const thresholdTime = time - EVENT_HISTORY_THRESHOLD_MS;
61 | const index = this._data.findIndex(r => r.time >= thresholdTime);
62 |
63 | this._data.splice(0, index);
64 | }
65 |
66 | append(time, delta) {
67 | this.trim(time);
68 |
69 | this._data.push({ time, delta });
70 | }
71 |
72 | calculateVelocity() {
73 | if (this._data.length < 2)
74 | return 0;
75 |
76 | const firstTime = this._data[0].time;
77 | const lastTime = this._data[this._data.length - 1].time;
78 |
79 | if (firstTime === lastTime)
80 | return 0;
81 |
82 | const totalDelta = this._data.slice(1).map(a => a.delta).reduce((a, b) => a + b);
83 | const period = lastTime - firstTime;
84 |
85 | return totalDelta / period;
86 | }
87 | };
88 |
89 | const TouchpadSwipeGesture = GObject.registerClass({
90 | Properties: {
91 | 'enabled': GObject.ParamSpec.boolean(
92 | 'enabled', 'enabled', 'enabled',
93 | GObject.ParamFlags.READWRITE,
94 | true),
95 | 'orientation': GObject.ParamSpec.enum(
96 | 'orientation', 'orientation', 'orientation',
97 | GObject.ParamFlags.READWRITE,
98 | Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
99 | },
100 | Signals: {
101 | 'begin': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
102 | 'update': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
103 | 'end': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE] },
104 | },
105 | }, class TouchpadSwipeGesture extends GObject.Object {
106 | _init(allowedModes) {
107 | super._init();
108 | this._allowedModes = allowedModes;
109 | this._state = TouchpadState.NONE;
110 | this._cumulativeX = 0;
111 | this._cumulativeY = 0;
112 | this._touchpadSettings = new Gio.Settings({
113 | schema_id: 'org.gnome.desktop.peripherals.touchpad',
114 | });
115 |
116 | this._stageCaptureEvent =
117 | global.stage.connect('captured-event::touchpad', this._handleEvent.bind(this));
118 | }
119 |
120 | _handleEvent(actor, event) {
121 | if (event.type() !== Clutter.EventType.TOUCHPAD_SWIPE)
122 | return Clutter.EVENT_PROPAGATE;
123 |
124 | if (event.get_gesture_phase() === Clutter.TouchpadGesturePhase.BEGIN)
125 | this._state = TouchpadState.NONE;
126 |
127 | if (event.get_touchpad_gesture_finger_count() !== GESTURE_FINGER_COUNT)
128 | return Clutter.EVENT_PROPAGATE;
129 |
130 | if ((this._allowedModes & Main.actionMode) === 0)
131 | return Clutter.EVENT_PROPAGATE;
132 |
133 | if (!this.enabled)
134 | return Clutter.EVENT_PROPAGATE;
135 |
136 | if (this._state === TouchpadState.IGNORED)
137 | return Clutter.EVENT_PROPAGATE;
138 |
139 | let time = event.get_time();
140 |
141 | const [x, y] = event.get_coords();
142 | let [dx, dy] = event.get_gesture_motion_delta();
143 |
144 | if (this._state === TouchpadState.NONE) {
145 | if (dx === 0 && dy === 0)
146 | return Clutter.EVENT_PROPAGATE;
147 |
148 | this._cumulativeX = 0;
149 | this._cumulativeY = 0;
150 | this._state = TouchpadState.PENDING;
151 | }
152 |
153 | if (this._state === TouchpadState.PENDING) {
154 | this._cumulativeX += dx * SWIPE_MULTIPLIER;
155 | this._cumulativeY += dy * SWIPE_MULTIPLIER;
156 |
157 | const cdx = this._cumulativeX;
158 | const cdy = this._cumulativeY;
159 | const distance = Math.sqrt(cdx * cdx + cdy * cdy);
160 |
161 | if (distance >= DRAG_THRESHOLD_DISTANCE) {
162 | const gestureOrientation = Math.abs(cdx) > Math.abs(cdy)
163 | ? Clutter.Orientation.HORIZONTAL
164 | : Clutter.Orientation.VERTICAL;
165 |
166 | this._cumulativeX = 0;
167 | this._cumulativeY = 0;
168 |
169 | if (gestureOrientation === this.orientation) {
170 | this._state = TouchpadState.HANDLING;
171 | this.emit('begin', time, x, y);
172 | } else {
173 | this._state = TouchpadState.IGNORED;
174 | return Clutter.EVENT_PROPAGATE;
175 | }
176 | } else {
177 | return Clutter.EVENT_PROPAGATE;
178 | }
179 | }
180 |
181 | const vertical = this.orientation === Clutter.Orientation.VERTICAL;
182 | let delta = (vertical ? dy : dx) * SWIPE_MULTIPLIER;
183 | const distance = vertical ? TOUCHPAD_BASE_HEIGHT : TOUCHPAD_BASE_WIDTH;
184 |
185 | switch (event.get_gesture_phase()) {
186 | case Clutter.TouchpadGesturePhase.BEGIN:
187 | case Clutter.TouchpadGesturePhase.UPDATE:
188 | if (this._touchpadSettings.get_boolean('natural-scroll'))
189 | delta = -delta;
190 |
191 | this.emit('update', time, delta, distance);
192 | break;
193 |
194 | case Clutter.TouchpadGesturePhase.END:
195 | case Clutter.TouchpadGesturePhase.CANCEL:
196 | this.emit('end', time, distance);
197 | this._state = TouchpadState.NONE;
198 | break;
199 | }
200 |
201 | return this._state === TouchpadState.HANDLING
202 | ? Clutter.EVENT_STOP
203 | : Clutter.EVENT_PROPAGATE;
204 | }
205 |
206 | destroy() {
207 | if (this._stageCaptureEvent) {
208 | global.stage.disconnect(this._stageCaptureEvent);
209 | delete this._stageCaptureEvent;
210 | }
211 | }
212 | });
213 |
214 | const TouchSwipeGesture = GObject.registerClass({
215 | Properties: {
216 | 'distance': GObject.ParamSpec.double(
217 | 'distance', 'distance', 'distance',
218 | GObject.ParamFlags.READWRITE,
219 | 0, Infinity, 0),
220 | 'orientation': GObject.ParamSpec.enum(
221 | 'orientation', 'orientation', 'orientation',
222 | GObject.ParamFlags.READWRITE,
223 | Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
224 | },
225 | Signals: {
226 | 'begin': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
227 | 'update': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
228 | 'end': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE] },
229 | 'cancel': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE] },
230 | },
231 | }, class TouchSwipeGesture extends Clutter.GestureAction {
232 | _init(allowedModes, nTouchPoints, thresholdTriggerEdge) {
233 | super._init();
234 | this.set_n_touch_points(nTouchPoints);
235 | this.set_threshold_trigger_edge(thresholdTriggerEdge);
236 |
237 | this._allowedModes = allowedModes;
238 | this._distance = global.screen_height;
239 |
240 | global.display.connect('grab-op-begin', () => {
241 | this.cancel();
242 | });
243 |
244 | this._lastPosition = 0;
245 | }
246 |
247 | get distance() {
248 | return this._distance;
249 | }
250 |
251 | set distance(distance) {
252 | if (this._distance === distance)
253 | return;
254 |
255 | this._distance = distance;
256 | this.notify('distance');
257 | }
258 |
259 | vfunc_gesture_prepare(actor) {
260 | if (!super.vfunc_gesture_prepare(actor))
261 | return false;
262 |
263 | if ((this._allowedModes & Main.actionMode) === 0)
264 | return false;
265 |
266 | let time = this.get_last_event(0).get_time();
267 | let [xPress, yPress] = this.get_press_coords(0);
268 | let [x, y] = this.get_motion_coords(0);
269 | const [xDelta, yDelta] = [x - xPress, y - yPress];
270 | const swipeOrientation = Math.abs(xDelta) > Math.abs(yDelta)
271 | ? Clutter.Orientation.HORIZONTAL : Clutter.Orientation.VERTICAL;
272 |
273 | if (swipeOrientation !== this.orientation)
274 | return false;
275 |
276 | this._lastPosition =
277 | this.orientation === Clutter.Orientation.VERTICAL ? y : x;
278 |
279 | this.emit('begin', time, xPress, yPress);
280 | return true;
281 | }
282 |
283 | vfunc_gesture_progress(_actor) {
284 | let [x, y] = this.get_motion_coords(0);
285 | let pos = this.orientation === Clutter.Orientation.VERTICAL ? y : x;
286 |
287 | let delta = pos - this._lastPosition;
288 | this._lastPosition = pos;
289 |
290 | let time = this.get_last_event(0).get_time();
291 |
292 | this.emit('update', time, -delta, this._distance);
293 |
294 | return true;
295 | }
296 |
297 | vfunc_gesture_end(_actor) {
298 | let time = this.get_last_event(0).get_time();
299 |
300 | this.emit('end', time, this._distance);
301 | }
302 |
303 | vfunc_gesture_cancel(_actor) {
304 | let time = Clutter.get_current_event_time();
305 |
306 | this.emit('cancel', time, this._distance);
307 | }
308 | });
309 |
310 | const ScrollGesture = GObject.registerClass({
311 | Properties: {
312 | 'enabled': GObject.ParamSpec.boolean(
313 | 'enabled', 'enabled', 'enabled',
314 | GObject.ParamFlags.READWRITE,
315 | true),
316 | 'orientation': GObject.ParamSpec.enum(
317 | 'orientation', 'orientation', 'orientation',
318 | GObject.ParamFlags.READWRITE,
319 | Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
320 | 'scroll-modifiers': GObject.ParamSpec.flags(
321 | 'scroll-modifiers', 'scroll-modifiers', 'scroll-modifiers',
322 | GObject.ParamFlags.READWRITE,
323 | Clutter.ModifierType, 0),
324 | },
325 | Signals: {
326 | 'begin': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
327 | 'update': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
328 | 'end': { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE] },
329 | },
330 | }, class ScrollGesture extends GObject.Object {
331 | _init(actor, allowedModes) {
332 | super._init();
333 | this._allowedModes = allowedModes;
334 | this._began = false;
335 | this._enabled = true;
336 |
337 | actor.connect('scroll-event', this._handleEvent.bind(this));
338 | }
339 |
340 | get enabled() {
341 | return this._enabled;
342 | }
343 |
344 | set enabled(enabled) {
345 | if (this._enabled === enabled)
346 | return;
347 |
348 | this._enabled = enabled;
349 | this._began = false;
350 |
351 | this.notify('enabled');
352 | }
353 |
354 | canHandleEvent(event) {
355 | if (event.type() !== Clutter.EventType.SCROLL)
356 | return false;
357 |
358 | if (event.get_scroll_source() !== Clutter.ScrollSource.FINGER &&
359 | event.get_source_device().get_device_type() !== Clutter.InputDeviceType.TOUCHPAD_DEVICE)
360 | return false;
361 |
362 | if (!this.enabled)
363 | return false;
364 |
365 | if ((this._allowedModes & Main.actionMode) === 0)
366 | return false;
367 |
368 | if (this.scrollModifiers !== 0 &&
369 | (event.get_state() & this.scrollModifiers) === 0)
370 | return false;
371 |
372 | return true;
373 | }
374 |
375 | _handleEvent(actor, event) {
376 | if (!this.canHandleEvent(event))
377 | return Clutter.EVENT_PROPAGATE;
378 |
379 | if (event.get_scroll_direction() !== Clutter.ScrollDirection.SMOOTH)
380 | return Clutter.EVENT_PROPAGATE;
381 |
382 | const vertical = this.orientation === Clutter.Orientation.VERTICAL;
383 | const distance = vertical ? TOUCHPAD_BASE_HEIGHT : TOUCHPAD_BASE_WIDTH;
384 |
385 | let time = event.get_time();
386 | let [dx, dy] = event.get_scroll_delta();
387 | if (dx === 0 && dy === 0) {
388 | this.emit('end', time, distance);
389 | this._began = false;
390 | return Clutter.EVENT_STOP;
391 | }
392 |
393 | if (!this._began) {
394 | let [x, y] = event.get_coords();
395 | this.emit('begin', time, x, y);
396 | this._began = true;
397 | }
398 |
399 | const delta = (vertical ? dy : dx) * SCROLL_MULTIPLIER;
400 |
401 | this.emit('update', time, delta, distance);
402 |
403 | return Clutter.EVENT_STOP;
404 | }
405 | });
406 |
407 | // USAGE:
408 | //
409 | // To correctly implement the gesture, there must be handlers for the following
410 | // signals:
411 | //
412 | // begin(tracker, monitor)
413 | // The handler should check whether a deceleration animation is currently
414 | // running. If it is, it should stop the animation (without resetting
415 | // progress). Then it should call:
416 | // tracker.confirmSwipe(distance, snapPoints, currentProgress, cancelProgress)
417 | // If it's not called, the swipe would be ignored.
418 | // The parameters are:
419 | // * distance: the page size;
420 | // * snapPoints: an (sorted with ascending order) array of snap points;
421 | // * currentProgress: the current progress;
422 | // * cancelprogress: a non-transient value that would be used if the gesture
423 | // is cancelled.
424 | // If no animation was running, currentProgress and cancelProgress should be
425 | // same. The handler may set 'orientation' property here.
426 | //
427 | // update(tracker, progress)
428 | // The handler should set the progress to the given value.
429 | //
430 | // end(tracker, duration, endProgress)
431 | // The handler should animate the progress to endProgress. If endProgress is
432 | // 0, it should do nothing after the animation, otherwise it should change the
433 | // state, e.g. change the current page or switch workspace.
434 | // NOTE: duration can be 0 in some cases, in this case it should finish
435 | // instantly.
436 |
437 | /** A class for handling swipe gestures */
438 | var SwipeTracker = GObject.registerClass({
439 | Properties: {
440 | 'enabled': GObject.ParamSpec.boolean(
441 | 'enabled', 'enabled', 'enabled',
442 | GObject.ParamFlags.READWRITE,
443 | true),
444 | 'orientation': GObject.ParamSpec.enum(
445 | 'orientation', 'orientation', 'orientation',
446 | GObject.ParamFlags.READWRITE,
447 | Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
448 | 'distance': GObject.ParamSpec.double(
449 | 'distance', 'distance', 'distance',
450 | GObject.ParamFlags.READWRITE,
451 | 0, Infinity, 0),
452 | 'allow-long-swipes': GObject.ParamSpec.boolean(
453 | 'allow-long-swipes', 'allow-long-swipes', 'allow-long-swipes',
454 | GObject.ParamFlags.READWRITE,
455 | false),
456 | 'scroll-modifiers': GObject.ParamSpec.flags(
457 | 'scroll-modifiers', 'scroll-modifiers', 'scroll-modifiers',
458 | GObject.ParamFlags.READWRITE,
459 | Clutter.ModifierType, 0),
460 | },
461 | Signals: {
462 | 'begin': { param_types: [GObject.TYPE_UINT] },
463 | 'update': { param_types: [GObject.TYPE_DOUBLE] },
464 | 'end': { param_types: [GObject.TYPE_UINT64, GObject.TYPE_DOUBLE] },
465 | },
466 | }, class SwipeTracker extends GObject.Object {
467 | _init(actor, orientation, allowedModes, params) {
468 | super._init();
469 | params = Params.parse(params, { allowDrag: true, allowScroll: true });
470 |
471 | this.orientation = orientation;
472 | this._allowedModes = allowedModes;
473 | this._enabled = true;
474 | this._distance = global.screen_height;
475 | this._history = new EventHistory();
476 | this._reset();
477 |
478 | this._touchpadGesture = new TouchpadSwipeGesture(allowedModes);
479 | this._touchpadGesture.connect('begin', this._beginGesture.bind(this));
480 | this._touchpadGesture.connect('update', this._updateGesture.bind(this));
481 | this._touchpadGesture.connect('end', this._endTouchpadGesture.bind(this));
482 | this.bind_property('enabled', this._touchpadGesture, 'enabled', 0);
483 | this.bind_property('orientation', this._touchpadGesture, 'orientation',
484 | GObject.BindingFlags.SYNC_CREATE);
485 |
486 | this._touchGesture = new TouchSwipeGesture(allowedModes,
487 | GESTURE_FINGER_COUNT,
488 | Clutter.GestureTriggerEdge.AFTER);
489 | this._touchGesture.connect('begin', this._beginTouchSwipe.bind(this));
490 | this._touchGesture.connect('update', this._updateGesture.bind(this));
491 | this._touchGesture.connect('end', this._endTouchGesture.bind(this));
492 | this._touchGesture.connect('cancel', this._cancelTouchGesture.bind(this));
493 | this.bind_property('enabled', this._touchGesture, 'enabled', 0);
494 | this.bind_property('orientation', this._touchGesture, 'orientation',
495 | GObject.BindingFlags.SYNC_CREATE);
496 | this.bind_property('distance', this._touchGesture, 'distance', 0);
497 | global.stage.add_action(this._touchGesture);
498 |
499 | if (params.allowDrag) {
500 | this._dragGesture = new TouchSwipeGesture(allowedModes, 1,
501 | Clutter.GestureTriggerEdge.AFTER);
502 | this._dragGesture.connect('begin', this._beginGesture.bind(this));
503 | this._dragGesture.connect('update', this._updateGesture.bind(this));
504 | this._dragGesture.connect('end', this._endTouchGesture.bind(this));
505 | this._dragGesture.connect('cancel', this._cancelTouchGesture.bind(this));
506 | this.bind_property('enabled', this._dragGesture, 'enabled', 0);
507 | this.bind_property('orientation', this._dragGesture, 'orientation',
508 | GObject.BindingFlags.SYNC_CREATE);
509 | this.bind_property('distance', this._dragGesture, 'distance', 0);
510 | actor.add_action(this._dragGesture);
511 | } else {
512 | this._dragGesture = null;
513 | }
514 |
515 | if (params.allowScroll) {
516 | this._scrollGesture = new ScrollGesture(actor, allowedModes);
517 | this._scrollGesture.connect('begin', this._beginGesture.bind(this));
518 | this._scrollGesture.connect('update', this._updateGesture.bind(this));
519 | this._scrollGesture.connect('end', this._endTouchpadGesture.bind(this));
520 | this.bind_property('enabled', this._scrollGesture, 'enabled', 0);
521 | this.bind_property('orientation', this._scrollGesture, 'orientation',
522 | GObject.BindingFlags.SYNC_CREATE);
523 | this.bind_property('scroll-modifiers',
524 | this._scrollGesture, 'scroll-modifiers', 0);
525 | } else {
526 | this._scrollGesture = null;
527 | }
528 | }
529 |
530 | /**
531 | * canHandleScrollEvent:
532 | * @param {Clutter.Event} scrollEvent: an event to check
533 | * @returns {bool} whether the event can be handled by the tracker
534 | *
535 | * This function can be used to combine swipe gesture and mouse
536 | * scrolling.
537 | */
538 | canHandleScrollEvent(scrollEvent) {
539 | if (!this.enabled || this._scrollGesture === null)
540 | return false;
541 |
542 | return this._scrollGesture.canHandleEvent(scrollEvent);
543 | }
544 |
545 | get enabled() {
546 | return this._enabled;
547 | }
548 |
549 | set enabled(enabled) {
550 | if (this._enabled === enabled)
551 | return;
552 |
553 | this._enabled = enabled;
554 | if (!enabled && this._state === State.SCROLLING)
555 | this._interrupt();
556 | this.notify('enabled');
557 | }
558 |
559 | get distance() {
560 | return this._distance;
561 | }
562 |
563 | set distance(distance) {
564 | if (this._distance === distance)
565 | return;
566 |
567 | this._distance = distance;
568 | this.notify('distance');
569 | }
570 |
571 | _reset() {
572 | this._state = State.NONE;
573 |
574 | this._snapPoints = [];
575 | this._initialProgress = 0;
576 | this._cancelProgress = 0;
577 |
578 | this._prevOffset = 0;
579 | this._progress = 0;
580 |
581 | this._cancelled = false;
582 |
583 | this._history.reset();
584 | }
585 |
586 | _interrupt() {
587 | this.emit('end', 0, this._cancelProgress);
588 | this._reset();
589 | }
590 |
591 | _beginTouchSwipe(gesture, time, x, y) {
592 | if (this._dragGesture)
593 | this._dragGesture.cancel();
594 |
595 | this._beginGesture(gesture, time, x, y);
596 | }
597 |
598 | _beginGesture(gesture, time, x, y) {
599 | if (this._state === State.SCROLLING)
600 | return;
601 |
602 | this._history.append(time, 0);
603 |
604 | let rect = new Meta.Rectangle({ x, y, width: 1, height: 1 });
605 | let monitor = global.display.get_monitor_index_for_rect(rect);
606 |
607 | this.emit('begin', monitor);
608 | }
609 |
610 | _findClosestPoint(pos) {
611 | const distances = this._snapPoints.map(x => Math.abs(x - pos));
612 | const min = Math.min(...distances);
613 | return distances.indexOf(min);
614 | }
615 |
616 | _findNextPoint(pos) {
617 | return this._snapPoints.findIndex(p => p >= pos);
618 | }
619 |
620 | _findPreviousPoint(pos) {
621 | const reversedIndex = this._snapPoints.slice().reverse().findIndex(p => p <= pos);
622 | return this._snapPoints.length - 1 - reversedIndex;
623 | }
624 |
625 | _findPointForProjection(pos, velocity) {
626 | const initial = this._findClosestPoint(this._initialProgress);
627 | const prev = this._findPreviousPoint(pos);
628 | const next = this._findNextPoint(pos);
629 |
630 | if ((velocity > 0 ? prev : next) === initial)
631 | return velocity > 0 ? next : prev;
632 |
633 | return this._findClosestPoint(pos);
634 | }
635 |
636 | _getBounds(pos) {
637 | if (this.allowLongSwipes)
638 | return [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]];
639 |
640 | const closest = this._findClosestPoint(pos);
641 |
642 | let prev, next;
643 | if (Math.abs(this._snapPoints[closest] - pos) < EPSILON) {
644 | prev = next = closest;
645 | } else {
646 | prev = this._findPreviousPoint(pos);
647 | next = this._findNextPoint(pos);
648 | }
649 |
650 | const lowerIndex = Math.max(prev - 1, 0);
651 | const upperIndex = Math.min(next + 1, this._snapPoints.length - 1);
652 |
653 | return [this._snapPoints[lowerIndex], this._snapPoints[upperIndex]];
654 | }
655 |
656 | _updateGesture(gesture, time, delta, distance) {
657 | if (this._state !== State.SCROLLING)
658 | return;
659 |
660 | if ((this._allowedModes & Main.actionMode) === 0 || !this.enabled) {
661 | this._interrupt();
662 | return;
663 | }
664 |
665 | if (this.orientation === Clutter.Orientation.HORIZONTAL &&
666 | Clutter.get_default_text_direction() === Clutter.TextDirection.RTL)
667 | delta = -delta;
668 |
669 | this._progress += delta / distance;
670 | this._history.append(time, delta);
671 |
672 | this._progress = Math.clamp(this._progress, ...this._getBounds(this._initialProgress));
673 |
674 | this.emit('update', this._progress);
675 | }
676 |
677 | _getEndProgress(velocity, distance, isTouchpad) {
678 | if (this._cancelled)
679 | return this._cancelProgress;
680 |
681 | const threshold = isTouchpad ? VELOCITY_THRESHOLD_TOUCHPAD : VELOCITY_THRESHOLD_TOUCH;
682 |
683 | if (Math.abs(velocity) < threshold)
684 | return this._snapPoints[this._findClosestPoint(this._progress)];
685 |
686 | const decel = isTouchpad ? DECELERATION_TOUCHPAD : DECELERATION_TOUCH;
687 | const slope = decel / (1.0 - decel) / 1000.0;
688 |
689 | let pos;
690 | if (Math.abs(velocity) > VELOCITY_CURVE_THRESHOLD) {
691 | const c = slope / 2 / DECELERATION_PARABOLA_MULTIPLIER;
692 | const x = Math.abs(velocity) - VELOCITY_CURVE_THRESHOLD + c;
693 |
694 | pos = slope * VELOCITY_CURVE_THRESHOLD +
695 | DECELERATION_PARABOLA_MULTIPLIER * x * x -
696 | DECELERATION_PARABOLA_MULTIPLIER * c * c;
697 | } else {
698 | pos = Math.abs(velocity) * slope;
699 | }
700 |
701 | pos = pos * Math.sign(velocity) + this._progress;
702 | pos = Math.clamp(pos, ...this._getBounds(this._initialProgress));
703 |
704 | const index = this._findPointForProjection(pos, velocity);
705 |
706 | return this._snapPoints[index];
707 | }
708 |
709 | _endTouchGesture(_gesture, time, distance) {
710 | this._endGesture(time, distance, false);
711 | }
712 |
713 | _endTouchpadGesture(_gesture, time, distance) {
714 | this._endGesture(time, distance, true);
715 | }
716 |
717 | _endGesture(time, distance, isTouchpad) {
718 | if (this._state !== State.SCROLLING)
719 | return;
720 |
721 | if ((this._allowedModes & Main.actionMode) === 0 || !this.enabled) {
722 | this._interrupt();
723 | return;
724 | }
725 |
726 | this._history.trim(time);
727 |
728 | let velocity = this._history.calculateVelocity();
729 | const endProgress = this._getEndProgress(velocity, distance, isTouchpad);
730 |
731 | velocity /= distance;
732 |
733 | if ((endProgress - this._progress) * velocity <= 0)
734 | velocity = ANIMATION_BASE_VELOCITY;
735 |
736 | const nPoints = Math.max(1, Math.ceil(Math.abs(this._progress - endProgress)));
737 | const maxDuration = MAX_ANIMATION_DURATION * Math.log2(1 + nPoints);
738 |
739 | let duration = Math.abs((this._progress - endProgress) / velocity * DURATION_MULTIPLIER);
740 | if (duration > 0)
741 | duration = Math.clamp(duration, MIN_ANIMATION_DURATION, maxDuration);
742 |
743 | this._reset();
744 | this.emit('end', duration, endProgress);
745 | }
746 |
747 | _cancelTouchGesture(_gesture, time, distance) {
748 | if (this._state !== State.SCROLLING)
749 | return;
750 |
751 | this._cancelled = true;
752 | this._endGesture(time, distance, false);
753 | }
754 |
755 | /**
756 | * confirmSwipe:
757 | * @param {number} distance: swipe distance in pixels
758 | * @param {number[]} snapPoints:
759 | * An array of snap points, sorted in ascending order
760 | * @param {number} currentProgress: initial progress value
761 | * @param {number} cancelProgress: the value to be used on cancelling
762 | *
763 | * Confirms a swipe. User has to call this in 'begin' signal handler,
764 | * otherwise the swipe wouldn't start. If there's an animation running,
765 | * it should be stopped first.
766 | *
767 | * @cancel_progress must always be a snap point, or a value matching
768 | * some other non-transient state.
769 | */
770 | confirmSwipe(distance, snapPoints, currentProgress, cancelProgress) {
771 | this.distance = distance;
772 | this._snapPoints = snapPoints;
773 | this._initialProgress = currentProgress;
774 | this._progress = currentProgress;
775 | this._cancelProgress = cancelProgress;
776 |
777 | this._state = State.SCROLLING;
778 | }
779 |
780 | destroy() {
781 | if (this._touchpadGesture) {
782 | this._touchpadGesture.destroy();
783 | delete this._touchpadGesture;
784 | }
785 |
786 | if (this._touchGesture) {
787 | global.stage.remove_action(this._touchGesture);
788 | delete this._touchGesture;
789 | }
790 | }
791 | });
792 |
--------------------------------------------------------------------------------
/util.js:
--------------------------------------------------------------------------------
1 | const Main = imports.ui.main;
2 | const Gi = imports._gi;
3 | const Gio = imports.gi.Gio;
4 | const GioSSS = Gio.SettingsSchemaSource;
5 | const ExtensionUtils = imports.misc.extensionUtils;
6 |
7 | const Self = ExtensionUtils.getCurrentExtension();
8 |
9 | function hookVfunc(proto, symbol, func) {
10 | proto[Gi.hook_up_vfunc_symbol](symbol, func);
11 | }
12 |
13 | function overrideProto(proto, overrides) {
14 | const backup = {};
15 |
16 | for (var symbol in overrides) {
17 | if (symbol.startsWith('after_')) {
18 | const actualSymbol = symbol.slice('after_'.length);
19 | const fn = proto[actualSymbol];
20 | const afterFn = overrides[symbol]
21 | proto[actualSymbol] = function() {
22 | const args = Array.prototype.slice.call(arguments);
23 | const res = fn.apply(this, args);
24 | afterFn.apply(this, args);
25 | return res;
26 | };
27 | backup[actualSymbol] = fn;
28 | }
29 | else {
30 | backup[symbol] = proto[symbol];
31 | if (symbol.startsWith('vfunc')) {
32 | hookVfunc(proto[Gi.gobject_prototype_symbol], symbol.slice(6), overrides[symbol]);
33 | }
34 | else {
35 | proto[symbol] = overrides[symbol];
36 | }
37 | }
38 | }
39 | return backup;
40 | }
41 |
42 | function bindSetting(label, callback, executeOnBind = true) {
43 | let settings = global.vertical_overview.settings;
44 | if (!settings) {
45 | settings = global.vertical_overview.settings = {
46 | object: ExtensionUtils.getSettings('org.gnome.shell.extensions.cosmic-workspaces'),
47 | signals: {},
48 | callbacks: {}
49 | };
50 | }
51 |
52 |
53 | if (settings.signals[label])
54 | settings.object.disconnect(settings.signals[label]);
55 |
56 | const signal = global.vertical_overview.settings.object.connect('changed::' + label, callback);
57 | global.vertical_overview.settings.signals[label] = signal;
58 | settings.callbacks[label] = callback;
59 |
60 | if (executeOnBind) callback(settings.object, label);
61 | return signal;
62 | }
63 |
64 | // returns a cosmic dock object if safe to use else undefined
65 | function getDock() {
66 | const cosmicDock = Main.extensionManager.lookup("cosmic-dock@system76.com");
67 | if (cosmicDock?.stateObj?.dockManager?.mainDock
68 | && cosmicDock.state === ExtensionUtils.ExtensionState.ENABLED)
69 | return cosmicDock;
70 | }
71 |
72 | function unbindSetting(label, callback) {
73 | let settings = global.vertical_overview.settings;
74 | if (!settings || !settings.signals[label])
75 | return;
76 |
77 | if (callback)
78 | callback(settings.object, label);
79 |
80 | settings.object.disconnect(settings.signals[label]);
81 | delete settings.signals[label];
82 |
83 | if (settings.callbacks[label]) {
84 | delete settings.callbacks[label];
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/workspace.js:
--------------------------------------------------------------------------------
1 | const { Clutter, GLib, GObject, Graphene, Meta, St } = imports.gi;
2 |
3 | const Background = imports.ui.background;
4 | const DND = imports.ui.dnd;
5 | const Main = imports.ui.main;
6 | const OverviewControls = imports.ui.overviewControls;
7 | const Params = imports.misc.params;
8 | const Util = imports.misc.util;
9 | const { WindowPreview } = imports.ui.windowPreview;
10 | var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95;
11 | var WINDOW_REPOSITIONING_DELAY = 750;
12 | var LAYOUT_SCALE_WEIGHT = 1;
13 | var LAYOUT_SPACE_WEIGHT = 0.1;
14 | const BACKGROUND_CORNER_RADIUS_PIXELS = 30;
15 | const BACKGROUND_MARGIN = 12;
16 | const { ExtensionState } = imports.misc.extensionUtils;
17 |
18 | const Workspace = imports.ui.workspace;
19 | const Self = imports.misc.extensionUtils.getCurrentExtension();
20 | const _Util = Self.imports.util;
21 | const animateAllocation = imports.ui.workspace.animateAllocation;
22 |
23 | function updateStaticBackgrounds() {
24 | for (var bg of global.vertical_overview.bgManagers) {
25 | bg.destroy();
26 | }
27 |
28 | global.vertical_overview.bgManagers = [];
29 |
30 | for (var monitor of Main.layoutManager.monitors) {
31 | let bgManager = new Background.BackgroundManager({
32 | monitorIndex: monitor.index,
33 | container: Main.layoutManager.overviewGroup,
34 | });
35 |
36 | global.vertical_overview.bgManagers.push(bgManager);
37 | }
38 |
39 | staticBackgroundEnabled = true;
40 | scalingWorkspaceBackgroundEnabled = true;
41 | }
42 |
43 | var staticBackgroundEnabled = false;
44 | var monitorsChangedId = null;
45 | function staticBackgroundOverride() {
46 | if (!staticBackgroundEnabled) {
47 | global.vertical_overview.bgManagers = [];
48 | monitorsChangedId = Main.layoutManager.connect('monitors-changed', () => {
49 | updateStaticBackgrounds();
50 | });
51 | updateStaticBackgrounds();
52 |
53 | staticBackgroundEnabled = true;
54 | }
55 | }
56 |
57 | function staticBackgroundReset() {
58 | if (staticBackgroundEnabled) {
59 | Main.layoutManager.disconnect(monitorsChangedId);
60 | monitorsChangedId = null;
61 |
62 | for (var bg of global.vertical_overview.bgManagers) {
63 | bg.destroy();
64 | }
65 | delete global.vertical_overview.bgManagers;
66 | staticBackgroundEnabled = false;
67 | }
68 | }
69 |
70 | var scalingWorkspaceBackgroundEnabled = false;
71 | function scalingWorkspaceBackgroundOverride() {
72 | if (!scalingWorkspaceBackgroundEnabled) {
73 | global.vertical_overview.GSFunctions['Workspace'] = _Util.overrideProto(Workspace.Workspace.prototype, WorkspaceOverride);
74 | scalingWorkspaceBackgroundEnabled = true;
75 | }
76 | }
77 |
78 | function scalingWorkspaceBackgroundReset() {
79 | if (scalingWorkspaceBackgroundEnabled) {
80 | _Util.overrideProto(Workspace.Workspace.prototype, global.vertical_overview.GSFunctions['Workspace']);
81 | scalingWorkspaceBackgroundEnabled = false;
82 | }
83 | }
84 |
85 | function override() {
86 | global.vertical_overview.GSFunctions["WorkspaceLayout"] = _Util.overrideProto(Workspace.WorkspaceLayout.prototype, WorkspaceLayoutOverride);
87 | }
88 |
89 | function reset() {
90 | staticBackgroundReset();
91 | scalingWorkspaceBackgroundReset();
92 | _Util.overrideProto(Workspace.WorkspaceLayout.prototype, global.vertical_overview.GSFunctions["WorkspaceLayout"]);
93 | }
94 |
95 | WorkspaceOverride = {
96 | _init: function (metaWorkspace, monitorIndex, overviewAdjustment) {
97 | St.Widget.prototype._init.call(this, {
98 | style_class: 'window-picker',
99 | pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }),
100 | layout_manager: new Clutter.BinLayout(),
101 | });
102 |
103 | const layoutManager = new Workspace.WorkspaceLayout(metaWorkspace, monitorIndex,
104 | overviewAdjustment);
105 |
106 | // Window previews
107 | this._container = new Clutter.Actor({
108 | reactive: true,
109 | x_expand: true,
110 | y_expand: true,
111 | });
112 |
113 | this._container.layout_manager = layoutManager;
114 | this.add_child(this._container);
115 |
116 | this.metaWorkspace = metaWorkspace;
117 | this._activeWorkspaceChangedId =
118 | this.metaWorkspace?.connect('notify::active', () => {
119 | layoutManager.syncOverlays();
120 | });
121 |
122 | this._overviewAdjustment = overviewAdjustment;
123 |
124 | this.monitorIndex = monitorIndex;
125 | this._monitor = Main.layoutManager.monitors[this.monitorIndex];
126 |
127 | if (monitorIndex != Main.layoutManager.primaryIndex)
128 | this.add_style_class_name('external-monitor');
129 |
130 | const clickAction = new Clutter.ClickAction();
131 | clickAction.connect('clicked', action => {
132 | // Switch to the workspace when not the active one, leave the
133 | // overview otherwise.
134 | if (action.get_button() === 1 || action.get_button() === 0) {
135 | const leaveOverview = this._shouldLeaveOverview();
136 |
137 | this.metaWorkspace?.activate(global.get_current_time());
138 | if (leaveOverview)
139 | Main.overview.hide();
140 | }
141 | });
142 | this.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
143 | this._container.add_action(clickAction);
144 |
145 | this.connect('style-changed', this._onStyleChanged.bind(this));
146 | this.connect('destroy', this._onDestroy.bind(this));
147 |
148 | this._skipTaskbarSignals = new Map();
149 |
150 | const windows = global.get_window_actors().map(a => a.meta_window)
151 | .filter(this._isMyWindow, this);
152 |
153 | // Create clones for windows that should be
154 | // visible in the Overview
155 | this._windows = [];
156 | for (let i = 0; i < windows.length; i++) {
157 | if (this._isOverviewWindow(windows[i]))
158 | this._addWindowClone(windows[i]);
159 | }
160 |
161 | // Track window changes, but let the window tracker process them first
162 | this.metaWorkspace?.connectObject(
163 | 'window-added', this._windowAdded.bind(this), GObject.ConnectFlags.AFTER,
164 | 'window-removed', this._windowRemoved.bind(this), GObject.ConnectFlags.AFTER,
165 | 'notify::active', () => layoutManager.syncOverlays(), this);
166 | global.display.connectObject(
167 | 'window-entered-monitor', this._windowEnteredMonitor.bind(this), GObject.ConnectFlags.AFTER,
168 | 'window-left-monitor', this._windowLeftMonitor.bind(this), GObject.ConnectFlags.AFTER,
169 | this);
170 | this._layoutFrozenId = 0;
171 |
172 | // DND requires this to be set
173 | this._delegate = this;
174 | },
175 |
176 | }
177 |
178 | let WorkspaceLayoutOverride = {
179 | _adjustSpacingAndPadding(rowSpacing, colSpacing, containerBox) {
180 | if (this._sortedWindows.length === 0)
181 | return [rowSpacing, colSpacing, containerBox];
182 |
183 | // All of the overlays have the same chrome sizes,
184 | // so just pick the first one.
185 | const window = this._sortedWindows[0];
186 |
187 | const [topOversize, bottomOversize] = window.chromeHeights();
188 | const [leftOversize, rightOversize] = window.chromeWidths();
189 |
190 | const oversize =
191 | Math.max(topOversize, bottomOversize, leftOversize, rightOversize);
192 |
193 | if (rowSpacing !== null)
194 | rowSpacing += oversize;
195 | if (colSpacing !== null)
196 | colSpacing += oversize;
197 |
198 | return [rowSpacing, colSpacing, containerBox];
199 | },
200 | }
201 |
--------------------------------------------------------------------------------
/workspaceSwitcherPopup.js:
--------------------------------------------------------------------------------
1 | const { Clutter, St } = imports.gi;
2 |
3 | const { ExtensionState } = imports.misc.extensionUtils;
4 | const OverviewControls = imports.ui.overviewControls;
5 | const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
6 | const Main = imports.ui.main;
7 |
8 | const Self = imports.misc.extensionUtils.getCurrentExtension();
9 | const Util = Self.imports.util;
10 |
11 | function override() {
12 | global.vertical_overview.GSFunctions['WorkspaceSwitcherPopup'] = Util.overrideProto(WorkspaceSwitcherPopup.WorkspaceSwitcherPopup.prototype, WorkspaceSwitcherPopupOverride);
13 | }
14 |
15 | function reset() {
16 | Util.overrideProto(WorkspaceSwitcherPopup.WorkspaceSwitcherPopup.prototype, WorkspaceSwitcherPopupOverride);
17 | }
18 |
19 | var WorkspaceSwitcherPopupOverride = {
20 | _redisplay: function() {
21 | // Move OSD to the side of the screen coresponding to the workspace picker location
22 | this._list.set_vertical(true);
23 | if (global.vertical_overview.workspace_picker_left) {
24 | this.set_x_align(Clutter.ActorAlign.START);
25 | } else {
26 | this.set_x_align(Clutter.ActorAlign.END);
27 | }
28 | this.set_y_align(Clutter.ActorAlign.CENTER);
29 |
30 | // translate x by dock width if picker and dock are on the same side
31 | const cosmicDock = Util.getDock();
32 | if (cosmicDock) {
33 | const mainDock = cosmicDock.stateObj.dockManager.mainDock
34 | const picker_left = global.vertical_overview.workspace_picker_left;
35 | const dashWidth = mainDock._slider.get_child().get_width();
36 |
37 | if (mainDock.get_height() > mainDock.get_y()) {
38 | const dock_left = mainDock.get_x() <= 0
39 | if (dock_left && picker_left) {
40 | this.set_translation(dashWidth,0,0);
41 | } else if (!dock_left && !picker_left) {
42 | this.set_translation(-dashWidth,0,0);
43 | }
44 | }
45 | }
46 |
47 | let workspaceManager = global.workspace_manager;
48 | this._list.destroy_all_children();
49 |
50 | for (let i = 0; i < workspaceManager.n_workspaces; i++) {
51 | const indicator = new St.Bin({
52 | style_class: 'ws-switcher-indicator',
53 | });
54 |
55 | if (i === this._activeWorkspaceIndex)
56 | indicator.add_style_pseudo_class('active');
57 |
58 | this._list.add_actor(indicator);
59 | }
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/workspaceThumbnail.js:
--------------------------------------------------------------------------------
1 | const { Clutter, Gio, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
2 |
3 | const DND = imports.ui.dnd;
4 | const Main = imports.ui.main;
5 | const Background = imports.ui.background;
6 | const Workspace = imports.ui.workspace;
7 | const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
8 |
9 | const Self = imports.misc.extensionUtils.getCurrentExtension();
10 | const Util = Self.imports.util;
11 |
12 | const NUM_WORKSPACES_THRESHOLD = 2;
13 |
14 | // The maximum size of a thumbnail is 5% the width and height of the screen
15 | var MAX_THUMBNAIL_SCALE = 0.05;
16 |
17 | var RESCALE_ANIMATION_TIME = 200;
18 | var SLIDE_ANIMATION_TIME = 200;
19 |
20 | // When we create workspaces by dragging, we add a "cut" into the top and
21 | // bottom of each workspace so that the user doesn't have to hit the
22 | // placeholder exactly.
23 | var WORKSPACE_CUT_SIZE = 10;
24 |
25 | var WORKSPACE_KEEP_ALIVE_TIME = 100;
26 |
27 | var MUTTER_SCHEMA = 'org.gnome.mutter';
28 |
29 | function override() {
30 | global.vertical_overview.GSFunctions['ThumbnailsBox'] = Util.overrideProto(WorkspaceThumbnail.ThumbnailsBox.prototype, ThumbnailsBoxOverride);
31 | global.vertical_overview.GSFunctions['WorkspaceThumbnail'] = Util.overrideProto(WorkspaceThumbnail.WorkspaceThumbnail.prototype, WorkspaceThumbnailOverride);
32 | Main.overview._overview._controls._thumbnailsBox.x_align = Clutter.ActorAlign.FILL;
33 | }
34 |
35 | function reset() {
36 | Util.overrideProto(WorkspaceThumbnail.ThumbnailsBox.prototype, global.vertical_overview.GSFunctions['ThumbnailsBox']);
37 | Util.overrideProto(WorkspaceThumbnail.WorkspaceThumbnail.prototype, global.vertical_overview.GSFunctions['WorkspaceThumbnail']);
38 | Main.overview._overview._controls._thumbnailsBox.x_align = Clutter.ActorAlign.CENTER;
39 | }
40 |
41 | function thumbnails_old_style() {
42 | let thumbnailsBox = Main.overview._overview._controls._thumbnailsBox;
43 | if (global.vertical_overview.old_style_enabled && global.vertical_overview.default_old_style_enabled) {
44 | thumbnailsBox.add_style_class_name("vertical-overview");
45 | } else {
46 | thumbnailsBox.remove_style_class_name("vertical-overview");
47 | }
48 | }
49 |
50 | var ThumbnailsBoxOverride = {
51 | _updateShouldShow: function() {
52 | const shouldShow = true;
53 |
54 | if (this._shouldShow === shouldShow)
55 | return;
56 |
57 | this._shouldShow = shouldShow;
58 | this.notify('should-show');
59 | },
60 |
61 | _activateThumbnailAtPoint: function (stageX, stageY, time) {
62 | const [_r, _x, y] = this.transform_stage_point(stageX, stageY);
63 |
64 | const thumbnail = this._thumbnails.find(t => y >= t.y && y <= t.y + t.height);
65 | if (thumbnail)
66 | thumbnail.activate(time);
67 | },
68 |
69 | _getPlaceholderTarget: function (index, spacing, rtl) {
70 | const workspace = this._thumbnails[index];
71 |
72 | let targetY1 = workspace.y - spacing - WORKSPACE_CUT_SIZE;
73 | let targetY2 = workspace.y + WORKSPACE_CUT_SIZE;
74 |
75 | if (index === 0) {
76 | targetY1 += spacing + WORKSPACE_CUT_SIZE;
77 | }
78 |
79 | if (index === this._dropPlaceholderPos) {
80 | const placeholderHeight = this._dropPlaceholder.get_height() + spacing;
81 | targetY1 -= placeholderHeight;
82 | }
83 |
84 | return [targetY1, targetY2];
85 | },
86 |
87 | _withinWorkspace: function (y, index, rtl) {
88 | const length = this._thumbnails.length;
89 | const workspace = this._thumbnails[index];
90 |
91 | let workspaceY1 = workspace.y + WORKSPACE_CUT_SIZE;
92 | let workspaceY2 = workspace.y + workspace.height - WORKSPACE_CUT_SIZE;
93 |
94 | if (index === length - 1) {
95 | workspaceY2 += WORKSPACE_CUT_SIZE;
96 | }
97 |
98 | return y > workspaceY1 && y <= workspaceY2;
99 | },
100 |
101 | // Draggable target interface
102 | handleDragOver: function(source, actor, x, y, time) {
103 | if (!source.metaWindow &&
104 | (!source.app || !source.app.can_open_new_window()) &&
105 | (source.app || !source.shellWorkspaceLaunch) &&
106 | source != Main.xdndHandler)
107 | return DND.DragMotionResult.CONTINUE;
108 |
109 | const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
110 | let canCreateWorkspaces = Meta.prefs_get_dynamic_workspaces();
111 | let spacing = this.get_theme_node().get_length('spacing');
112 |
113 | this._dropWorkspace = -1;
114 | let placeholderPos = -1;
115 | let length = this._thumbnails.length;
116 | for (let i = 0; i < length; i++) {
117 | const index = rtl ? length - i - 1 : i;
118 |
119 | if (canCreateWorkspaces && source !== Main.xdndHandler) {
120 | const [targetStart, targetEnd] =
121 | this._getPlaceholderTarget(index, spacing, rtl);
122 |
123 | if (y > targetStart && y <= targetEnd) {
124 | placeholderPos = index;
125 | break;
126 | }
127 | }
128 |
129 | if (this._withinWorkspace(y, index, rtl)) {
130 | this._dropWorkspace = index;
131 | break;
132 | }
133 | }
134 |
135 | if (this._dropPlaceholderPos != placeholderPos) {
136 | this._dropPlaceholderPos = placeholderPos;
137 | this.queue_relayout();
138 | }
139 |
140 | if (this._dropWorkspace != -1)
141 | return this._thumbnails[this._dropWorkspace].handleDragOverInternal(source, actor, time);
142 | else if (this._dropPlaceholderPos != -1)
143 | return source.metaWindow ? DND.DragMotionResult.MOVE_DROP : DND.DragMotionResult.COPY_DROP;
144 | else
145 | return DND.DragMotionResult.CONTINUE;
146 | },
147 |
148 | vfunc_allocate: function(box) {
149 |
150 | if (this._thumbnails.length == 0) // not visible
151 | return;
152 |
153 | //set top and bottom margin
154 | box.y1 += 16;
155 | box.y2 -= 32;
156 |
157 | var width;
158 | const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
159 | const scale = Math.max(1, Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex).width / Main.layoutManager.primaryMonitor.width);
160 |
161 | var mainDockHides;
162 | var mainDockWidth;
163 | var mainDockHeight;
164 | var mainDockPosition;
165 | const cosmicDock = Util.getDock();
166 | if (cosmicDock) {
167 | const mainDock = cosmicDock.stateObj.dockManager.mainDock;
168 | const dockSettings = cosmicDock.stateObj.dockManager.settings;
169 | mainDockHides = dockSettings.intellihideMode || dockSettings.dockFixed || !dockSettings.multiMonitor;
170 | mainDockPosition = mainDock.position;
171 | [, mainDockWidth] = mainDock.get_preferred_width(height);
172 | [, mainDockHeight] = mainDock.get_preferred_height(width);
173 | }
174 |
175 | if (this._monitorIndex == Main.layoutManager.primaryIndex) {
176 | global.vertical_overview.workspacePickerX1 = box.x1;
177 | global.vertical_overview.workspacePickerWidth = box.get_width() / scaleFactor;
178 | width = box.get_width();
179 | } else {
180 | box.x1 = global.vertical_overview.workspacePickerX1;
181 | width = global.vertical_overview.workspacePickerWidth * scale * scaleFactor;
182 |
183 | if (mainDockPosition == St.Side.LEFT && mainDockHides) {
184 | box.x1 -= mainDockWidth;
185 | } else if (mainDockPosition == St.Side.BOTTOM && !mainDockHides) {
186 | box.set_size(box.get_width(), box.get_height() - mainDockHeight);
187 | }
188 | }
189 |
190 | let parentBox = box;
191 | const themeNode = this.get_theme_node();
192 | box = themeNode.get_content_box(parentBox);
193 |
194 | const portholeWidth = this._porthole.width;
195 | const portholeHeight = this._porthole.height;
196 | const ratio = portholeHeight / portholeWidth;
197 |
198 | var height = Math.round(width * ratio);
199 |
200 | let vScale = width / portholeWidth;
201 | let hScale = height / portholeHeight;
202 |
203 | var spacing = themeNode.get_length('spacing');
204 |
205 | let indicatorValue = this._scrollAdjustment.value;
206 | let indicatorUpperWs = Math.ceil(indicatorValue);
207 | let indicatorLowerWs = Math.floor(indicatorValue);
208 |
209 | let indicatorLowerY1 = 0;
210 | let indicatorLowerY2 = 0;
211 | let indicatorUpperY1 = 0;
212 | let indicatorUpperY2 = 0;
213 |
214 | if (this._dropPlaceholderPos == -1) {
215 | this._dropPlaceholder.allocate_preferred_size(
216 | ...this._dropPlaceholder.get_position());
217 |
218 | Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
219 | this._dropPlaceholder.hide();
220 | });
221 | }
222 |
223 | let totalHeight = (height + spacing) * this._thumbnails.length;
224 | box.y1 = themeNode.get_padding(St.Side.TOP);
225 |
226 | let additionalScale = (box.get_height() < totalHeight) ? box.get_height() / totalHeight : 1;
227 | height *= additionalScale;
228 | width *= additionalScale;
229 | spacing *= additionalScale;
230 | vScale *= additionalScale;
231 | hScale *= additionalScale;
232 |
233 | if (!global.vertical_overview.workspace_picker_left) {
234 | const total_spacing = spacing * 2;
235 | const gap = 16 * scaleFactor;
236 | parentBox.x1 = portholeWidth - width - gap - total_spacing;
237 | if (mainDockPosition == St.Side.RIGHT && !mainDockHides) {
238 | parentBox.x1 -= mainDockWidth;
239 | } else if (this._monitorIndex == Main.layoutManager.primaryIndex
240 | && mainDockPosition == St.Side.LEFT
241 | && mainDockHides) {
242 | parentBox.x1 += mainDockWidth;
243 | }
244 | }
245 |
246 | parentBox.set_size(width + spacing*2, parentBox.get_height())
247 | this.set_allocation(parentBox);
248 |
249 | box.x2 = box.x1 + width;
250 |
251 | let childBox = new Clutter.ActorBox();
252 | for (let i = 0; i < this._thumbnails.length; i++) {
253 | let thumbnail = this._thumbnails[i];
254 |
255 | let y1 = box.y1 + (height + spacing) * i;
256 |
257 | const [placeholderWidth, placeholderHeight] = this._dropPlaceholder.get_preferred_height(-1);
258 | if (i === this._dropPlaceholderPos) {
259 | childBox.set_origin(box.x1, y1)
260 | childBox.set_size(placeholderWidth, placeholderHeight);
261 | this._dropPlaceholder.allocate(childBox);
262 |
263 | Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
264 | this._dropPlaceholder.show();
265 | });
266 | }
267 |
268 | if (this._dropPlaceholderPos !== -1 && this._dropPlaceholderPos <= i) {
269 | y1 += placeholderHeight + spacing;
270 | }
271 |
272 | childBox.set_origin(spacing, y1);
273 | childBox.set_size(width, height);
274 | thumbnail.setScale(vScale, hScale);
275 | thumbnail.allocate(childBox);
276 |
277 | if (i === indicatorUpperWs) {
278 | indicatorUpperY1 = childBox.y1;
279 | indicatorUpperY2 = childBox.y2;
280 | }
281 | if (i === indicatorLowerWs) {
282 | indicatorLowerY1 = childBox.y1;
283 | indicatorLowerY2 = childBox.y2;
284 | }
285 | }
286 |
287 | let indicatorThemeNode = this._indicator.get_theme_node();
288 | let indicatorTopFullBorder = indicatorThemeNode.get_padding(St.Side.TOP) + indicatorThemeNode.get_border_width(St.Side.TOP);
289 | let indicatorBottomFullBorder = indicatorThemeNode.get_padding(St.Side.BOTTOM) + indicatorThemeNode.get_border_width(St.Side.BOTTOM);
290 | let indicatorLeftFullBorder = indicatorThemeNode.get_padding(St.Side.LEFT) + indicatorThemeNode.get_border_width(St.Side.LEFT);
291 | let indicatorRightFullBorder = indicatorThemeNode.get_padding(St.Side.RIGHT) + indicatorThemeNode.get_border_width(St.Side.RIGHT);
292 |
293 | childBox.x1 = spacing;
294 | childBox.x2 = spacing + (box.get_width() + width)/2;
295 |
296 | const indicatorY1 = indicatorLowerY1 +
297 | (indicatorUpperY1 - indicatorLowerY1) * (indicatorValue % 1);
298 | const indicatorY2 = indicatorLowerY2 +
299 | (indicatorUpperY2 - indicatorLowerY2) * (indicatorValue % 1);
300 |
301 | childBox.y1 = indicatorY1 - indicatorTopFullBorder;
302 | childBox.y2 = indicatorY2 + indicatorBottomFullBorder;
303 | childBox.x1 -= indicatorLeftFullBorder;
304 | childBox.x2 += indicatorRightFullBorder;
305 | this._indicator.allocate(childBox);
306 | }
307 | }
308 |
309 | var WorkspaceThumbnailOverride = {
310 | after__init: function () {
311 | this._bgManager = new Background.BackgroundManager({
312 | monitorIndex: this.monitorIndex,
313 | container: this._viewport,
314 | vignette: false,
315 | controlPosition: false,
316 | });
317 | this._viewport.set_child_below_sibling(this._bgManager.backgroundActor, null);
318 |
319 | this.connect('destroy', (function () {
320 | this._bgManager.destroy();
321 | this._bgManager = null;
322 | }).bind(this));
323 | }
324 | }
325 |
--------------------------------------------------------------------------------
/workspacesView.js:
--------------------------------------------------------------------------------
1 |
2 | const { Clutter, St } = imports.gi;
3 | const WORKSPACE_MIN_SPACING = 24;
4 | const WORKSPACE_MAX_SPACING = 1000;
5 | const WORKSPACE_INACTIVE_SCALE = 0.94;
6 | const SECONDARY_WORKSPACE_SCALE = 0.70;
7 |
8 |
9 | const { ExtensionState } = imports.misc.extensionUtils;
10 | const OverviewControls = imports.ui.overviewControls;
11 | const WorkspacesView = imports.ui.workspacesView;
12 | const Main = imports.ui.main;
13 |
14 | const Self = imports.misc.extensionUtils.getCurrentExtension();
15 | const Util = Self.imports.util;
16 |
17 | function override() {
18 | global.vertical_overview.GSFunctions['WorkspacesView'] = Util.overrideProto(WorkspacesView.WorkspacesView.prototype, WorkspacesViewOverride);
19 | log('You may see an error below,\nSecondaryMonitorDisplay is defined as const for some reason\nSince I\'m overriding values in that const, thus an error might show up.\n Feel free to ignore it');
20 | SecondaryMonitorDisplay = WorkspacesView.SecondaryMonitorDisplay;
21 |
22 | global.vertical_overview.GSFunctions['SecondaryMonitorDisplay'] = Util.overrideProto(WorkspacesView.SecondaryMonitorDisplay.prototype, SecondaryMonitorDisplayOverride);
23 | log('Thank you, please carry on');
24 |
25 | if (global.vertical_overview.default_old_style_enabled) {
26 | Main.overview._overview._controls._workspacesDisplay.add_style_class_name("vertical-overview");
27 | }
28 | }
29 |
30 | function reset() {
31 | Util.overrideProto(WorkspacesView.WorkspacesView.prototype, global.vertical_overview.GSFunctions['WorkspacesView']);
32 | Util.overrideProto(WorkspacesView.SecondaryMonitorDisplay.prototype, global.vertical_overview.GSFunctions['SecondaryMonitorDisplay']);
33 | if (global.vertical_overview.default_old_style_enabled) {
34 | Main.overview._overview._controls._workspacesDisplay.remove_style_class_name("vertical-overview");
35 | }
36 | }
37 |
38 | var WorkspacesViewOverride = {
39 | _getWorkspaceModeForOverviewState: function(state) {
40 | const { ControlsState } = OverviewControls;
41 |
42 | switch (state) {
43 | case ControlsState.HIDDEN:
44 | return 0;
45 | case ControlsState.WINDOW_PICKER:
46 | return 1;
47 | case ControlsState.APP_GRID:
48 | return 1;
49 | }
50 |
51 | return 0;
52 | },
53 |
54 | _getSpacing(box, fitMode, vertical) {
55 | const [width, height] = box.get_size();
56 | const [workspace] = this._workspaces;
57 | var [, workspaceHeight] = workspace.get_preferred_height(width);
58 | if (workspaceHeight > height) {
59 | workspaceHeight = height;
60 | }
61 | let total_height = global.screen_height;
62 | let availableSpace = ((total_height - workspaceHeight) / 2) - (global.vertical_overview.workspacePeek || 0);
63 | const spacing = (availableSpace) * (1 - fitMode);
64 | const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
65 |
66 | return Math.max(spacing * scaleFactor, 0);
67 | },
68 |
69 | _getFirstFitSingleWorkspaceBox(box, spacing, vertical) {
70 | const [width, height] = box.get_size();
71 | const [workspace] = this._workspaces;
72 |
73 | const rtl = this.text_direction === Clutter.TextDirection.RTL;
74 | const adj = this._scrollAdjustment;
75 | const currentWorkspace = vertical || !rtl
76 | ? adj.value : adj.upper - adj.value - 1;
77 |
78 | // Single fit mode implies centered too
79 | let [x1, y1] = box.get_origin();
80 | var [, workspaceHeight] = workspace.get_preferred_height(width);
81 | if (workspaceHeight > height) {
82 | workspaceHeight = height;
83 | }
84 |
85 | y1 += (height - workspaceHeight) / 2;
86 | y1 -= currentWorkspace * (workspaceHeight + spacing);
87 |
88 | const fitSingleBox = new Clutter.ActorBox({ x1, y1 });
89 |
90 | fitSingleBox.set_size(width, workspaceHeight);
91 |
92 | return fitSingleBox;
93 | }
94 | }
95 |
96 | var SecondaryMonitorDisplayOverride = {
97 | _getWorkspacesBoxForState(state, box, padding, leftOffset, rightOffset, spacing) {
98 | const { ControlsState } = OverviewControls;
99 | const workspaceBox = box.copy();
100 | const [width, height] = workspaceBox.get_size();
101 | const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
102 |
103 | const newWidth = width - this._thumbnails.width * ( scaleFactor > 1 ? scaleFactor : 2);
104 | const newXOrigin = this._thumbnails.x + this._thumbnails.width + spacing * 2;
105 |
106 | switch (state) {
107 | case ControlsState.HIDDEN:
108 | break;
109 | case ControlsState.WINDOW_PICKER:
110 | case ControlsState.APP_GRID:
111 | workspaceBox.set_origin(newXOrigin, padding + spacing);
112 | workspaceBox.set_size(
113 | newWidth,
114 | height - 2 * padding - spacing);
115 | break;
116 | }
117 |
118 | return workspaceBox;
119 | },
120 |
121 | vfunc_allocate(box) {
122 | this.set_allocation(box);
123 |
124 | const themeNode = this.get_theme_node();
125 | const contentBox = themeNode.get_content_box(box);
126 | const [width, height] = contentBox.get_size();
127 | const { expandFraction } = this._thumbnails;
128 | const spacing = themeNode.get_length('spacing') * expandFraction;
129 | const padding =
130 | Math.round((1 - SECONDARY_WORKSPACE_SCALE) * height / 2);
131 |
132 | const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
133 | const scale = Math.max(1, Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex).width / Main.layoutManager.primaryMonitor.width);
134 | const layoutManager = Main.overview._overview._controls.layoutManager;
135 |
136 | const leftOffset = layoutManager.leftOffset * scale * scaleFactor;
137 | const rightOffset = layoutManager.rightOffset * scale * scaleFactor;
138 |
139 | // Workspace Thumbnails
140 | if (this._thumbnails.visible) {
141 | const childBox = new Clutter.ActorBox();
142 | let origin, size;
143 | if (global.vertical_overview.workspace_picker_left) {
144 | origin = [0, 0];
145 | size = [leftOffset, height];
146 | } else {
147 | origin = [width - rightOffset, 0];
148 | size = [rightOffset, height];
149 | }
150 |
151 | childBox.set_origin(...origin);
152 | childBox.set_size(...size);
153 |
154 | this._thumbnails.allocate(childBox);
155 | }
156 |
157 | const {
158 | currentState, initialState, finalState, transitioning, progress,
159 | } = this._overviewAdjustment.getStateTransitionParams();
160 |
161 | let workspacesBox;
162 | const workspaceParams = [contentBox, padding, leftOffset, rightOffset, spacing];
163 | if (!transitioning) {
164 | workspacesBox =
165 | this._getWorkspacesBoxForState(currentState, ...workspaceParams);
166 | } else {
167 | const initialBox =
168 | this._getWorkspacesBoxForState(initialState, ...workspaceParams);
169 | const finalBox =
170 | this._getWorkspacesBoxForState(finalState, ...workspaceParams);
171 | workspacesBox = initialBox.interpolate(finalBox, progress);
172 | }
173 | this._workspacesView.allocate(workspacesBox);
174 | }
175 | }
176 |
--------------------------------------------------------------------------------