Does a Gtk application window have a callback for mouse movement?
I'm just playing around with Gtk, deciding whether I should spend time learning it. I have an application window with an "activate" callback, which gets called. After that callback returns, and the window is present on the screen, if I move the mouse, I get a "division-by-zero" error. I don't have a mouse movement callback. If that's the problem, I should add one. But what is the name of the mouse movement callback? The only one I've found is "move-cursor", which seems to be for an editing cursor, not a mouse cursor.
I'm using /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 because that's the one that happens to be on my Ubuntu PC. libgtk-3.so.0 is identical to libgtk-3.so.0.2200.25.
MCVE:
#!/usr/local/bin/sbcl --script
(define-alien-routine gtk_application_window_new (* t) (app (* t)))
(define-alien-routine gtk_application_new (* t) (txt c-string) (flags int))
(define-alien-routine g_application_run int
(app (* t)) (argc int) (argv (* t)))
(define-alien-routine g_signal_connect_data int;
(instance (* t)) (sig c-string)
(cback (function void (* t) int))
(data (* t)) (unusedptr (* t)) (unusedint int))
(define-alien-routine gtk_window_set_title void (win (* t)) (ttl (c-string)))
(define-alien-routine gtk_window_set_default_size void
(win (* t)) (x int) (y int))
(define-alien-routine gtk_widget_show_all void (win (* t)))
(sb-alien::define-alien-callback mycallback void ((app (* t)) (u int))
(with-alien ((win (* t)))
(setf win (gtk_application_window_new app))
(gtk_window_set_title win "This")
(gtk_window_set_default_size win 100 100)
(gtk_widget_show_all win)))
(load-shared-object "/usr/lib/x86_64-linux-gnu/libgtk-3.so.0")
(with-alien ((app (* t)) (status int))
(setf app (gtk_application_new nil 0))
(g_signal_connect_data app "activate" mycallback nil nil 0)
(g_application_run app 0 nil))
gtk gtk3
|
show 6 more comments
I'm just playing around with Gtk, deciding whether I should spend time learning it. I have an application window with an "activate" callback, which gets called. After that callback returns, and the window is present on the screen, if I move the mouse, I get a "division-by-zero" error. I don't have a mouse movement callback. If that's the problem, I should add one. But what is the name of the mouse movement callback? The only one I've found is "move-cursor", which seems to be for an editing cursor, not a mouse cursor.
I'm using /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 because that's the one that happens to be on my Ubuntu PC. libgtk-3.so.0 is identical to libgtk-3.so.0.2200.25.
MCVE:
#!/usr/local/bin/sbcl --script
(define-alien-routine gtk_application_window_new (* t) (app (* t)))
(define-alien-routine gtk_application_new (* t) (txt c-string) (flags int))
(define-alien-routine g_application_run int
(app (* t)) (argc int) (argv (* t)))
(define-alien-routine g_signal_connect_data int;
(instance (* t)) (sig c-string)
(cback (function void (* t) int))
(data (* t)) (unusedptr (* t)) (unusedint int))
(define-alien-routine gtk_window_set_title void (win (* t)) (ttl (c-string)))
(define-alien-routine gtk_window_set_default_size void
(win (* t)) (x int) (y int))
(define-alien-routine gtk_widget_show_all void (win (* t)))
(sb-alien::define-alien-callback mycallback void ((app (* t)) (u int))
(with-alien ((win (* t)))
(setf win (gtk_application_window_new app))
(gtk_window_set_title win "This")
(gtk_window_set_default_size win 100 100)
(gtk_widget_show_all win)))
(load-shared-object "/usr/lib/x86_64-linux-gnu/libgtk-3.so.0")
(with-alien ((app (* t)) (status int))
(setf app (gtk_application_new nil 0))
(g_signal_connect_data app "activate" mycallback nil nil 0)
(g_application_run app 0 nil))
gtk gtk3
2
Give us guys an MCVE to observe. We have no idea what your code looks like.
– theGtknerd
Nov 11 '18 at 17:21
I should give it the mouse movement callback first, then make the MCVE from that. The only callback I presently give it is the "activate" callback. It calls that and shows the window. Then when it gets mouse movement is when it crashes with the division-by-zero error.
– Mr E
Nov 12 '18 at 1:37
If you don't know what I mean by a callback, I mean the function you give as an argument to g_signal_connect. The only callback I presently have is the "activate" callback, which gets called and returns. Then, with the window visible, waiting for input, I move the mouse, and it crashes. That seems to imply I need a mouse-movement callback. Right?
– Mr E
Nov 12 '18 at 2:19
3
Please show us some code first. We can't guess why you get a division by 0 error out of the blue. A simple app won't crash just because you didn't connect a callback to a signal.
– liberforce
Nov 12 '18 at 10:30
Please also add the result ofpkg-config --modversion gtk+-3.0
, so we know exactly the version you're using, as the so name is mostly useless.
– liberforce
Nov 12 '18 at 10:32
|
show 6 more comments
I'm just playing around with Gtk, deciding whether I should spend time learning it. I have an application window with an "activate" callback, which gets called. After that callback returns, and the window is present on the screen, if I move the mouse, I get a "division-by-zero" error. I don't have a mouse movement callback. If that's the problem, I should add one. But what is the name of the mouse movement callback? The only one I've found is "move-cursor", which seems to be for an editing cursor, not a mouse cursor.
I'm using /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 because that's the one that happens to be on my Ubuntu PC. libgtk-3.so.0 is identical to libgtk-3.so.0.2200.25.
MCVE:
#!/usr/local/bin/sbcl --script
(define-alien-routine gtk_application_window_new (* t) (app (* t)))
(define-alien-routine gtk_application_new (* t) (txt c-string) (flags int))
(define-alien-routine g_application_run int
(app (* t)) (argc int) (argv (* t)))
(define-alien-routine g_signal_connect_data int;
(instance (* t)) (sig c-string)
(cback (function void (* t) int))
(data (* t)) (unusedptr (* t)) (unusedint int))
(define-alien-routine gtk_window_set_title void (win (* t)) (ttl (c-string)))
(define-alien-routine gtk_window_set_default_size void
(win (* t)) (x int) (y int))
(define-alien-routine gtk_widget_show_all void (win (* t)))
(sb-alien::define-alien-callback mycallback void ((app (* t)) (u int))
(with-alien ((win (* t)))
(setf win (gtk_application_window_new app))
(gtk_window_set_title win "This")
(gtk_window_set_default_size win 100 100)
(gtk_widget_show_all win)))
(load-shared-object "/usr/lib/x86_64-linux-gnu/libgtk-3.so.0")
(with-alien ((app (* t)) (status int))
(setf app (gtk_application_new nil 0))
(g_signal_connect_data app "activate" mycallback nil nil 0)
(g_application_run app 0 nil))
gtk gtk3
I'm just playing around with Gtk, deciding whether I should spend time learning it. I have an application window with an "activate" callback, which gets called. After that callback returns, and the window is present on the screen, if I move the mouse, I get a "division-by-zero" error. I don't have a mouse movement callback. If that's the problem, I should add one. But what is the name of the mouse movement callback? The only one I've found is "move-cursor", which seems to be for an editing cursor, not a mouse cursor.
I'm using /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 because that's the one that happens to be on my Ubuntu PC. libgtk-3.so.0 is identical to libgtk-3.so.0.2200.25.
MCVE:
#!/usr/local/bin/sbcl --script
(define-alien-routine gtk_application_window_new (* t) (app (* t)))
(define-alien-routine gtk_application_new (* t) (txt c-string) (flags int))
(define-alien-routine g_application_run int
(app (* t)) (argc int) (argv (* t)))
(define-alien-routine g_signal_connect_data int;
(instance (* t)) (sig c-string)
(cback (function void (* t) int))
(data (* t)) (unusedptr (* t)) (unusedint int))
(define-alien-routine gtk_window_set_title void (win (* t)) (ttl (c-string)))
(define-alien-routine gtk_window_set_default_size void
(win (* t)) (x int) (y int))
(define-alien-routine gtk_widget_show_all void (win (* t)))
(sb-alien::define-alien-callback mycallback void ((app (* t)) (u int))
(with-alien ((win (* t)))
(setf win (gtk_application_window_new app))
(gtk_window_set_title win "This")
(gtk_window_set_default_size win 100 100)
(gtk_widget_show_all win)))
(load-shared-object "/usr/lib/x86_64-linux-gnu/libgtk-3.so.0")
(with-alien ((app (* t)) (status int))
(setf app (gtk_application_new nil 0))
(g_signal_connect_data app "activate" mycallback nil nil 0)
(g_application_run app 0 nil))
gtk gtk3
gtk gtk3
edited Nov 20 '18 at 0:33
Mr E
asked Nov 11 '18 at 3:44
Mr EMr E
114
114
2
Give us guys an MCVE to observe. We have no idea what your code looks like.
– theGtknerd
Nov 11 '18 at 17:21
I should give it the mouse movement callback first, then make the MCVE from that. The only callback I presently give it is the "activate" callback. It calls that and shows the window. Then when it gets mouse movement is when it crashes with the division-by-zero error.
– Mr E
Nov 12 '18 at 1:37
If you don't know what I mean by a callback, I mean the function you give as an argument to g_signal_connect. The only callback I presently have is the "activate" callback, which gets called and returns. Then, with the window visible, waiting for input, I move the mouse, and it crashes. That seems to imply I need a mouse-movement callback. Right?
– Mr E
Nov 12 '18 at 2:19
3
Please show us some code first. We can't guess why you get a division by 0 error out of the blue. A simple app won't crash just because you didn't connect a callback to a signal.
– liberforce
Nov 12 '18 at 10:30
Please also add the result ofpkg-config --modversion gtk+-3.0
, so we know exactly the version you're using, as the so name is mostly useless.
– liberforce
Nov 12 '18 at 10:32
|
show 6 more comments
2
Give us guys an MCVE to observe. We have no idea what your code looks like.
– theGtknerd
Nov 11 '18 at 17:21
I should give it the mouse movement callback first, then make the MCVE from that. The only callback I presently give it is the "activate" callback. It calls that and shows the window. Then when it gets mouse movement is when it crashes with the division-by-zero error.
– Mr E
Nov 12 '18 at 1:37
If you don't know what I mean by a callback, I mean the function you give as an argument to g_signal_connect. The only callback I presently have is the "activate" callback, which gets called and returns. Then, with the window visible, waiting for input, I move the mouse, and it crashes. That seems to imply I need a mouse-movement callback. Right?
– Mr E
Nov 12 '18 at 2:19
3
Please show us some code first. We can't guess why you get a division by 0 error out of the blue. A simple app won't crash just because you didn't connect a callback to a signal.
– liberforce
Nov 12 '18 at 10:30
Please also add the result ofpkg-config --modversion gtk+-3.0
, so we know exactly the version you're using, as the so name is mostly useless.
– liberforce
Nov 12 '18 at 10:32
2
2
Give us guys an MCVE to observe. We have no idea what your code looks like.
– theGtknerd
Nov 11 '18 at 17:21
Give us guys an MCVE to observe. We have no idea what your code looks like.
– theGtknerd
Nov 11 '18 at 17:21
I should give it the mouse movement callback first, then make the MCVE from that. The only callback I presently give it is the "activate" callback. It calls that and shows the window. Then when it gets mouse movement is when it crashes with the division-by-zero error.
– Mr E
Nov 12 '18 at 1:37
I should give it the mouse movement callback first, then make the MCVE from that. The only callback I presently give it is the "activate" callback. It calls that and shows the window. Then when it gets mouse movement is when it crashes with the division-by-zero error.
– Mr E
Nov 12 '18 at 1:37
If you don't know what I mean by a callback, I mean the function you give as an argument to g_signal_connect. The only callback I presently have is the "activate" callback, which gets called and returns. Then, with the window visible, waiting for input, I move the mouse, and it crashes. That seems to imply I need a mouse-movement callback. Right?
– Mr E
Nov 12 '18 at 2:19
If you don't know what I mean by a callback, I mean the function you give as an argument to g_signal_connect. The only callback I presently have is the "activate" callback, which gets called and returns. Then, with the window visible, waiting for input, I move the mouse, and it crashes. That seems to imply I need a mouse-movement callback. Right?
– Mr E
Nov 12 '18 at 2:19
3
3
Please show us some code first. We can't guess why you get a division by 0 error out of the blue. A simple app won't crash just because you didn't connect a callback to a signal.
– liberforce
Nov 12 '18 at 10:30
Please show us some code first. We can't guess why you get a division by 0 error out of the blue. A simple app won't crash just because you didn't connect a callback to a signal.
– liberforce
Nov 12 '18 at 10:30
Please also add the result of
pkg-config --modversion gtk+-3.0
, so we know exactly the version you're using, as the so name is mostly useless.– liberforce
Nov 12 '18 at 10:32
Please also add the result of
pkg-config --modversion gtk+-3.0
, so we know exactly the version you're using, as the so name is mostly useless.– liberforce
Nov 12 '18 at 10:32
|
show 6 more comments
1 Answer
1
active
oldest
votes
A callback for mouse movement turned out not to be the issue.
The cause of the divide-by-zero error turned out to be that GTK relies on being able to divide by zero. All I had to do to fix it was to tell SBCL to not consider division by zero to be an error. The only reason mouse movement was involved was that the division by zero happens then. The reason why it doesn't happen in most other programming languages is that they don't consider division by zero to be an error.
To fix the MCVE script, to make it work, simply add this line after the shebang line, to tell it to only consider overflow and invalid to be floating point errors, and not division by zero: (sb-int:set-floating-point-modes :traps '(:overflow :invalid))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245656%2fdoes-a-gtk-application-window-have-a-callback-for-mouse-movement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A callback for mouse movement turned out not to be the issue.
The cause of the divide-by-zero error turned out to be that GTK relies on being able to divide by zero. All I had to do to fix it was to tell SBCL to not consider division by zero to be an error. The only reason mouse movement was involved was that the division by zero happens then. The reason why it doesn't happen in most other programming languages is that they don't consider division by zero to be an error.
To fix the MCVE script, to make it work, simply add this line after the shebang line, to tell it to only consider overflow and invalid to be floating point errors, and not division by zero: (sb-int:set-floating-point-modes :traps '(:overflow :invalid))
add a comment |
A callback for mouse movement turned out not to be the issue.
The cause of the divide-by-zero error turned out to be that GTK relies on being able to divide by zero. All I had to do to fix it was to tell SBCL to not consider division by zero to be an error. The only reason mouse movement was involved was that the division by zero happens then. The reason why it doesn't happen in most other programming languages is that they don't consider division by zero to be an error.
To fix the MCVE script, to make it work, simply add this line after the shebang line, to tell it to only consider overflow and invalid to be floating point errors, and not division by zero: (sb-int:set-floating-point-modes :traps '(:overflow :invalid))
add a comment |
A callback for mouse movement turned out not to be the issue.
The cause of the divide-by-zero error turned out to be that GTK relies on being able to divide by zero. All I had to do to fix it was to tell SBCL to not consider division by zero to be an error. The only reason mouse movement was involved was that the division by zero happens then. The reason why it doesn't happen in most other programming languages is that they don't consider division by zero to be an error.
To fix the MCVE script, to make it work, simply add this line after the shebang line, to tell it to only consider overflow and invalid to be floating point errors, and not division by zero: (sb-int:set-floating-point-modes :traps '(:overflow :invalid))
A callback for mouse movement turned out not to be the issue.
The cause of the divide-by-zero error turned out to be that GTK relies on being able to divide by zero. All I had to do to fix it was to tell SBCL to not consider division by zero to be an error. The only reason mouse movement was involved was that the division by zero happens then. The reason why it doesn't happen in most other programming languages is that they don't consider division by zero to be an error.
To fix the MCVE script, to make it work, simply add this line after the shebang line, to tell it to only consider overflow and invalid to be floating point errors, and not division by zero: (sb-int:set-floating-point-modes :traps '(:overflow :invalid))
answered Dec 19 '18 at 16:03
Mr EMr E
114
114
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245656%2fdoes-a-gtk-application-window-have-a-callback-for-mouse-movement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Give us guys an MCVE to observe. We have no idea what your code looks like.
– theGtknerd
Nov 11 '18 at 17:21
I should give it the mouse movement callback first, then make the MCVE from that. The only callback I presently give it is the "activate" callback. It calls that and shows the window. Then when it gets mouse movement is when it crashes with the division-by-zero error.
– Mr E
Nov 12 '18 at 1:37
If you don't know what I mean by a callback, I mean the function you give as an argument to g_signal_connect. The only callback I presently have is the "activate" callback, which gets called and returns. Then, with the window visible, waiting for input, I move the mouse, and it crashes. That seems to imply I need a mouse-movement callback. Right?
– Mr E
Nov 12 '18 at 2:19
3
Please show us some code first. We can't guess why you get a division by 0 error out of the blue. A simple app won't crash just because you didn't connect a callback to a signal.
– liberforce
Nov 12 '18 at 10:30
Please also add the result of
pkg-config --modversion gtk+-3.0
, so we know exactly the version you're using, as the so name is mostly useless.– liberforce
Nov 12 '18 at 10:32