Skip to content

Commit

Permalink
undo more dumb formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 14, 2024
1 parent 124f57e commit cffed14
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 172 deletions.
55 changes: 18 additions & 37 deletions html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -535,19 +535,15 @@ <h4 class="panel-title">Advanced options</h4>
</li>
<li class="list-group-item">
<span>Debugging</span>:<br />
<input type="checkbox" id="debug_main" /> <span>Main</span>,
<input type="checkbox" id="debug_keyboard" />
<span>keyboard</span>,
<input type="checkbox" id="debug_geometry" />
<span>geometry</span>,
<input type="checkbox" id="debug_mouse" /> <span>mouse</span>,
<input type="checkbox" id="debug_clipboard" />
<span>clipboard</span>
<input type="checkbox" id="debug_draw" /> <span>draw</span>,
<input type="checkbox" id="debug_audio" /> <span>audio</span>,
<input type="checkbox" id="debug_network" />
<span>network</span>
<input type="checkbox" id="debug_file" /> <span>file</span>
<input type="checkbox" id="debug_main" /> <span>Main</span>,
<input type="checkbox" id="debug_keyboard" /> <span>keyboard</span>,
<input type="checkbox" id="debug_geometry" /> <span>geometry</span>,
<input type="checkbox" id="debug_mouse" /> <span>mouse</span>,
<input type="checkbox" id="debug_clipboard" /> <span>clipboard</span>
<input type="checkbox" id="debug_draw" /> <span>draw</span>,
<input type="checkbox" id="debug_audio" /> <span>audio</span>,
<input type="checkbox" id="debug_network" /> <span>network</span>
<input type="checkbox" id="debug_file" /> <span>file</span>
</li>
</ul>
</div>
Expand Down Expand Up @@ -919,19 +915,16 @@ <h4 class="panel-title">Advanced options</h4>
if (https) {
protocol_port = 443;
}
document.getElementById("server").value =
getparam("server") || link.hostname;
document.getElementById("port").value =
getparam("port") || link.port || protocol_port;
document.getElementById("server").value = getparam("server") || link.hostname;
document.getElementById("port").value = getparam("port") || link.port || protocol_port;
document.getElementById("path").value = path || pathname;
document.getElementById("username").value = getparam("username") || "";

const override_width = getparam("override_width");
if (override_width) {
document.getElementById("override_width").value = override_width;
} else {
document.getElementById("override_width").placeholder =
window.innerWidth;
document.getElementById("override_width").placeholder = window.innerWidth;
}

const ssl = getboolparam("ssl", https);
Expand Down Expand Up @@ -1034,10 +1027,7 @@ <h4 class="panel-title">Advanced options</h4>
//local storage makes this secure
$("span#insecure-span").hide();
}
$("input#password").prop(
"disabled",
!has_session_storage && !ssl_input.checked && !insecure_input.checked
);
$("input#password").prop("disabled", !has_session_storage && !ssl_input.checked && !insecure_input.checked);
insecure_input.onchange = function () {
$("input#password").prop(
"disabled",
Expand Down Expand Up @@ -1244,8 +1234,7 @@ <h4 class="panel-title">Advanced options</h4>
);
}

const desktop_entry_icon =
document.getElementById("desktop_entry_icon");
const desktop_entry_icon = document.getElementById("desktop_entry_icon");
const desktop_entry = document.getElementById("desktop_entry");
function desktop_entry_changed() {
var de = desktop_entry.options[desktop_entry.selectedIndex].innerHTML;
Expand Down Expand Up @@ -1549,20 +1538,13 @@ <h4 class="panel-title">Advanced options</h4>
const encoding = getparam("encoding") || "auto";
document.getElementById("encoding").value = encoding;

const offscreen = getboolparam(
"offscreen",
XpraOffscreenWorker.isAvailable()
);
const offscreen = getboolparam("offscreen", XpraOffscreenWorker.isAvailable());
document.getElementById("offscreen").checked = offscreen;
if (!XpraOffscreenWorker.isAvailable()) {
document.getElementById("offscreen").disabled = true;
document
.getElementById("offscreen")
.setAttribute("title", "not available in your browser");
document.getElementById("offscreen").setAttribute("title", "not available in your browser");
document.getElementById("offscreen_label").classList.add("disabled");
document
.getElementById("offscreen_label")
.setAttribute("title", "not available in your browser");
document.getElementById("offscreen_label").setAttribute("title", "not available in your browser");
}

let bandwidth_limit = getparam("bandwidth_limit");
Expand Down Expand Up @@ -1597,8 +1579,7 @@ <h4 class="panel-title">Advanced options</h4>
Utilities.debug("request locale:", locale);
if (locale != keyboard_layout) {
keyboard_layout = locale;
document.getElementById("keyboard_layout").value =
keyboard_layout;
document.getElementById("keyboard_layout").value = keyboard_layout;
}
}
}
Expand Down
160 changes: 25 additions & 135 deletions html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ class XpraClient {
[PACKET_TYPES.clipboard_request]: this._process_clipboard_request,
[PACKET_TYPES.clipboard_token]: this._process_clipboard_token,
[PACKET_TYPES.close]: this._process_close,
[PACKET_TYPES.configure_override_redirect]:
this._process_configure_override_redirect,
[PACKET_TYPES.configure_override_redirect]: this._process_configure_override_redirect,
[PACKET_TYPES.cursor]: this._process_cursor,
[PACKET_TYPES.desktop_size]: this._process_desktop_size,
[PACKET_TYPES.disconnect]: this._process_disconnect,
Expand Down Expand Up @@ -499,10 +498,7 @@ class XpraClient {
this.on_connection_progress("Connecting to server", details, 40);
// open the web socket, started it in a worker if available
// check we have enough information for encryption
if (
this.encryption &&
(!this.encryption_key || this.encryption_key == "")
) {
if (this.encryption && (!this.encryption_key || this.encryption_key == "")) {
this.callback_close("no key specified for encryption");
return;
}
Expand Down Expand Up @@ -669,11 +665,7 @@ class XpraClient {
}

request_refresh(wid) {
this.send([
PACKET_TYPES.buffer_refresh,
wid,
0,
100,
this.send([PACKET_TYPES.buffer_refresh, wid, 0, 100,
{
"refresh-now": true,
batch: { reset: true },
Expand Down Expand Up @@ -731,6 +723,7 @@ class XpraClient {
this.clog("encoding:", encoding);
this.encoding = encoding;
}

set_encoding_option(option, value) {
this.clog("encoding: ", option, "=", value);
this.encoding_options[option] = value;
Expand Down Expand Up @@ -1022,22 +1015,10 @@ class XpraClient {
}
let keystring = event.key || String.fromCharCode(keycode);
let unpress_now = false;
this.debug(
"keyboard",
"last keycode pressed=",
this.last_keycode_pressed,
", keycode=",
keycode,
", pressed=",
pressed,
", str=",
keystring
);
this.debug("keyboard", "last keycode pressed=", this.last_keycode_pressed, ", keycode=", keycode,
", pressed=", pressed, ", str=", keystring);
const dead = keystring.toLowerCase() == "dead";
if (
dead &&
((this.last_keycode_pressed != keycode && !pressed) || pressed)
) {
if (dead && ((this.last_keycode_pressed != keycode && !pressed) || pressed)) {
//dead key unpress without first getting a key pressed event,
//or just a regular pressed dead key, in both cases send a pair:
pressed = true;
Expand All @@ -1046,19 +1027,7 @@ class XpraClient {

this.last_keycode_pressed = pressed ? keycode : 0;

this.debug(
"keyboard",
"processKeyEvent(",
pressed,
", ",
event,
") key=",
keyname,
"keycode=",
keycode,
"dead=",
dead
);
this.debug("keyboard", "processKeyEvent(", pressed, ", ", event, ") key=", keyname, "keycode=", keycode, "dead=", dead);

//sync numlock
if (keycode == 144 && pressed) {
Expand Down Expand Up @@ -1182,23 +1151,15 @@ class XpraClient {
}
//let the OS see Control (or Meta on macos) and Shift:
if (clipboard_modifier_keys.includes(keyname)) {
this.debug(
"keyboard",
"passing clipboard modifier key event to browser:",
keyname
);
this.debug("keyboard", "passing clipboard modifier key event to browser:", keyname);
allow_default = true;
}
//let the OS see Shift + Insert:
if (shift && keyname == "Insert") {
this.debug(
"keyboard",
"passing clipboard combination Shift+Insert to browser"
);
this.debug("keyboard", "passing clipboard combination Shift+Insert to browser");
allow_default = true;
}
const is_clipboard_modifier_set =
raw_modifiers.includes(clipboard_modifier);
const is_clipboard_modifier_set = raw_modifiers.includes(clipboard_modifier);
if (is_clipboard_modifier_set) {
const l = keyname.toLowerCase();
if (l == "c" || l == "x" || l == "v") {
Expand All @@ -1211,38 +1172,18 @@ class XpraClient {
);
allow_default = true;
if (l == "v") {
this.clipboard_delayed_event_time =
performance.now() + CLIPBOARD_EVENT_DELAY;
this.clipboard_delayed_event_time = performance.now() + CLIPBOARD_EVENT_DELAY;
}
}
}
}

if (this.topwindow != undefined) {
let packet = [
"key-action",
this.topwindow,
keyname,
pressed,
modifiers,
keyval,
keystring,
keycode,
group,
];
const wid = this.topwindow;
let packet = ["key-action", wid, keyname, pressed, modifiers, keyval, keystring, keycode, group];
this.key_packets.push(packet);
if (unpress_now) {
packet = [
"key-action",
this.topwindow,
keyname,
false,
modifiers,
keyval,
keystring,
keycode,
group,
];
packet = ["key-action", wid, keyname, false, modifiers, keyval, keystring, keycode, group];
this.key_packets.push(packet);
}

Expand Down Expand Up @@ -1273,6 +1214,7 @@ class XpraClient {
_keyb_onkeydown(event) {
return this._keyb_process(true, event);
}

_keyb_onkeyup(event) {
return this._keyb_process(false, event);
}
Expand Down Expand Up @@ -1924,28 +1866,12 @@ class XpraClient {
if (apx > 0) {
const button_x = px >= 0 ? 6 : 7;
const xdist = Math.round((px * 1000) / 120);
this.send([
PACKET_TYPES.wheel_motion,
wid,
button_x,
-xdist,
[x, y],
modifiers,
buttons,
]);
this.send([PACKET_TYPES.wheel_motion, wid, button_x, -xdist, [x, y], modifiers, buttons]);
}
if (apy > 0) {
const button_y = py >= 0 ? 5 : 4;
const ydist = Math.round((py * 1000) / 120);
this.send([
PACKET_TYPES.wheel_motion,
wid,
button_y,
-ydist,
[x, y],
modifiers,
buttons,
]);
this.send([PACKET_TYPES.wheel_motion, wid, button_y, -ydist, [x, y], modifiers, buttons]);
}
return;
}
Expand All @@ -1967,45 +1893,13 @@ class XpraClient {
const button_y = this.wheel_delta_y >= 0 ? 5 : 4;
while (wx >= 120) {
wx -= 120;
this.send([
PACKET_TYPES.button_action,
wid,
button_x,
true,
[x, y],
modifiers,
buttons,
]);
this.send([
PACKET_TYPES.button_action,
wid,
button_x,
false,
[x, y],
modifiers,
buttons,
]);
this.send([PACKET_TYPES.button_action, wid, button_x, true, [x, y], modifiers, buttons]);
this.send([PACKET_TYPES.button_action, wid, button_x, false, [x, y], modifiers, buttons]);
}
while (wy >= 120) {
wy -= 120;
this.send([
PACKET_TYPES.button_action,
wid,
button_y,
true,
[x, y],
modifiers,
buttons,
]);
this.send([
PACKET_TYPES.button_action,
wid,
button_y,
false,
[x, y],
modifiers,
buttons,
]);
this.send([PACKET_TYPES.button_action, wid, button_y, true, [x, y], modifiers, buttons]);
this.send([PACKET_TYPES.button_action, wid, button_y, false, [x, y], modifiers, buttons]);
}
//store left overs:
this.wheel_delta_x = this.wheel_delta_x >= 0 ? wx : -wx;
Expand All @@ -2017,11 +1911,7 @@ class XpraClient {
init_clipboard() {
window.addEventListener("paste", (e) => {
let clipboardData = (e.originalEvent || e).clipboardData;
if (
clipboardData &&
clipboardData.files &&
clipboardData.files.length > 0
) {
if (clipboardData && clipboardData.files && clipboardData.files.length > 0) {
const files = clipboardData.files;
this.clog("paste got", files.length, "files");
for (let index = 0; index < files.length; index++) {
Expand Down Expand Up @@ -2309,8 +2199,7 @@ class XpraClient {
default_settings.auto_fullscreen_desktop_class !== undefined &&
default_settings.auto_fullscreen_desktop_class.length > 0
) {
const auto_fullscreen_desktop_class =
default_settings.auto_fullscreen_desktop_class;
const auto_fullscreen_desktop_class = default_settings.auto_fullscreen_desktop_class;
if (
win.windowtype == "DESKTOP" &&
win.metadata["class-instance"].includes(auto_fullscreen_desktop_class)
Expand Down Expand Up @@ -2490,6 +2379,7 @@ class XpraClient {
this.close();
}, this.HELLO_TIMEOUT);
}

cancel_hello_timer() {
if (this.hello_timer) {
clearTimeout(this.hello_timer);
Expand Down

0 comments on commit cffed14

Please sign in to comment.