]> Dogcows Code - chaz/openbox/commitdiff
only show() if the dialog is not already visible
authorDana Jansens <danakj@orodu.net>
Sun, 16 Feb 2003 12:20:10 +0000 (12:20 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Feb 2003 12:20:10 +0000 (12:20 +0000)
otk/messagedialog.cc

index df004347bdf3dd9b9826dd42c7d69d753e738e0b..216189818cd224f184bee4c1b80321de59c7a433 100644 (file)
@@ -101,7 +101,8 @@ MessageDialog::~MessageDialog()
 
 const DialogButton& MessageDialog::run()
 {
-  show();
+  if (!visible())
+    show();
 
   while (visible()) {
     dispatcher()->dispatchEvents();
@@ -118,11 +119,17 @@ void MessageDialog::show()
     _button_widgets.push_back(new DialogButtonWidget(_button_holder,
                                                     this, *it));
 
+  Rect r;
+
+  if (parent())
+    r = parent()->area();
+  else
+    r = Rect(Point(0, 0), display->screenInfo(screen())->size());
+  
   XSizeHints size;
-  size.flags = PMinSize;
+  size.flags = PMinSize | PPosition;
   size.min_width = minSize().width();
   size.min_height = minSize().height();
-  XSetWMNormalHints(**display, window(), &size);
 
   Size dest = area().size();
   if (dest.width() < 200 || dest.height() < 100) {
@@ -132,6 +139,12 @@ void MessageDialog::show()
     resize(dest);
   }
 
+  // center it above its parent
+  move(Point(r.x() + (r.width() - dest.width()) / 2,
+            r.y() + (r.height() - dest.height()) / 2));
+  
+  XSetWMNormalHints(**display, window(), &size);
+  
   Widget::show();
 }
 
This page took 0.023447 seconds and 4 git commands to generate.