Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
merge develop into master

See merge request Scientific-IT-Systems/gr!741
  • Loading branch information
jheinen committed Oct 29, 2021
2 parents c1a1830 + d0ac1e0 commit 194684a
Show file tree
Hide file tree
Showing 16 changed files with 848 additions and 269 deletions.
33 changes: 19 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
.*
!.gitignore
!.git-blame-ignore-rev
!.githooks
build/
dist/
*.o
!.gitignore
*.a
*.so
*.so.dSYM
*.dylib
*.app
*.dylib
*.o
*.pc
*.pkg
*.so
*.so.dSYM
Makedefs
QMakefile
build/
cmake-build-*/
demo
dist/
gksm
gr*.deb
gr*.rpm
cmake-build-*/
moc_*.h
gr_version.h
js/fonts/
js/gr.js
js/libGR.js
lib/gks/qt/gksqt
moc_*.cpp
moc_*.h
qrc_*.cpp
QMakefile
gr_version.h
Makedefs
demo
gksm
35 changes: 23 additions & 12 deletions js/jsterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ JSTerm = function(ispluto=false) {

var jsterm_ispluto = ispluto;

var dpr = window.devicePixelRatio || 1;

window.addEventListener('resize', function() {
// redraw plots if window zoom changed
if (window.devicePixelRatio != Module.dpr) {
for (pid in widgets) {
let _dpr = window.devicePixelRatio || 1;
if (_dpr != dpr) {
dpr = _dpr;
for (let pid in widgets) {
if (typeof(widgets[pid].canvas) !== 'undefined' && document.body.contains(widgets[pid].canvas)) {
widgets[pid].draw();
}
Expand Down Expand Up @@ -178,13 +182,17 @@ JSTerm = function(ispluto=false) {
let overlay = document.createElement('canvas');
overlay.id = 'jsterm-overlay-' + widget.id;
overlay.style = 'position:absolute; top: 0; right: 0; z-index: 2;';
overlay.width = widget.width;
overlay.height = widget.height;
overlay.style.width = widget.width + "px";
overlay.style.height = widget.height + "px";
overlay.width = parseInt(widget.width * dpr, 10);
overlay.height = parseInt(widget.height * dpr, 10);
overlay.getContext('2d').setTransform(dpr, 0, 0, dpr, 0, 0);

let canvas = document.createElement('canvas');
canvas.id = 'jsterm-' + widget.id;
canvas.style = 'position: absolute; top: 0; right: 0; z-index: 0';
canvas.width = widget.width;
canvas.height = widget.height;
canvas.style.width = widget.width + "px";
canvas.style.height = widget.height + "px";
div.appendChild(overlay);
div.appendChild(canvas);
disp.appendChild(div);
Expand Down Expand Up @@ -421,10 +429,13 @@ JSTerm = function(ispluto=false) {
this.width = width;
this.height = height;
if (this.canvas !== undefined) {
this.canvas.width = width;
this.canvas.height = height;
this.overlayCanvas.width = width;
this.overlayCanvas.height = height;
this.canvas.style.width = width + "px";
this.canvas.style.height = height + "px";
this.overlayCanvas.style.width = width + "px";
this.overlayCanvas.style.height = height + "px";
this.overlayCanvas.width = parseInt(width * dpr, 10);
this.overlayCanvas.height = parseInt(height * dpr, 10);
this.overlayCanvas.getContext('2d').setTransform(dpr, 0, 0, dpr, 0, 0);
this.div.style = "position: relative; width: " + width + "px; height: " + height + "px;";
}
this.draw();
Expand Down Expand Up @@ -1116,8 +1127,8 @@ JSTerm = function(ispluto=false) {
if (typeof grm === 'undefined') {
let canvas = document.createElement('canvas');
canvas.id = 'jsterm-hidden-canvas';
canvas.width = 640;
canvas.height = 480;
canvas.style.width = '640px';
canvas.style.height = '480px';
canvas.style = 'display: none;';
document.body.appendChild(canvas);
grm = new GRM('jsterm-hidden-canvas');
Expand Down
18 changes: 5 additions & 13 deletions js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,14 @@ var Module = {
}
},
set_dpr: function() {
var _dpr = window.devicePixelRatio || 1
var _dpr = window.devicePixelRatio || 1;
if (!(this.canvas.id in this.dpr_per_canvas)) {
this.dpr_per_canvas[this.canvas.id] = 1;
}
if (this.dpr_per_canvas[this.canvas.id] != _dpr) {
var initial_width = this.canvas.width / this.dpr_per_canvas[this.canvas.id];
var initial_height = this.canvas.height / this.dpr_per_canvas[this.canvas.id];

this.canvas.style.width = initial_width + 'px';
this.canvas.style.height = initial_height + 'px';
this.canvas.width = parseInt(initial_width * _dpr, 10);
this.canvas.height = parseInt(initial_height * _dpr, 10);

this.context.setTransform(_dpr, 0, 0, _dpr, 0, 0);
this.dpr_per_canvas[this.canvas.id] = _dpr;
}
this.canvas.width = parseInt(this.canvas.clientWidth * _dpr, 10);
this.canvas.height = parseInt(this.canvas.clientHeight * _dpr, 10);
this.context.setTransform(_dpr, 0, 0, _dpr, 0, 0);
this.dpr_per_canvas[this.canvas.id] = _dpr;
if (this.dpr != this.dpr_per_canvas[this.canvas.id]) {
this.dpr = this.dpr_per_canvas[this.canvas.id];
}
Expand Down
2 changes: 2 additions & 0 deletions lib/gks/gks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ void gks_text(double px, double py, char *str)
gks_input2utf8(str, utf8_str, ENCODING_LATIN1);

gks_ft_text(px, py, utf8_str, s, gks_ft_gdp);
gks_free(utf8_str);
}
else
gks_ft_text(px, py, str, s, gks_ft_gdp);
Expand Down Expand Up @@ -2933,6 +2934,7 @@ void gks_inq_text_extent(int wkid, double px, double py, char *str, int *errind,
gks_input2utf8(str, utf8_str, ENCODING_LATIN1);

gks_ft_inq_text_extent(px, py, utf8_str, s, gks_ft_gdp, bx, by);
gks_free(utf8_str);
}
else
gks_ft_inq_text_extent(px, py, str, s, gks_ft_gdp, bx, by);
Expand Down
2 changes: 1 addition & 1 deletion lib/gks/quartz/GKSView.m
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ - (IBAction)saveDocumentAs:(id)sender
[self savePanelDidEnd:savePanel returnCode:result contextInfo:saveFormatPopUp];
}];
#else
[savePanel beginSheetModalForWindow:cWindow
[savePanel beginSheetModalForWindow:[self window]
completionHandler:^(NSInteger result) {
[self savePanelDidEnd:savePanel returnCode:result contextInfo:saveFormatPopUp];
}];
Expand Down
48 changes: 47 additions & 1 deletion lib/gks/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
#include <netinet/in.h>
#include <netdb.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#else
#include <windows.h>
#endif
Expand Down Expand Up @@ -93,9 +94,54 @@ static DWORD WINAPI gksqt_tread(LPVOID parm)

static void *gksqt_tread(void *arg)
{
#ifdef __APPLE__
sigset_t blockMask, origMask;
struct sigaction saIgnore, saOrigQuit, saOrigInt, saDefault;
pid_t pid;

sigemptyset(&blockMask);
sigaddset(&blockMask, SIGCHLD);
sigprocmask(SIG_BLOCK, &blockMask, &origMask);

saIgnore.sa_handler = SIG_IGN;
saIgnore.sa_flags = 0;
sigemptyset(&saIgnore.sa_mask);
sigaction(SIGINT, &saIgnore, &saOrigInt);
sigaction(SIGQUIT, &saIgnore, &saOrigQuit);

pid = fork();
if (pid < 0)
{
fprintf(stderr, "Fork failed\n");
return -1;
}
else if (pid == 0)
{
saDefault.sa_handler = SIG_DFL;
saDefault.sa_flags = 0;
sigemptyset(&saDefault.sa_mask);

if (saOrigInt.sa_handler != SIG_IGN) sigaction(SIGINT, &saDefault, NULL);
if (saOrigQuit.sa_handler != SIG_IGN) sigaction(SIGQUIT, &saDefault, NULL);

sigprocmask(SIG_SETMASK, &origMask, NULL);

is_running = 1;
execl("/bin/sh", "sh", "-c", (char *)arg, (char *)NULL);
is_running = 0;

exit(127);
}

sigprocmask(SIG_SETMASK, &origMask, NULL);
sigaction(SIGINT, &saOrigInt, NULL);
sigaction(SIGQUIT, &saOrigQuit, NULL);
#else
is_running = 1;
system((char *)arg);
is_running = 0;
#endif

return NULL;
}

Expand Down
Loading

0 comments on commit 194684a

Please sign in to comment.