LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-07-2010, 02:35 PM   #1
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
WM-hints and moving window?


Hi,

I have a toplevel window that I want to place depending on another toplevel window. I use gtk_window_move(widget, x, y); At startup this function is called several times and y is changed ones from 412 to 413 and x is always 0(checked with gdb in netbeans). The window gets placed at x=10 and y=400 or so. If I do not use variables but pure ints for x and y it gets placed correctly even if its the same values. I suspect that my window manager notice this change of y and place the widget for me. Is this correct and how do I tell the WM not to do so?



This change of y is due to window size is just a local size and not the correct one as in X. Can i force uppdates from X to the local cache?



Any hints are welcome. Happy programing!
 
Old 09-09-2010, 08:20 AM   #2
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Original Poster
Rep: Reputation: 38
This is really strange.

Well i solved the part of getting the correct values from the first window. The solution is to catch the signal configure-event from that widget and then use the values.

The problem now is that if i only move the second window it works or if i only resize the second window it works but if i do both i get the wrong position. This with values from the first position.

gtk_window_resize(widget,w,h);
gtk_window_move(widget,x,y);

and the order do not matter.


hmmmmm
 
Old 09-18-2010, 05:19 AM   #3
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Original Poster
Rep: Reputation: 38
ok i wrote a small program to test it. Now i now its not my code. Its the wm.

The wm (in my case xfwm4) snaps the second window to x = 10 when it should be x=0.

Code:
int main(int argc, char **argv)
{  
    gtk_init(&argc, &argv);

    GtkWidget *win1;
    GtkWidget *win2;
    GdkColor col1;
    GdkColor col2;

    gint x2;


    win1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
    gdk_color_parse("#00f", &col1);
    gtk_widget_modify_bg(win1, GTK_STATE_NORMAL, &col1);

    gtk_window_set_decorated(GTK_WINDOW(win1), FALSE);
    //gtk_window_set_keep_above(GTK_WINDOW(win1), TRUE);
    gtk_window_set_keep_below(GTK_WINDOW(win1),TRUE);
    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(win1), TRUE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(win1), TRUE);
    
    gtk_window_resize(GTK_WINDOW(win1), 200, 200);
    gtk_window_move(GTK_WINDOW(win1), 5, 100);
    gtk_widget_show_all(win1);



    win2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gdk_color_parse("#f00", &col2);
    gtk_widget_modify_bg(win2, GTK_STATE_NORMAL, &col2);

    gtk_window_set_decorated(GTK_WINDOW(win2), FALSE);
    gtk_window_set_keep_above(GTK_WINDOW(win2), TRUE);
    //gtk_window_set_keep_below(GTK_WINDOW(win2),TRUE);
    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(win2), TRUE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(win2), TRUE);
    x2 = 100;
    gtk_window_resize(GTK_WINDOW(win2), 5, 200);
    gtk_window_move(GTK_WINDOW(win2), x2, 100);
    gtk_widget_show_all(win2);
    x2 = 0;
    gtk_window_move(GTK_WINDOW(win2), x2, 100);
    gtk_widget_show_all(win2);

    gtk_main();

    return (EXIT_SUCCESS);
}

Last edited by kalleanka; 09-18-2010 at 05:22 AM.
 
Old 09-23-2010, 07:20 AM   #4
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Original Poster
Rep: Reputation: 38
ok I solved the problem with an ugly hack. I first destroy the widget with gtk_widget_destroy and the recreat it. The the placement works then. The only thing is that one have to filter signals so this only happens when really needed this handeling otherwise preformance will be bad.

It would be nice to know if this problem is to do with my wm or X.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving a window with middle click possible ? wini_g Linux - Software 1 06-16-2006 02:26 AM
problem when moving tcl/tk-window in X mweis Programming 4 02-23-2006 06:04 AM
problem when moving tcl/tk-window in X mweis Linux - Software 0 02-09-2006 07:38 AM
Moving from Gentoo/Slack to Fedora, any hints? MasterC Fedora 4 09-26-2005 05:36 AM
mplayer freezes on moving a window Davebomb Linux - Software 2 12-04-2004 03:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration