-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFINAL_FOR_1-24_mate-panel_Center_stick_applets_r1.patch
1541 lines (1399 loc) · 60.1 KB
/
FINAL_FOR_1-24_mate-panel_Center_stick_applets_r1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# MATE Panel: Center-stick support for applets (and better right-stick
# support, too)
#
# Conventionally, the applets on a MATE Panel are positioned relative to the
# left edge of the panel (if the panel is horizontal) or the top edge (if the
# panel is vertical). There has also been some (buggy) support for positioning
# of applets relative to the right (or bottom) edge of the panel, so that
# applets on the right side of the panel will stay on the right side even if
# the user changes screen resolutions or if the panel changes size for some
# other reason.
#
# However, many users want to also place applets at or near the center of their
# panel(s). There is no such conventional support for positioning applets
# relative to the center of the panel, so users have positioned applets near
# the center of the panel -- but the position recorded is relative to the left
# side of the panel. As such, the applets will almost certainly shift over
# to the left or right slightly if the panel is ever resized, and the user will
# have to reposition all those centered applets yet again. This is especially
# frustrating if the user switches differently-sized monitors on a regular
# basis!
#
# This patch radically revamps the MATE Panel's positioning framework, and
# deprecates the original "right-stick" feature. To replace the right-stick
# feature, this patch instead associates an "edge relativity" setting with
# each and every panel applet: An applet can be relative to the start (left/
# top), end (right/bottom), or center of the panel. This setting can be
# changed using DConf/GSettings, using a custom panel layout file, or even
# by simply dragging the applet to the appropriate place on the panel.
# (Conventionally, applets are not even right-stuck automatically even when the
# user drags the applet over to the far right of the panel!) As a bonus, when
# the user drags an applet across the center of the panel, the applet will
# temporarily "stick" to the very center of the panel, to allow the user to
# very precisely align any applet they wish.
#
# Since I created the first patch, several bugs have been fixed and some more
# backward compatibility was added; the code that is now part of the latest
# versions of the MATE Panel is different from the code in my original patch.
# On top of that, after my contributions were accepted into the official MATE
# Panel repository, it came to my attention that not all applets centered
# properly with the patch that I contributed -- namely, expanding applets
# (such as the Window List and the Dock Applet from the Ubuntu MATE project).
# This patch includes all the changes made to my patch in order for it to be
# accepted "upstream" -- by the MATE developers themselves -- and also fixes
# the issue with centering of expanding applets. I intend to contribute the
# expanding applet centering fix upstream as well, fairly soon. I also
# apologize for not testing this patch thoroughly enough the first time
# through.
#
# This patch has been tested and is known to work with MATE Panel versions
# 1.24.0, 1.24.1, and 1.24.2. This patch has been verified NOT to work on
# versions 1.26.0, 1.26.1 and 1.26.2; there should be another patch in the
# same directory as this one that is especially for these and newer versions of
# the MATE Panel. This patch may work on other versions of the panel, though
# other versions have not been tested yet.
diff -uprN mate-panel-1.24.0-original/data/default.layout mate-panel-1.24.0-patched-r1/data/default.layout
--- mate-panel-1.24.0-original/data/default.layout 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/default.layout 2022-08-12 21:15:54.950208942 -0400
@@ -19,7 +19,7 @@ object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=top
position=10
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object clock]
@@ -27,7 +27,7 @@ object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=top
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object show-desktop]
@@ -49,5 +49,5 @@ object-type=applet
applet-iid=WnckletFactory::WorkspaceSwitcherApplet
toplevel-id=bottom
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
diff -uprN mate-panel-1.24.0-original/data/fedora.layout mate-panel-1.24.0-patched-r1/data/fedora.layout
--- mate-panel-1.24.0-original/data/fedora.layout 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/fedora.layout 2022-08-12 21:15:54.950208942 -0400
@@ -40,7 +40,7 @@ object-type=applet
applet-iid=GvcAppletFactory::GvcApplet
toplevel-id=top
position=20
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object notification-area]
@@ -48,7 +48,7 @@ object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=top
position=10
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object clock]
@@ -56,7 +56,7 @@ object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=top
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object show-desktop]
@@ -78,5 +78,5 @@ object-type=applet
applet-iid=WnckletFactory::WorkspaceSwitcherApplet
toplevel-id=bottom
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
diff -uprN mate-panel-1.24.0-original/data/linuxmint.layout mate-panel-1.24.0-patched-r1/data/linuxmint.layout
--- mate-panel-1.24.0-original/data/linuxmint.layout 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/linuxmint.layout 2022-08-12 21:15:54.950208942 -0400
@@ -29,7 +29,7 @@ object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=bottom
position=10
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object clock]
@@ -37,5 +37,5 @@ object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=bottom
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
diff -uprN mate-panel-1.24.0-original/data/mageia.layout mate-panel-1.24.0-patched-r1/data/mageia.layout
--- mate-panel-1.24.0-original/data/mageia.layout 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/mageia.layout 2022-08-12 21:15:54.950208942 -0400
@@ -40,7 +40,7 @@ object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=top
position=10
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object clock]
@@ -48,7 +48,7 @@ object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=top
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object show-desktop]
@@ -70,6 +70,6 @@ object-type=applet
applet-iid=WnckletFactory::WorkspaceSwitcherApplet
toplevel-id=bottom
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
diff -uprN mate-panel-1.24.0-original/data/opensuse.layout mate-panel-1.24.0-patched-r1/data/opensuse.layout
--- mate-panel-1.24.0-original/data/opensuse.layout 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/opensuse.layout 2022-08-12 21:15:54.950208942 -0400
@@ -29,7 +29,7 @@ object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=bottom
position=30
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object workspace-switcher]
@@ -37,7 +37,7 @@ object-type=applet
applet-iid=WnckletFactory::WorkspaceSwitcherApplet
toplevel-id=bottom
position=20
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object clock]
@@ -45,7 +45,7 @@ object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=bottom
position=10
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object show-desktop]
@@ -53,5 +53,5 @@ object-type=applet
applet-iid=WnckletFactory::ShowDesktopApplet
toplevel-id=bottom
position=0
-panel-right-stick=true
+relative-to-edge=end
locked=true
diff -uprN mate-panel-1.24.0-original/data/org.mate.panel.object.gschema.xml.in mate-panel-1.24.0-patched-r1/data/org.mate.panel.object.gschema.xml.in
--- mate-panel-1.24.0-original/data/org.mate.panel.object.gschema.xml.in 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/org.mate.panel.object.gschema.xml.in 2022-08-12 21:15:54.950208942 -0400
@@ -17,8 +17,13 @@
</key>
<key name="panel-right-stick" type="b">
<default>false</default>
- <summary>Interpret position relative to bottom/right edge</summary>
- <description>If true, the position of the object is interpreted relative to the right (or bottom if vertical) edge of the panel.</description>
+ <summary>Interpret position relative to bottom/right edge (DEPRECATED)</summary>
+ <description>If true, the position of the object is interpreted relative to the right (or bottom if vertical) edge of the panel. This key is provided only for backward compatibility with old panel layouts; please set the "relative-to-edge" property instead.</description>
+ </key>
+ <key name="relative-to-edge" enum="org.mate.panel.PanelObjectEdgeRelativity">
+ <default>'start'</default>
+ <summary>Whether to interpret the value of the "position" key relative to the start, center or end of the panel</summary>
+ <description>The position of the object is interpreted relative to one edge of the panel. The value of this key determines whether the object is positioned relative to the start (left/top edge), center, or end (right/bottom edge) of the panel. Valid values for this key are 'start', 'center', and 'end'.</description>
</key>
<key name="locked" type="b">
<default>false</default>
diff -uprN mate-panel-1.24.0-original/data/ubuntu.layout mate-panel-1.24.0-patched-r1/data/ubuntu.layout
--- mate-panel-1.24.0-original/data/ubuntu.layout 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/data/ubuntu.layout 2022-08-12 21:15:54.950208942 -0400
@@ -26,23 +26,23 @@ menu-path=applications:/
object-type=applet
applet-iid=NotificationAreaAppletFactory::NotificationArea
toplevel-id=top
-position=30
-panel-right-stick=true
+position=20
+relative-to-edge=end
locked=true
[Object clock]
object-type=applet
applet-iid=ClockAppletFactory::ClockApplet
toplevel-id=top
-position=20
-panel-right-stick=true
+position=10
+relative-to-edge=end
locked=true
[Object shutdown]
action-type=shutdown
object-type=action
-position=10
-panel-right-stick=true
+position=0
+relative-to-edge=end
toplevel-id=top
locked=true
@@ -65,7 +65,7 @@ object-type=applet
applet-iid=WnckletFactory::WorkspaceSwitcherApplet
toplevel-id=bottom
position=10
-panel-right-stick=true
+relative-to-edge=end
locked=true
[Object trashapplet]
@@ -74,4 +74,4 @@ position=0
toplevel-id=bottom
applet-iid=TrashAppletFactory::TrashApplet
object-type=applet
-panel-right-stick=true
+relative-to-edge=end
diff -uprN mate-panel-1.24.0-original/mate-panel/applet.c mate-panel-1.24.0-patched-r1/mate-panel/applet.c
--- mate-panel-1.24.0-original/mate-panel/applet.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/applet.c 2022-08-12 21:15:54.960208942 -0400
@@ -771,12 +771,12 @@ mate_panel_applet_destroy (GtkWidget *w
}
typedef struct {
- char *id;
- PanelObjectType type;
- char *toplevel_id;
- int position;
- guint right_stick : 1;
- guint locked : 1;
+ char *id;
+ PanelObjectType type;
+ char *toplevel_id;
+ int position;
+ PanelObjectEdgeRelativity edge_relativity;
+ guint locked : 1;
} MatePanelAppletToLoad;
/* Each time those lists get both empty,
@@ -903,9 +903,14 @@ mate_panel_applet_load_idle_handler (gpo
panel_widget = panel_toplevel_get_panel_widget (toplevel);
- if (applet->right_stick) {
- if (!panel_widget->packed)
- applet->position = panel_widget->size - applet->position;
+ if (applet->edge_relativity == PANEL_EDGE_CENTER ||
+ applet->edge_relativity == PANEL_EDGE_END) {
+ if (!panel_widget->packed) {
+ if (applet->edge_relativity == PANEL_EDGE_CENTER)
+ applet->position = panel_widget->size/2 + applet->position;
+ else if (applet->edge_relativity == PANEL_EDGE_END)
+ applet->position = panel_widget->size - applet->position;
+ }
else
applet->position = -1;
}
@@ -980,12 +985,12 @@ mate_panel_applet_load_idle_handler (gpo
}
void
-mate_panel_applet_queue_applet_to_load (const char *id,
- PanelObjectType type,
- const char *toplevel_id,
- int position,
- gboolean right_stick,
- gboolean locked)
+mate_panel_applet_queue_applet_to_load (const char *id,
+ PanelObjectType type,
+ const char *toplevel_id,
+ int position,
+ PanelObjectEdgeRelativity edge_relativity,
+ gboolean locked)
{
MatePanelAppletToLoad *applet;
@@ -996,12 +1001,12 @@ mate_panel_applet_queue_applet_to_load (
applet = g_new0 (MatePanelAppletToLoad, 1);
- applet->id = g_strdup (id);
- applet->type = type;
- applet->toplevel_id = g_strdup (toplevel_id);
- applet->position = position;
- applet->right_stick = right_stick != FALSE;
- applet->locked = locked != FALSE;
+ applet->id = g_strdup (id);
+ applet->type = type;
+ applet->toplevel_id = g_strdup (toplevel_id);
+ applet->position = position;
+ applet->edge_relativity = edge_relativity;
+ applet->locked = locked != FALSE;
mate_panel_applets_to_load = g_slist_prepend (mate_panel_applets_to_load, applet);
}
@@ -1014,8 +1019,8 @@ mate_panel_applet_compare (const MatePan
if ((c = strcmp (a->toplevel_id, b->toplevel_id)))
return c;
- else if (a->right_stick != b->right_stick)
- return b->right_stick ? -1 : 1;
+ else if (a->edge_relativity != b->edge_relativity)
+ return a->edge_relativity - b->edge_relativity;
else
return a->position - b->position;
}
@@ -1096,12 +1101,12 @@ mate_panel_applet_save_position (AppletI
const char *id,
gboolean immediate)
{
- PanelWidget *panel_widget;
- const char *toplevel_id;
- char *old_toplevel_id;
- gboolean right_stick;
- gboolean locked;
- int position;
+ PanelWidget *panel_widget;
+ const char *toplevel_id;
+ char *old_toplevel_id;
+ PanelObjectEdgeRelativity edge_relativity;
+ gboolean locked;
+ int position;
g_return_if_fail (applet_info != NULL);
@@ -1133,7 +1138,7 @@ mate_panel_applet_save_position (AppletI
g_free (old_toplevel_id);
/* Note: changing some properties of the panel that may not be locked down
- (e.g. background) can change the state of the "panel_right_stick" and
+ (e.g. background) can change the state of the "relative-to-edge" and
"position" properties of an applet that may in fact be locked down.
So check if these are writable before attempting to write them */
@@ -1144,18 +1149,32 @@ mate_panel_applet_save_position (AppletI
if (locked) {
// Until position calculations are refactored to fix the issue of the panel applets
// getting reordered on resolution changes...
- // .. don't save position/right-stick on locked applets
+ // .. don't save position/relative-to-edge on locked applets
return;
}
- right_stick = panel_is_applet_right_stick (applet_info->widget) ? 1 : 0;
+ edge_relativity = panel_determine_applet_edge_relativity (applet_info->widget);
+ if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY) &&
+ g_settings_get_enum (applet_info->settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY) != edge_relativity)
+ g_settings_set_enum (applet_info->settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY, edge_relativity);
+
+ /*
+ * If the deprecated `panel-right-stick` setting is set, unset it.
+ * See the `panel_profile_load_object ()` function in the file
+ * `panel-profile.c` for a lengthy comment detailing why this is
+ * done.
+ */
if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY) &&
- (g_settings_get_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY) ? 1 : 0) != right_stick)
- g_settings_set_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, right_stick);
+ g_settings_get_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY))
+ g_settings_set_boolean (applet_info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, FALSE);
position = mate_panel_applet_get_position (applet_info);
- if (right_stick && !panel_widget->packed)
- position = panel_widget->size - position;
+ if (!panel_widget->packed) {
+ if (edge_relativity == PANEL_EDGE_CENTER)
+ position -= panel_widget->size/2;
+ else if (edge_relativity == PANEL_EDGE_END)
+ position = panel_widget->size - position;
+ }
if (g_settings_is_writable (applet_info->settings, PANEL_OBJECT_POSITION_KEY) &&
g_settings_get_int (applet_info->settings, PANEL_OBJECT_POSITION_KEY) != position)
@@ -1372,7 +1391,7 @@ mate_panel_applet_can_freely_move (Apple
if (!g_settings_is_writable (applet->settings, PANEL_OBJECT_TOPLEVEL_ID_KEY))
return FALSE;
- if (!g_settings_is_writable (applet->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY))
+ if (!g_settings_is_writable (applet->settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY))
return FALSE;
return TRUE;
diff -uprN mate-panel-1.24.0-original/mate-panel/applet.h mate-panel-1.24.0-patched-r1/mate-panel/applet.h
--- mate-panel-1.24.0-original/mate-panel/applet.h 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/applet.h 2022-08-12 21:15:54.960208942 -0400
@@ -68,12 +68,12 @@ GSList *mate_panel_applet_list_apple
void mate_panel_applet_clean (AppletInfo *info);
-void mate_panel_applet_queue_applet_to_load (const char *id,
- PanelObjectType type,
- const char *toplevel_id,
- int position,
- gboolean right_stick,
- gboolean locked);
+void mate_panel_applet_queue_applet_to_load (const char *id,
+ PanelObjectType type,
+ const char *toplevel_id,
+ int position,
+ PanelObjectEdgeRelativity edge_relativity,
+ gboolean locked);
void mate_panel_applet_load_queued_applets (gboolean initial_load);
gboolean mate_panel_applet_on_load_queue (const char *id);
@@ -97,7 +97,7 @@ void mate_panel_applet_save_posit
int mate_panel_applet_get_position (AppletInfo *applet);
/* True if all the keys relevant to moving are writable
- (position, toplevel_id, panel_right_stick) */
+ (position, toplevel-id, relative-to-edge) */
gboolean mate_panel_applet_can_freely_move (AppletInfo *applet);
/* True if the locked flag is writable */
diff -uprN mate-panel-1.24.0-original/mate-panel/drawer.c mate-panel-1.24.0-patched-r1/mate-panel/drawer.c
--- mate-panel-1.24.0-original/mate-panel/drawer.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/drawer.c 2022-08-12 21:15:54.960208942 -0400
@@ -626,7 +626,7 @@ panel_drawer_create (PanelToplevel *topl
{
char *id;
- id = panel_profile_prepare_object (PANEL_OBJECT_DRAWER, toplevel, position, FALSE);
+ id = panel_profile_prepare_object (PANEL_OBJECT_DRAWER, toplevel, position);
panel_drawer_prepare (id, custom_icon, use_custom_icon, tooltip, NULL);
@@ -645,7 +645,7 @@ panel_drawer_create_with_id (const char
char *id;
char *attached_toplevel_id = NULL;
- id = panel_profile_prepare_object_with_id (PANEL_OBJECT_DRAWER, toplevel_id, position, FALSE);
+ id = panel_profile_prepare_object_with_id (PANEL_OBJECT_DRAWER, toplevel_id, position);
panel_drawer_prepare (id, custom_icon, use_custom_icon, tooltip, &attached_toplevel_id);
diff -uprN mate-panel-1.24.0-original/mate-panel/launcher.c mate-panel-1.24.0-patched-r1/mate-panel/launcher.c
--- mate-panel-1.24.0-original/mate-panel/launcher.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/launcher.c 2022-08-12 21:15:54.960208942 -0400
@@ -1062,8 +1062,7 @@ panel_launcher_create_with_id (const cha
id = panel_profile_prepare_object_with_id (PANEL_OBJECT_LAUNCHER,
toplevel_id,
- position,
- FALSE);
+ position);
path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-action-button.c mate-panel-1.24.0-patched-r1/mate-panel/panel-action-button.c
--- mate-panel-1.24.0-original/mate-panel/panel-action-button.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-action-button.c 2022-08-12 21:15:54.960208942 -0400
@@ -774,7 +774,7 @@ panel_action_button_create (PanelTopleve
char *id;
char *path;
- id = panel_profile_prepare_object (PANEL_OBJECT_ACTION, toplevel, position, FALSE);
+ id = panel_profile_prepare_object (PANEL_OBJECT_ACTION, toplevel, position);
path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-applet-frame.c mate-panel-1.24.0-patched-r1/mate-panel/panel-applet-frame.c
--- mate-panel-1.24.0-original/mate-panel/panel-applet-frame.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-applet-frame.c 2022-08-12 21:15:54.960208942 -0400
@@ -1071,7 +1071,7 @@ mate_panel_applet_frame_create (PanelTop
g_return_if_fail (iid != NULL);
- id = panel_profile_prepare_object (PANEL_OBJECT_APPLET, toplevel, position, FALSE);
+ id = panel_profile_prepare_object (PANEL_OBJECT_APPLET, toplevel, position);
path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff -uprN mate-panel-1.24.0-original/mate-panel/panel.c mate-panel-1.24.0-patched-r1/mate-panel/panel.c
--- mate-panel-1.24.0-original/mate-panel/panel.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel.c 2022-08-12 21:15:54.970208942 -0400
@@ -1263,24 +1263,24 @@ panel_screen_from_panel_widget (PanelWid
return gtk_window_get_screen (GTK_WINDOW (panel->toplevel));
}
-gboolean
-panel_is_applet_right_stick (GtkWidget *applet)
+PanelObjectEdgeRelativity
+panel_determine_applet_edge_relativity (GtkWidget *applet)
{
GtkWidget *parent;
PanelWidget *panel_widget;
- g_return_val_if_fail (GTK_IS_WIDGET (applet), FALSE);
+ g_return_val_if_fail (GTK_IS_WIDGET (applet), PANEL_EDGE_START);
parent = gtk_widget_get_parent (applet);
- g_return_val_if_fail (PANEL_IS_WIDGET (parent), FALSE);
+ g_return_val_if_fail (PANEL_IS_WIDGET (parent), PANEL_EDGE_START);
panel_widget = PANEL_WIDGET (parent);
if (!panel_toplevel_get_expand (panel_widget->toplevel))
- return FALSE;
+ return PANEL_EDGE_START;
- return panel_widget_is_applet_stuck (panel_widget, applet);
+ return panel_widget_determine_applet_edge_relativity (panel_widget, applet);
}
static void
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-enums-gsettings.h mate-panel-1.24.0-patched-r1/mate-panel/panel-enums-gsettings.h
--- mate-panel-1.24.0-original/mate-panel/panel-enums-gsettings.h 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-enums-gsettings.h 2022-08-12 21:15:54.970208942 -0400
@@ -60,6 +60,12 @@ typedef enum {
} PanelObjectType;
typedef enum {
+ PANEL_EDGE_START = 0,
+ PANEL_EDGE_CENTER = 1,
+ PANEL_EDGE_END = 2
+} PanelObjectEdgeRelativity;
+
+typedef enum {
PANEL_ACTION_NONE = 0,
PANEL_ACTION_LOCK,
PANEL_ACTION_LOGOUT,
diff -uprN mate-panel-1.24.0-original/mate-panel/panel.h mate-panel-1.24.0-patched-r1/mate-panel/panel.h
--- mate-panel-1.24.0-original/mate-panel/panel.h 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel.h 2022-08-12 21:15:54.970208942 -0400
@@ -26,7 +26,7 @@ PanelData *panel_setup (PanelToplevel *t
GdkScreen *panel_screen_from_panel_widget (PanelWidget *panel);
-gboolean panel_is_applet_right_stick (GtkWidget *applet);
+PanelObjectEdgeRelativity panel_determine_applet_edge_relativity (GtkWidget *applet);
gboolean panel_check_dnd_target_data (GtkWidget *widget,
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-layout.c mate-panel-1.24.0-patched-r1/mate-panel/panel-layout.c
--- mate-panel-1.24.0-original/mate-panel/panel-layout.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-layout.c 2022-08-12 21:15:54.970208942 -0400
@@ -76,6 +76,7 @@ static PanelLayoutKeyDefinition panel_la
{ PANEL_OBJECT_TOPLEVEL_ID_KEY, G_TYPE_STRING },
{ PANEL_OBJECT_POSITION_KEY, G_TYPE_INT },
{ PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, G_TYPE_BOOLEAN },
+ { PANEL_OBJECT_RELATIVE_TO_EDGE_KEY, G_TYPE_STRING },
{ PANEL_OBJECT_LOCKED_KEY, G_TYPE_BOOLEAN },
{ PANEL_OBJECT_APPLET_IID_KEY, G_TYPE_STRING },
{ PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY, G_TYPE_STRING },
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-menu-bar.c mate-panel-1.24.0-patched-r1/mate-panel/panel-menu-bar.c
--- mate-panel-1.24.0-original/mate-panel/panel-menu-bar.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-menu-bar.c 2022-08-12 21:15:54.970208942 -0400
@@ -375,7 +375,7 @@ void panel_menu_bar_create(PanelToplevel
{
char* id;
- id = panel_profile_prepare_object(PANEL_OBJECT_MENU_BAR, toplevel, position, FALSE);
+ id = panel_profile_prepare_object(PANEL_OBJECT_MENU_BAR, toplevel, position);
panel_profile_add_to_list(PANEL_GSETTINGS_OBJECTS, id);
g_free(id);
}
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-menu-button.c mate-panel-1.24.0-patched-r1/mate-panel/panel-menu-button.c
--- mate-panel-1.24.0-original/mate-panel/panel-menu-button.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-menu-button.c 2022-08-12 21:15:54.980208942 -0400
@@ -973,7 +973,7 @@ panel_menu_button_create (PanelToplevel
const char *scheme;
char *id;
- id = panel_profile_prepare_object (PANEL_OBJECT_MENU, toplevel, position, FALSE);
+ id = panel_profile_prepare_object (PANEL_OBJECT_MENU, toplevel, position);
path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-profile.c mate-panel-1.24.0-patched-r1/mate-panel/panel-profile.c
--- mate-panel-1.24.0-original/mate-panel/panel-profile.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-profile.c 2022-08-12 21:15:54.980208942 -0400
@@ -1214,10 +1214,9 @@ panel_profile_destroy_toplevel (const ch
}
char *
-panel_profile_prepare_object_with_id (PanelObjectType object_type,
- const char *toplevel_id,
- int position,
- gboolean right_stick)
+panel_profile_prepare_object_with_id (PanelObjectType object_type,
+ const char *toplevel_id,
+ int position)
{
PanelGSettingsKeyType key_type;
char *id;
@@ -1234,7 +1233,6 @@ panel_profile_prepare_object_with_id (Pa
g_settings_set_enum (settings, PANEL_OBJECT_TYPE_KEY, object_type);
g_settings_set_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY, toplevel_id);
g_settings_set_int (settings, PANEL_OBJECT_POSITION_KEY, position);
- g_settings_set_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY, right_stick);
g_free (settings_path);
g_object_unref (settings);
@@ -1243,15 +1241,13 @@ panel_profile_prepare_object_with_id (Pa
}
char *
-panel_profile_prepare_object (PanelObjectType object_type,
- PanelToplevel *toplevel,
- int position,
- gboolean right_stick)
+panel_profile_prepare_object (PanelObjectType object_type,
+ PanelToplevel *toplevel,
+ int position)
{
return panel_profile_prepare_object_with_id (object_type,
panel_profile_get_toplevel_id (toplevel),
- position,
- right_stick);
+ position);
}
void
@@ -1269,13 +1265,13 @@ panel_profile_delete_object (AppletInfo
static void
panel_profile_load_object (char *id)
{
- PanelObjectType object_type;
- char *object_path;
- char *toplevel_id;
- int position;
- gboolean right_stick;
- gboolean locked;
- GSettings *settings;
+ PanelObjectType object_type;
+ char *object_path;
+ char *toplevel_id;
+ int position;
+ PanelObjectEdgeRelativity edge_relativity;
+ gboolean locked;
+ GSettings *settings;
object_path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, object_path);
@@ -1283,14 +1279,53 @@ panel_profile_load_object (char *id)
object_type = g_settings_get_enum (settings, PANEL_OBJECT_TYPE_KEY);
position = g_settings_get_int (settings, PANEL_OBJECT_POSITION_KEY);
toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY);
- right_stick = g_settings_get_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY);
+ edge_relativity = g_settings_get_enum (settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY);
locked = g_settings_get_boolean (settings, PANEL_OBJECT_LOCKED_KEY);
+ /* If a panel layout uses the deprecated 'panel-right-stick' property,
+ * interpret the position of the applet relative to the applet's left
+ * side, rather than its right like we'd do for end-relative objects.
+ * The position of an end-relative applet is relative to the *right*
+ * side of the applet, which makes more sense, IMHO. The difference
+ * between these two positioning schemes is on the order of the width
+ * of the applet; without this backwards-compatible safeguard, many of
+ * the user's manually-placed right-stuck applets may be moved far out
+ * of place when they upgrade the panel to this version.
+ *
+ * The `panel-right-stick` property will, unfortunately, remain set,
+ * unless and until the user explicitly moves the applet under the new
+ * version of the panel. Keeping the `panel-right-stick` property set
+ * is necessary since we can't know the equivalent 'edge-relative'
+ * position to use in the place of the old, 'right-stuck' position;
+ * after all, we have no idea of the size of the applet when it was
+ * first positioned on the panel. (Some applets dynamically change
+ * size; sure, chances are right-stuck applets will be forced /
+ * constrained to the very far right side of the panel, but who knows,
+ * somebody might have set the positions of their applets using a
+ * layout file or directly via GSettings.)
+ *
+ * If the user moves the applets, of course, the applets will be
+ * repositioned edge-relatively, which is good -- unless the user ever
+ * downgrades the panel, in which case the applets will be in the wrong
+ * places. However, there's a limit to what you can do -- hopefully
+ * the user will only downgrade the panel if they know what they are
+ * doing, and the user will have a completely screwed-up panel if they
+ * *center*-stuck applets and then downgraded. So the point of this
+ * hack is to ensure the user experiences a seamless (or nearly
+ * seamless) transition forward, but if the user moves backward a few
+ * versions, then we really can't help them.
+ */
+ if (g_settings_get_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY)) {
+ edge_relativity = PANEL_EDGE_END;
+ g_settings_set_enum (settings, PANEL_OBJECT_RELATIVE_TO_EDGE_KEY, edge_relativity);
+ }
+
+
mate_panel_applet_queue_applet_to_load (id,
object_type,
toplevel_id,
position,
- right_stick,
+ edge_relativity,
locked);
g_free (toplevel_id);
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-profile.h mate-panel-1.24.0-patched-r1/mate-panel/panel-profile.h
--- mate-panel-1.24.0-original/mate-panel/panel-profile.h 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-profile.h 2022-08-12 21:15:54.980208942 -0400
@@ -51,23 +51,21 @@ gboolean panel_profile_get_enable_pro
gboolean panel_profile_get_enable_autocompletion (void);
-void panel_profile_add_to_list (PanelGSettingsKeyType type,
- const char *id);
-void panel_profile_remove_from_list (PanelGSettingsKeyType type,
- const char *id);
+void panel_profile_add_to_list (PanelGSettingsKeyType type,
+ const char *id);
+void panel_profile_remove_from_list (PanelGSettingsKeyType type,
+ const char *id);
gboolean panel_profile_id_lists_are_writable (void);
-void panel_profile_create_toplevel (GdkScreen *screen);
-PanelToplevel *panel_profile_load_toplevel (const char *toplevel_id);
-void panel_profile_delete_toplevel (PanelToplevel *toplevel);
-char *panel_profile_prepare_object (PanelObjectType object_type,
- PanelToplevel *toplevel,
- int position,
- gboolean right_stick);
-char *panel_profile_prepare_object_with_id (PanelObjectType object_type,
- const char *toplevel_id,
- int position,
- gboolean right_stick);
-void panel_profile_delete_object (AppletInfo *applet_info);
+void panel_profile_create_toplevel (GdkScreen *screen);
+PanelToplevel *panel_profile_load_toplevel (const char *toplevel_id);
+void panel_profile_delete_toplevel (PanelToplevel *toplevel);
+char *panel_profile_prepare_object (PanelObjectType object_type,
+ PanelToplevel *toplevel,
+ int position);
+char *panel_profile_prepare_object_with_id (PanelObjectType object_type,
+ const char *toplevel_id,
+ int position);
+void panel_profile_delete_object (AppletInfo *applet_info);
gboolean panel_profile_key_is_writable (PanelToplevel *toplevel,
gchar *key);
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-schemas.h mate-panel-1.24.0-patched-r1/mate-panel/panel-schemas.h
--- mate-panel-1.24.0-original/mate-panel/panel-schemas.h 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-schemas.h 2022-08-12 21:15:54.990208942 -0400
@@ -47,6 +47,7 @@
#define PANEL_OBJECT_TOPLEVEL_ID_KEY "toplevel-id"
#define PANEL_OBJECT_POSITION_KEY "position"
#define PANEL_OBJECT_PANEL_RIGHT_STICK_KEY "panel-right-stick"
+#define PANEL_OBJECT_RELATIVE_TO_EDGE_KEY "relative-to-edge"
#define PANEL_OBJECT_LOCKED_KEY "locked"
#define PANEL_OBJECT_APPLET_IID_KEY "applet-iid"
#define PANEL_OBJECT_ATTACHED_TOPLEVEL_ID_KEY "attached-toplevel-id"
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-separator.c mate-panel-1.24.0-patched-r1/mate-panel/panel-separator.c
--- mate-panel-1.24.0-original/mate-panel/panel-separator.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-separator.c 2022-08-12 21:15:54.990208942 -0400
@@ -262,7 +262,7 @@ panel_separator_create (PanelToplevel *t
char *id;
id = panel_profile_prepare_object (PANEL_OBJECT_SEPARATOR,
- toplevel, position, FALSE);
+ toplevel, position);
panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id);
g_free (id);
}
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-toplevel.c mate-panel-1.24.0-patched-r1/mate-panel/panel-toplevel.c
--- mate-panel-1.24.0-original/mate-panel/panel-toplevel.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-toplevel.c 2022-08-12 21:15:55.000208942 -0400
@@ -2908,11 +2908,6 @@ panel_toplevel_move_resize_window (Panel
{
GtkWidget *widget;
- GList *list;
- const char *id;
- int position;
- gboolean stick;
-
widget = GTK_WIDGET (toplevel);
g_assert (gtk_widget_get_realized (widget));
@@ -2931,30 +2926,6 @@ panel_toplevel_move_resize_window (Panel
gdk_window_resize (gtk_widget_get_window (widget),
toplevel->priv->geometry.width,
toplevel->priv->geometry.height);
-
- if (resize || move) {
- for (list = toplevel->priv->panel_widget->applet_list; list != NULL; list = g_list_next (list)) {
- AppletData *ad = list->data;
- id = mate_panel_applet_get_id_by_widget (ad->applet);
-
- if (!id)
- return;
-
- AppletInfo *info;
- info = mate_panel_applet_get_by_id (id);
-
- stick = g_settings_get_boolean (info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY);
-
- if (stick) {
- position = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY);
- if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
- ad->pos = toplevel->priv->geometry.width - position;
- } else {
- ad->pos = toplevel->priv->geometry.height - position;
- }
- }
- }
- }
}
static void
diff -uprN mate-panel-1.24.0-original/mate-panel/panel-widget.c mate-panel-1.24.0-patched-r1/mate-panel/panel-widget.c
--- mate-panel-1.24.0-original/mate-panel/panel-widget.c 2020-02-10 07:16:55.000000000 -0500
+++ mate-panel-1.24.0-patched-r1/mate-panel/panel-widget.c 2022-08-12 21:21:15.850209602 -0400
@@ -29,8 +29,11 @@
#include "panel-globals.h"
#include "panel-profile.h"
#include "panel-lockdown.h"
+#include "panel-schemas.h"
-#define MOVE_INCREMENT 1
+#define MOVE_INCREMENT 1
+/* The following was originally from panel-toplevel.c */
+#define SNAP_TOLERANCE_FACTOR 6
typedef enum {
PANEL_SWITCH_MOVE = 0,
@@ -623,36 +626,89 @@ get_applet_list_pos (PanelWidget *panel,
return NULL;
}
-/*tells us if an applet is "stuck" on the right side*/
-int
-panel_widget_is_applet_stuck (PanelWidget *panel_widget,
- GtkWidget *widget)
-{
- AppletData *applet;
+/*
+ * This function determines whether the given panel applet should be positioned
+ * relative to the center or end of the panel; that is, whether the applet
+ * is part of a contiguous group of other applets, one of which touches the
+ * center or end of the panel.
+ */
+PanelObjectEdgeRelativity
+panel_widget_determine_applet_edge_relativity (PanelWidget *panel_widget,
+ GtkWidget *widget)
+{
+ AppletData *applet_in_question;
+ gboolean applet_is_centered = FALSE;
+
+ g_return_val_if_fail (PANEL_IS_WIDGET (panel_widget), PANEL_EDGE_START);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), PANEL_EDGE_START);
+
+ applet_in_question = g_object_get_data (G_OBJECT (widget), MATE_PANEL_APPLET_DATA);
+ if (applet_in_question) {
+ GList *applet_list, *l;
+ AppletData *applet;
+ int start_pos, end_pos;
+
+ applet_list = g_list_find (panel_widget->applet_list, applet_in_question);
+ start_pos = applet_in_question->constrained;
+ end_pos = applet_in_question->constrained;
- g_return_val_if_fail (PANEL_IS_WIDGET (panel_widget), FALSE);
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+ /*
+ * Start by moving towards the start of the panel, checking
+ * whether any applets lie on the panel's center.
+ */
+ for (l = applet_list; l; l = l->prev)
+ {
+ applet = l->data;
- applet = g_object_get_data (G_OBJECT (widget), MATE_PANEL_APPLET_DATA);
- if (applet) {
- GList *applet_list, *l;
- int end_pos = -1;
+ if (applet->constrained + applet->cells < end_pos)
+ break;
- applet_list = g_list_find (panel_widget->applet_list, applet);
+ if (applet->constrained <= panel_widget->size/2 &&
+ applet->constrained + applet->cells > panel_widget->size/2)
+ applet_is_centered = TRUE;
+
+ end_pos = applet->constrained;
+ if (end_pos <= 0)
+ /*
+ * If the applet in question is part of a line
+ * of contiguous applets, the first of which
+ * touches the start of the panel, then don't
+ * center this applet under any circumstances.
+ */
+ return PANEL_EDGE_START;
+ }
- for (l = applet_list; l; l = l->next) {
+ /*
+ * Now move towards the panel's end, looking for applets that
+ * cross the center of the panel.
+ */
+ for (l = applet_list; l; l = l->next)
+ {
applet = l->data;
- if (end_pos != -1 && applet->pos != end_pos)
+ if (applet->constrained > start_pos)
break;
- end_pos = applet->pos + applet->cells;
- if (end_pos >= panel_widget->size)
- return TRUE;
+ if (applet->constrained <= panel_widget->size/2 &&
+ applet->constrained + applet->cells > panel_widget->size/2)
+ applet_is_centered = TRUE;
+
+ start_pos += applet->cells;
+ if (start_pos >= panel_widget->size)
+ /*
+ * If the applet in question is part of a line
+ * of contiguous applets, the last of which
+ * touches the end of the panel, then the
+ * applet is actually end-relative.
+ */
+ return PANEL_EDGE_END;
}
}
- return FALSE;
+ if (applet_is_centered)
+ return PANEL_EDGE_CENTER;
+
+ return PANEL_EDGE_START;
}
static int
@@ -676,6 +732,24 @@ get_size_from_hints (AppletData *ad, int
return MAX (cells, ad->min_cells);
}
+/*
+ * A utility function to adjust an applet's position by its allocated size,
+ * if the applet is end-relative or centered.
+ */
+static void
+adjust_applet_position (PanelWidget *panel,
+ AppletData *ad)
+{
+ PanelObjectEdgeRelativity edge_relativity;
+
+ edge_relativity = panel_widget_determine_applet_edge_relativity (panel, ad->applet);
+
+ if (edge_relativity == PANEL_EDGE_CENTER)
+ ad->pos += ad->cells/2;
+ else if (edge_relativity == PANEL_EDGE_END)
+ ad->pos += ad->cells;