I’m creating a panel in gtk3 for X11. I managed to implement many functionalities needed in panel window. However, I don’t know how to make it resizable without having decorations.
I tried using gtk_window_begin_resize_drag() but it doesn’t work as expected. What’s the most straightforward way of doing that, or how can I use this function properly, please also explain what this function does specifically.
begin_resize_drag() is the right method to use. You should call it from a button-press event handler of your window.
#include <gtkmm.h>
class MyWindow
: public Gtk::Window
{
public:
MyWindow();
protected:
bool on_button_press(GdkEventButton *button_event);
};
bool MyWindow::on_button_press(GdkEventButton *button_event)
{
if (button_event->button == 1)
get_window()->begin_resize_drag(
Gdk::WINDOW_EDGE_SOUTH_EAST,
button_event->button,
button_event->x_root,
button_event->y_root,
button_event->time);
return false; // propagate event further
}
MyWindow::MyWindow()
: Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{
/* constructor */
add_events(Gdk::POINTER_MOTION_MASK |
Gdk::BUTTON_PRESS_MASK |
Gdk::BUTTON_RELEASE_MASK);
signal_button_press_event().connect(sigc::mem_fun(*this, MyWindow::on_button_press));
}
int main(int argc, char **argv)
{
auto app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
MyWindow window;
window.set_default_size(200, 200);
return app->run(window);
}
See also:
2 Likes
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.