Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix floating menu regression #110

Merged
merged 2 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1260,33 +1260,25 @@ <h2>Xpra Bug Report</h2>
}

function init_float_menu() {
const toolbar_position = getparam("toolbar_position");
const floating_menu = getboolparam("floating_menu", true);
const autohide = getboolparam("autohide", false);
const toolbar_position = getparam("toolbar_position");
const float_menu_element = $('#float_menu');
if (!floating_menu) {
//nothing to do, it starts hidden
return;
}
float_menu_element.fadeIn();
var toolbar_width = float_menu_element.width();
var left = 0;
var top = float_menu_element.offset().top || 0;
var screen_width = $('#screen').width();
if (toolbar_position=="top-left") {
//no calculations needed
}
else if (toolbar_position=="top") {
left = screen_width/2-toolbar_width/2;
}
else if (toolbar_position=="top-right") {
left = screen_width-toolbar_width-100;
if(client){
client.toolbar_position = toolbar_position;
}
float_menu_element.offset({ top: top, left: left });

if (autohide) {
float_menu_element.on('mouseover', expand_float_menu);
float_menu_element.on('mouseout', retract_float_menu);
// Expand and retract the floating menu so it
// is correctly positioned and collapsed
expand_float_menu();
retract_float_menu();
}
else {
expand_float_menu();
Expand Down
27 changes: 27 additions & 0 deletions html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ XpraClient.prototype.init_state = function(container) {
this.server_ok = false;
//packet handling
this.decode_worker = null;
// floating menu
this.toolbar_position = "top";

this.server_display = "";
this.server_platform = "";
Expand Down Expand Up @@ -603,6 +605,8 @@ XpraClient.prototype._screen_resized = function(event, ctx) {
const iwin = ctx.id_to_window[i];
iwin.screen_resized();
}
// Re-position floating toolbar menu
this.position_float_menu();
};

/**
Expand Down Expand Up @@ -2342,6 +2346,28 @@ XpraClient.prototype.stop_info_timer = function() {
/**
* System Tray forwarding
*/

XpraClient.prototype.position_float_menu = function() {
const float_menu_element = $('#float_menu');
var toolbar_width = float_menu_element.width();
var left = float_menu_element.offset().left || 0;
var top = float_menu_element.offset().top || 0;
var screen_width = $('#screen').width();
if (this.toolbar_position=="custom") {
//no calculations needed
}
else if (this.toolbar_position=="top-left") {
//no calculations needed
}
else if (this.toolbar_position=="top") {
left = screen_width/2-toolbar_width/2;
}
else if (this.toolbar_position=="top-right") {
left = screen_width-toolbar_width-100;
}
float_menu_element.offset({ top: top, left: left });
}

XpraClient.prototype._process_new_tray = function(packet, ctx) {
const wid = packet[1];
//let w = packet[2];
Expand Down Expand Up @@ -2419,6 +2445,7 @@ XpraClient.prototype.reconfigure_all_trays = function() {
// only set if float_menu is visible
if($('#float_menu').width() > 0){
float_menu.style.width = float_menu_width;
this.position_float_menu();
}
};

Expand Down
1 change: 1 addition & 0 deletions html5/js/Menu-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ $(function() {
});
float_menu.on("dragstop",function(ev,ui){
client.mouse_grabbed = false;
client.toolbar_position="custom";
client.reconfigure_all_trays();
});

Expand Down