LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-06-2007, 01:57 AM   #1
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Rep: Reputation: 30
move window


hi all
we know that click on the tittlebar we can move the window, but
is there any widget(window) that is movable(means we have to click the mouse button in the middle of the window , and move the window)

am using gtk c.

please help me with an example

thank you in advance
 
Old 10-06-2007, 06:34 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Window placement and movement is something which the Window Manager deals with, and as such it depends which desktop environment you are using. For example, in XFCE, you can alt + left-click anywhere on a window and then drag to move it about.
 
Old 10-06-2007, 07:22 AM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
WindowMaker also works by using ALT+left-click-drag.
 
Old 10-06-2007, 07:37 AM   #4
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by gnashley View Post
WindowMaker also works by using ALT+left-click-drag.
i tried this
Code:
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>


/* prototypes */
void
on_button_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data);


int main (int argc, char *argv[])
{
    GtkWidget *window;
  GtkWidget *eventbox;
 
    gtk_init (&argc, &argv);
   
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  eventbox = gtk_event_box_new ();
  gtk_widget_show (eventbox);
  gtk_container_add (GTK_CONTAINER (window), eventbox);

  gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLBAR);
//gtk_window_set_opacity (window,0);
   
    /* connect signal callbacks */
    g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);
          gtk_signal_connect(GTK_OBJECT(eventbox), "button_press_event",
		     GTK_SIGNAL_FUNC(on_button_press), NULL);

                   
    gtk_widget_show_all (window);
   
    gtk_main ();
 
    return 0;
}

void
on_button_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
//event->keyval == GDK_Alt_L;
g_print("hiiiiiiiiiiiii \n");

}
and compiled
gcc -Wall -g `pkg-config --cflags --libs gtk+-2.0` -o pointer pointer.c

but not getting the window movement...

please help me with this code

thank you inadvance
 
Old 10-06-2007, 08:17 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
It is not something in your code. The window manager is what controls this, not the programs themselves. If your window manager intercepts alt-left drag, your application probably won't even see the event.
 
Old 10-06-2007, 08:24 AM   #6
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
It is not something in your code. The window manager is what controls this, not the programs themselves. If your window manager intercepts alt-left drag, your application probably won't even see the event.
will u please make corrections in my code to get window movement?

thank you in advance
 
Old 10-06-2007, 08:53 AM   #7
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by munna_dude View Post
will u please make corrections in my code to get window movement?
*Bangs head against wall*. What don't you understand about matthewg42's post (particularly the first sentence)?
 
Old 10-06-2007, 09:03 AM   #8
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
This has to be a language problem.

Munna, changing your code cannot fix the problem. Window movement is part of your window manager, which is part of your desktop environment if you use something like KDE or Gnome.
 
Old 10-10-2007, 01:16 AM   #9
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
hi
if we click on the tittlebar and drag the window will move..

how can it will be moving?
if we click on the middle of the window it doesnt move
how to move like this

please help me

thank you in advance
 
Old 10-10-2007, 01:46 AM   #10
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Let me try to explain. What you want to do is *not* controlled by your program. It is controlled by the *window manager*. You can't write code into your program which will make the window movable by clicking and dragging on the middle of the window. Most window managers will do nothing when you click and drag on the middle part of the window. Clicking on the middle of the window causes the window to be focused under most window managers, but dragging from the middlw will do nothing. However, several window managers will allow you to drag from the middle of the window if you press the ALT key while dragging with button 1 of the mouse.
The only way to get your program to do what you want would be to include code which intercepts all clicks on the desktop -basically disabling the window manager which you probably do not want. You might examine the code from programs for handling desktop icons to find a way to do this(ROX-Filer and fbdesktop are two examples). However the icons are unbordered windows which may not be what you want.
 
  


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
How to move a running window to a different DISPLAY? mtford Linux - Desktop 2 03-13-2007 05:32 PM
Can't move window out of bounds jorisb Linux - Software 3 09-29-2004 07:16 PM
move window up in gnome/metacity? codec Linux - Software 3 09-18-2004 03:05 PM
Cannot resize/move firefox window 000jits General 3 09-08-2004 07:39 AM
GTK2 - move a borderless window??? PhilD Programming 3 03-21-2003 08:31 AM

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

All times are GMT -5. The time now is 05:25 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