Skip to content

Commit d44181b

Browse files
committed
Improve backward compatibility to 4.2 and fix remaining 5.4 bugs
1 parent faf4471 commit d44181b

File tree

9 files changed

+67
-67
lines changed

9 files changed

+67
-67
lines changed

workspace-grid@hernejj/files/workspace-grid@hernejj/5.4/BarIndicatorStyle.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,51 @@ function BarIndicatorStyle(applet, cols, rows, height) {
77
}
88

99
BarIndicatorStyle.prototype = {
10-
10+
1111
_init: function(applet, cols, rows, height) {
1212
this.applet = applet;
1313
this.button = [];
1414
this.update_grid(cols, rows, height);
1515
this.switch_id = global.window_manager.connect('switch-workspace', Lang.bind(this, this.update));
1616
this.scroll_id = this.applet.actor.connect('scroll-event', Lang.bind(this,this.onMouseScroll));
1717
},
18-
18+
1919
update_grid: function(cols, rows, height) {
2020
this.cols = cols;
2121
this.rows = rows;
2222
this.height = height;
2323
this.rebuild();
2424
},
25-
25+
2626
cleanup: function() {
2727
global.window_manager.disconnect(this.switch_id);
2828
this.applet.actor.disconnect(this.scroll_id);
2929
},
30-
30+
3131
onMouseScroll: function(actor, event){
3232
if (this.scrollby == 'row')
3333
this.scrollByRow(event);
3434
else
3535
this.scrollByCol(event);
3636
},
37-
37+
3838
scrollByCol: function(event) {
3939
var idx = global.screen.get_active_workspace_index();
40-
41-
if (event.get_scroll_direction() == 0) idx--;
40+
41+
if (event.get_scroll_direction() == 0) idx--;
4242
else if (event.get_scroll_direction() == 1) idx++;
43-
43+
4444
if(global.screen.get_workspace_by_index(idx) != null)
4545
global.screen.get_workspace_by_index(idx).activate(global.get_current_time());
4646
},
47-
47+
4848
scrollByRow: function(event) {
4949
var idx = global.screen.get_active_workspace_index();
5050
var numworkspaces = this.rows * this.cols;
51-
51+
5252
var row = Math.floor(idx/this.cols);
5353
var col = idx % this.cols;
54-
54+
5555
if (event.get_scroll_direction() == 0) {
5656
row--;
5757
if (row < 0) {
@@ -66,19 +66,19 @@ BarIndicatorStyle.prototype = {
6666
col++;
6767
}
6868
}
69-
69+
7070
if (col < 0 || col >= this.cols)
7171
return;
72-
72+
7373
idx = row*this.cols + col;
74-
74+
7575
if(global.screen.get_workspace_by_index(idx) != null)
7676
global.screen.get_workspace_by_index(idx).activate(global.get_current_time());
7777
},
7878

7979
onRowIndicatorClicked: function(actor, event) {
8080
if (event.get_button() != 1) return false;
81-
81+
8282
let curws_idx = global.screen.get_active_workspace_index();
8383
let curws_row = Math.floor(curws_idx/this.cols);
8484
let [x, y] = event.get_coords();
@@ -89,20 +89,20 @@ BarIndicatorStyle.prototype = {
8989
let clicked_row = Math.floor(this.rows*y/h);
9090
clicked_idx = (clicked_row * this.cols) + (curws_idx % this.cols);
9191

92-
global.screen.get_workspace_by_index(clicked_idx).activate(global.get_current_time());
92+
global.screen.get_workspace_by_index(clicked_idx).activate(global.get_current_time());
9393
return true;
9494
},
9595

9696
onWorkspaceButtonClicked: function(actor, event) {
9797
if (event.get_button() != 1) return false;
9898
global.screen.get_workspace_by_index(actor.index).activate(global.get_current_time());
9999
},
100-
100+
101101
setReactivity: function(reactive) {
102102
for (let i=0; i < this.button.length; ++i)
103103
this.button[i].set_reactive(reactive);
104-
},
105-
104+
},
105+
106106
rebuild: function() {
107107
this.applet.actor.destroy_all_children();
108108

@@ -117,7 +117,7 @@ BarIndicatorStyle.prototype = {
117117
this.button = [];
118118
for ( let i=0; i<global.screen.n_workspaces; ++i ) {
119119
this.button[i] = new St.Button({ name: 'workspaceButton', style_class: 'workspace-button', reactive: true });
120-
120+
121121
let text = (i+1).toString();
122122
let label = new St.Label({ text: text });
123123
label.set_style("font-weight: bold");
@@ -137,19 +137,19 @@ BarIndicatorStyle.prototype = {
137137
let active_row = Math.floor(active_ws/this.cols);
138138
let low = (active_row)*this.cols;
139139
let high = low + this.cols;
140-
140+
141141
// If the user added or removed workspaces external to this applet then
142142
// we could end up with a selected workspaces that is out of bounds. Just
143143
// revert to displaying the last row in that case.
144144
if (active_ws >= nworks) {
145145
high = nworks - 1;
146146
low = high - this.cols;
147147
}
148-
148+
149149
for (let i=0; i < nworks; ++i) {
150150
if (i >= low && i < high) this.button[i].show();
151151
else this.button[i].hide();
152-
152+
153153
if (i == active_ws) {
154154
this.button[i].get_child().set_text((i+1).toString());
155155
this.button[i].add_style_pseudo_class('outlined');
@@ -159,21 +159,21 @@ BarIndicatorStyle.prototype = {
159159
this.button[i].remove_style_pseudo_class('outlined');
160160
}
161161
}
162-
162+
163163
if ( this.row_indicator ) {
164164
this.row_indicator.queue_repaint();
165165
}
166166
},
167-
167+
168168
draw_row_indicator: function(area) {
169169
let [width, height] = area.get_surface_size();
170170
let themeNode = this.row_indicator.get_theme_node();
171171
let cr = area.get_context();
172-
172+
173173
let base_color = this.get_base_color();
174174
let active_color = null;
175175
let inactive_color = null;
176-
176+
177177
if (this.is_theme_light_on_dark()) {
178178
active_color = base_color.lighten();
179179
inactive_color = base_color.darken();
@@ -182,10 +182,10 @@ BarIndicatorStyle.prototype = {
182182
active_color = base_color.darken().darken();
183183
inactive_color = base_color.lighten().lighten();
184184
}
185-
185+
186186
let active = global.screen.get_active_workspace_index();
187187
let active_row = Math.floor(active/this.cols);
188-
188+
189189
// Catch overflow due to externally added/removed workspaces
190190
if (active >= this.button.length) active_row = (this.button.length-1) /this.cols;
191191

@@ -200,20 +200,20 @@ BarIndicatorStyle.prototype = {
200200
cr.stroke();
201201
}
202202
},
203-
203+
204204
is_theme_light_on_dark: function() {
205205
let selected_idx = global.screen.get_active_workspace_index();
206206
let unselected_idx = 0;
207207
if (unselected_idx == selected_idx) unselected_idx = 1;
208-
208+
209209
let selected_txt_color = this.button[selected_idx].get_theme_node().get_color('color');
210210
let unselected_txt_color = this.button[unselected_idx].get_theme_node().get_color('color');
211211

212212
let sel_avg = (selected_txt_color.red + selected_txt_color.green + selected_txt_color.blue)/3;
213213
let unsel_avg = (unselected_txt_color.red + unselected_txt_color.green + unselected_txt_color.blue)/3;
214214
return (sel_avg < unsel_avg);
215215
},
216-
216+
217217
// All colors we use in this applet are based on this theme defined color.
218218
// We simply grab the color of a normal, non-outlined workspae button.
219219
get_base_color: function() {

workspace-grid@hernejj/files/workspace-grid@hernejj/5.4/GridStyle.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function GridStyle(applet, cols, rows, height) {
77
}
88

99
GridStyle.prototype = {
10-
10+
1111
_init: function(applet, cols, rows, height) {
1212
this.scrollby = 'col';
1313
this.applet = applet;
@@ -17,43 +17,43 @@ GridStyle.prototype = {
1717
this.switch_id = global.window_manager.connect('switch-workspace', Lang.bind(this, this.update));
1818
this.scroll_id = this.applet.actor.connect('scroll-event', Lang.bind(this,this.onMouseScroll));
1919
},
20-
20+
2121
cleanup: function() {
2222
global.window_manager.disconnect(this.switch_id);
2323
this.applet.actor.disconnect(this.scroll_id);
2424
},
25-
25+
2626
update_grid: function(cols, rows, height) {
2727
this.cols = cols;
2828
this.rows = rows;
2929
this.height = height;
3030
this.rebuild();
3131
},
32-
32+
3333
onMouseScroll: function(actor, event){
3434
if (this.scrollby == 'row')
3535
this.scrollByRow(event);
3636
else
3737
this.scrollByCol(event);
3838
},
39-
39+
4040
scrollByCol: function(event) {
4141
var idx = global.screen.get_active_workspace_index();
42-
43-
if (event.get_scroll_direction() == 0) idx--;
42+
43+
if (event.get_scroll_direction() == 0) idx--;
4444
else if (event.get_scroll_direction() == 1) idx++;
45-
45+
4646
if(global.screen.get_workspace_by_index(idx) != null)
4747
global.screen.get_workspace_by_index(idx).activate(global.get_current_time());
4848
},
49-
49+
5050
scrollByRow: function(event) {
5151
var idx = global.screen.get_active_workspace_index();
5252
var numworkspaces = this.rows * this.cols;
53-
53+
5454
var row = Math.floor(idx/this.cols);
5555
var col = idx % this.cols ;
56-
56+
5757
if (event.get_scroll_direction() == 0) {
5858
row--;
5959
if (row < 0) {
@@ -68,12 +68,12 @@ GridStyle.prototype = {
6868
col++;
6969
}
7070
}
71-
71+
7272
if (col < 0 || col >= this.cols)
7373
return;
74-
74+
7575
idx = row*this.cols + col;
76-
76+
7777
if(global.screen.get_workspace_by_index(idx) != null)
7878
global.screen.get_workspace_by_index(idx).activate(global.get_current_time());
7979
},
@@ -82,23 +82,23 @@ GridStyle.prototype = {
8282
if (event.get_button() != 1) return false;
8383
global.screen.get_workspace_by_index(actor.index).activate(global.get_current_time());
8484
},
85-
85+
8686
setReactivity: function(reactive) {
8787
for (let i=0; i < this.button.length; ++i)
88-
this.button[i].reactive = reactive;
89-
},
90-
88+
this.button[i].reactive = reactive;
89+
},
90+
9191
rebuild: function() {
9292
this.applet.actor.destroy_all_children();
9393
this.table = new St.Table({homogeneous: false, reactive: true });
9494
this.applet.actor.add(this.table);
95-
95+
9696
let btn_height = this.height/this.rows;
9797
this.button = [];
9898
for(let r=0; r < this.rows; r++) {
9999
for(let c=0; c < this.cols; c++) {
100100
let i = (r*this.cols)+c;
101-
101+
102102
this.button[i] = new St.Button({ name: 'workspaceButton', style_class: 'workspace-button', reactive: true });
103103
this.button[i].index = i;
104104
this.button[i].set_height(btn_height);
@@ -112,13 +112,13 @@ GridStyle.prototype = {
112112

113113
update: function() {
114114
let active_ws = global.screen.get_active_workspace_index();
115-
115+
116116
for (let i=0; i < this.button.length; ++i) {
117117
if (i == active_ws)
118118
this.button[i].add_style_pseudo_class('outlined');
119119
else
120120
this.button[i].remove_style_pseudo_class('outlined');
121121
}
122-
}
122+
}
123123
};
124124

workspace-grid@hernejj/files/workspace-grid@hernejj/5.4/WorkspaceController.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ function WorkspaceController(cols, rows) {
55
}
66

77
WorkspaceController.prototype = {
8-
8+
99
_init: function(cols, rows) {
1010
this.set_workspace_grid(cols, rows);
1111
},
12-
12+
1313
// Create proper workspace layout geometry within Gnome
1414
set_workspace_grid: function (cols, rows) {
1515
this.cols = cols;
1616
this.rows = rows;
1717
this.__equalize_num_workspaces();
1818
global.screen.override_workspace_layout(TOPLEFT, false, rows, cols);
1919
},
20-
20+
2121
// Update Gnome's view of workspaces to reflect our count based on row*col.
2222
__equalize_num_workspaces: function() {
2323
let new_ws_count = this.cols * this.rows;
2424
let old_ws_count = global.screen.n_workspaces;
25-
25+
2626
if (new_ws_count > old_ws_count) {
2727
for (let i=old_ws_count; i<new_ws_count; i++)
2828
global.screen.append_new_workspace(false, global.get_current_time());
@@ -34,7 +34,7 @@ WorkspaceController.prototype = {
3434
}
3535
}
3636
},
37-
37+
3838
// This applet is going away. Revert to allowing Cinnamon to control workspaces.
3939
release_control: function() {
4040
this.set_workspace_grid(-1, 1); // Set to no rows, and a single desktop

0 commit comments

Comments
 (0)